Spaces:
Running
Running
Added exception handling
Browse files- pipeline.py +12 -6
pipeline.py
CHANGED
@@ -175,12 +175,18 @@ CACHE_SIZE_LIMIT = 1000
|
|
175 |
|
176 |
# Fallback
|
177 |
fallback_groq_api_key = os.environ.get("GROQ_API_KEY_FALLBACK", "GROQ_API_KEY")
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
# -------------------------------------------------------
|
186 |
# Rate-limit & Cache
|
|
|
175 |
|
176 |
# Fallback
|
177 |
fallback_groq_api_key = os.environ.get("GROQ_API_KEY_FALLBACK", "GROQ_API_KEY")
|
178 |
+
|
179 |
+
# Attempt to initialize ChatGroq without a cache
|
180 |
+
try:
|
181 |
+
groq_fallback_llm = ChatGroq(
|
182 |
+
model=GROQ_MODELS["default"],
|
183 |
+
temperature=0.7,
|
184 |
+
groq_api_key=fallback_groq_api_key,
|
185 |
+
max_tokens=2048
|
186 |
+
)
|
187 |
+
except Exception as e:
|
188 |
+
logger.error(f"Failed to initialize ChatGroq: {e}")
|
189 |
+
raise RuntimeError("ChatGroq initialization failed.") from e
|
190 |
|
191 |
# -------------------------------------------------------
|
192 |
# Rate-limit & Cache
|