Update agent.py
Browse files
agent.py
CHANGED
@@ -259,6 +259,9 @@ def analyze_excel_file(file_path: str, query: str) -> str:
|
|
259 |
except Exception as e:
|
260 |
return f"Error analyzing Excel file: {str(e)}"
|
261 |
|
|
|
|
|
|
|
262 |
# --------------------------------------------------------------------------- #
|
263 |
# Custom LiteLLM model with rate limiting and error handling
|
264 |
# --------------------------------------------------------------------------- #
|
@@ -303,17 +306,23 @@ class RateLimitedClaudeModel:
|
|
303 |
temperature=temperature
|
304 |
)
|
305 |
|
306 |
-
def __call__(self, prompt: str,
|
307 |
"""
|
308 |
Call the model with rate limiting and error handling
|
309 |
|
310 |
Args:
|
311 |
prompt: The prompt to generate from
|
312 |
-
system_instruction: The system instruction to use
|
313 |
|
314 |
Returns:
|
315 |
The generated text
|
316 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
retries = 0
|
318 |
while True:
|
319 |
try:
|
@@ -321,7 +330,7 @@ class RateLimitedClaudeModel:
|
|
321 |
RATE_LIMITER.wait()
|
322 |
|
323 |
# Call the model
|
324 |
-
return self.model(prompt,
|
325 |
|
326 |
except Exception as e:
|
327 |
# Check if it's a rate limit error
|
|
|
259 |
except Exception as e:
|
260 |
return f"Error analyzing Excel file: {str(e)}"
|
261 |
|
262 |
+
# --------------------------------------------------------------------------- #
|
263 |
+
# Custom LiteLLM model with rate limiting and error handling
|
264 |
+
# --------------------------------------------------------------------------- #
|
265 |
# --------------------------------------------------------------------------- #
|
266 |
# Custom LiteLLM model with rate limiting and error handling
|
267 |
# --------------------------------------------------------------------------- #
|
|
|
306 |
temperature=temperature
|
307 |
)
|
308 |
|
309 |
+
def __call__(self, prompt: str, **kwargs) -> str:
|
310 |
"""
|
311 |
Call the model with rate limiting and error handling
|
312 |
|
313 |
Args:
|
314 |
prompt: The prompt to generate from
|
|
|
315 |
|
316 |
Returns:
|
317 |
The generated text
|
318 |
"""
|
319 |
+
# Make sure system_instruction is always present
|
320 |
+
if "system_instruction" not in kwargs:
|
321 |
+
system_instruction = """You are a concise, highly accurate assistant specialized in solving challenges.
|
322 |
+
Your answers should be precise, direct, and exactly match the expected format.
|
323 |
+
All answers are graded by exact string match, so format carefully!"""
|
324 |
+
kwargs["system_instruction"] = system_instruction
|
325 |
+
|
326 |
retries = 0
|
327 |
while True:
|
328 |
try:
|
|
|
330 |
RATE_LIMITER.wait()
|
331 |
|
332 |
# Call the model
|
333 |
+
return self.model(prompt, **kwargs)
|
334 |
|
335 |
except Exception as e:
|
336 |
# Check if it's a rate limit error
|