Spaces:
Sleeping
Sleeping
Update app/core/model_loader.py
Browse files- app/core/model_loader.py +6 -3
app/core/model_loader.py
CHANGED
|
@@ -3,6 +3,7 @@ import json
|
|
| 3 |
import logging
|
| 4 |
import threading
|
| 5 |
import time
|
|
|
|
| 6 |
from datetime import datetime
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
from groq import Groq
|
|
@@ -35,7 +36,11 @@ class LLMSingleton:
|
|
| 35 |
else:
|
| 36 |
self.client = Groq(api_key=self.api_key)
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
self._stats_lock = threading.Lock()
|
| 40 |
self._rpm_lock = threading.Lock()
|
| 41 |
|
|
@@ -125,8 +130,6 @@ class LLMSingleton:
|
|
| 125 |
return True
|
| 126 |
|
| 127 |
def generate(self, prompt: str, max_tokens: int = 2048) -> str:
|
| 128 |
-
import random
|
| 129 |
-
|
| 130 |
self._check_daily_reset()
|
| 131 |
self._check_rpm_window()
|
| 132 |
|
|
|
|
| 3 |
import logging
|
| 4 |
import threading
|
| 5 |
import time
|
| 6 |
+
import random
|
| 7 |
from datetime import datetime
|
| 8 |
from dotenv import load_dotenv
|
| 9 |
from groq import Groq
|
|
|
|
| 36 |
else:
|
| 37 |
self.client = Groq(api_key=self.api_key)
|
| 38 |
|
| 39 |
+
# Sanitize model string to strip hidden whitespace, newlines, or quotes injected by HF UI
|
| 40 |
+
raw_model = os.getenv("GROQ_MODEL", "llama-3.1-8b-instant")
|
| 41 |
+
clean_model = raw_model.strip().strip('"').strip("'") if raw_model else ""
|
| 42 |
+
self.model_name = clean_model if clean_model else "llama-3.1-8b-instant"
|
| 43 |
+
|
| 44 |
self._stats_lock = threading.Lock()
|
| 45 |
self._rpm_lock = threading.Lock()
|
| 46 |
|
|
|
|
| 130 |
return True
|
| 131 |
|
| 132 |
def generate(self, prompt: str, max_tokens: int = 2048) -> str:
|
|
|
|
|
|
|
| 133 |
self._check_daily_reset()
|
| 134 |
self._check_rpm_window()
|
| 135 |
|