Phoenix21 commited on
Commit
d05df24
·
verified ·
1 Parent(s): e857f76

Added exception handling

Browse files
Files changed (1) hide show
  1. 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
- groq_fallback_llm = ChatGroq(
179
- model=GROQ_MODELS["default"],
180
- temperature=0.7,
181
- groq_api_key=fallback_groq_api_key,
182
- max_tokens=2048
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