Phoenix21 commited on
Commit
7d710bd
·
verified ·
1 Parent(s): 5fd3ff4

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +18 -1
pipeline.py CHANGED
@@ -191,12 +191,29 @@ CACHE_SIZE_LIMIT = 1000
191
  # logger.error(f"Failed to initialize ChatGroq: {e}")
192
  # raise RuntimeError("ChatGroq initialization failed.") from e
193
 
 
 
 
 
 
 
194
 
195
 
196
- ChatGroq.model_rebuild()
197
 
198
  # Initialize ChatGroq with the callback manager
199
  try:
 
 
 
 
 
 
 
 
 
 
 
 
200
  fallback_groq_api_key = os.environ.get("GROQ_API_KEY_FALLBACK", os.environ.get("GROQ_API_KEY"))
201
  groq_fallback_llm = ChatGroq(
202
  model=GROQ_MODELS["default"],
 
191
  # logger.error(f"Failed to initialize ChatGroq: {e}")
192
  # raise RuntimeError("ChatGroq initialization failed.") from e
193
 
194
+ # Fix for ChatGroq initialization with model_rebuild
195
+
196
+ from langchain_core.callbacks import CallbackManager
197
+ from langchain_core.callbacks.base import BaseCallbackHandler
198
+ from langchain_core.caches import BaseCache # Import BaseCache (this might be needed)
199
+
200
 
201
 
 
202
 
203
  # Initialize ChatGroq with the callback manager
204
  try:
205
+ # First, ensure BaseCache is defined (if needed)
206
+ class NoCache(BaseCache):
207
+ """Simple no-op cache implementation."""
208
+ def __init__(self): pass
209
+ def lookup(self, prompt, llm_string): return None
210
+ def update(self, prompt, llm_string, return_val): pass
211
+ def clear(self): pass
212
+
213
+ # Call model_rebuild() before initializing
214
+ ChatGroq.model_rebuild()
215
+
216
+ # Then initialize the model
217
  fallback_groq_api_key = os.environ.get("GROQ_API_KEY_FALLBACK", os.environ.get("GROQ_API_KEY"))
218
  groq_fallback_llm = ChatGroq(
219
  model=GROQ_MODELS["default"],