Phoenix21 commited on
Commit
3a680bc
·
verified ·
1 Parent(s): c1057bc

Added baseCache

Browse files
Files changed (1) hide show
  1. pipeline.py +8 -3
pipeline.py CHANGED
@@ -188,14 +188,18 @@ CACHE_SIZE_LIMIT = 1000
188
  # logger.error(f"Failed to initialize ChatGroq: {e}")
189
  # raise RuntimeError("ChatGroq initialization failed.") from e
190
 
191
- # Define a minimal no-op cache class
192
- class NoOpCache:
193
  def lookup(self, key: str):
194
  return None # Always return None, meaning no cache hit
195
 
196
  def update(self, key: str, value: str):
197
  pass # Do nothing on cache update
198
 
 
 
 
 
199
  # Assign the no-op cache to ChatGroq
200
  ChatGroq.cache = NoOpCache()
201
 
@@ -206,7 +210,7 @@ ChatGroq.model_rebuild()
206
  fallback_groq_api_key = os.environ.get("GROQ_API_KEY_FALLBACK", "GROQ_API_KEY")
207
  try:
208
  groq_fallback_llm = ChatGroq(
209
- model=GROQ_MODELS["default"],
210
  temperature=0.7,
211
  groq_api_key=fallback_groq_api_key,
212
  max_tokens=2048
@@ -215,6 +219,7 @@ except Exception as e:
215
  logger.error(f"Failed to initialize ChatGroq: {e}")
216
  raise RuntimeError("ChatGroq initialization failed.") from e
217
 
 
218
  # -------------------------------------------------------
219
  # Rate-limit & Cache
220
  # -------------------------------------------------------
 
188
  # logger.error(f"Failed to initialize ChatGroq: {e}")
189
  # raise RuntimeError("ChatGroq initialization failed.") from e
190
 
191
+ # Define a dummy BaseCache class locally
192
+ class BaseCache:
193
  def lookup(self, key: str):
194
  return None # Always return None, meaning no cache hit
195
 
196
  def update(self, key: str, value: str):
197
  pass # Do nothing on cache update
198
 
199
+ # Define a no-op cache that does nothing
200
+ class NoOpCache(BaseCache):
201
+ pass
202
+
203
  # Assign the no-op cache to ChatGroq
204
  ChatGroq.cache = NoOpCache()
205
 
 
210
  fallback_groq_api_key = os.environ.get("GROQ_API_KEY_FALLBACK", "GROQ_API_KEY")
211
  try:
212
  groq_fallback_llm = ChatGroq(
213
+ model=GROQ_MODELS["default"], # Replace with your model name
214
  temperature=0.7,
215
  groq_api_key=fallback_groq_api_key,
216
  max_tokens=2048
 
219
  logger.error(f"Failed to initialize ChatGroq: {e}")
220
  raise RuntimeError("ChatGroq initialization failed.") from e
221
 
222
+
223
  # -------------------------------------------------------
224
  # Rate-limit & Cache
225
  # -------------------------------------------------------