Update app.py
Browse files
app.py
CHANGED
|
@@ -273,21 +273,21 @@ class GAIAAgent:
|
|
| 273 |
|
| 274 |
# Initialize the model with fallback options
|
| 275 |
try:
|
| 276 |
-
# Try powerful model first
|
| 277 |
-
model_id = "
|
| 278 |
self.model = InferenceClientModel(model_id=model_id)
|
| 279 |
print(f"β
Model initialized successfully: {model_id}")
|
| 280 |
except Exception as e:
|
| 281 |
print(f"β οΈ Error with primary model: {e}")
|
| 282 |
try:
|
| 283 |
-
# Fallback to a
|
| 284 |
fallback_model = "microsoft/DialoGPT-medium"
|
| 285 |
self.model = InferenceClientModel(model_id=fallback_model)
|
| 286 |
print(f"β
Fallback model initialized: {fallback_model}")
|
| 287 |
except Exception as e2:
|
| 288 |
print(f"β οΈ Error with fallback model: {e2}")
|
| 289 |
try:
|
| 290 |
-
# Last resort - use default
|
| 291 |
self.model = InferenceClientModel()
|
| 292 |
print("β
Default model initialized")
|
| 293 |
except Exception as e3:
|
|
@@ -344,8 +344,16 @@ Question: {question}
|
|
| 344 |
|
| 345 |
Answer:"""
|
| 346 |
|
| 347 |
-
# Run the agent
|
| 348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
|
| 350 |
# Clean up the result to ensure it's just the answer
|
| 351 |
if isinstance(result, str):
|
|
@@ -540,7 +548,7 @@ with gr.Blocks(title="GAIA Agent Evaluation") as demo:
|
|
| 540 |
- π **Data Analysis**: Statistical analysis of numerical data
|
| 541 |
- π’ **Number Extraction**: Intelligent number parsing from text
|
| 542 |
- π **Text Analysis**: Counting and text processing utilities
|
| 543 |
-
- π€ **LLM Model**: Llama-3.
|
| 544 |
|
| 545 |
**Instructions:**
|
| 546 |
1. π **Clone this space** and customize the agent as needed
|
|
|
|
| 273 |
|
| 274 |
# Initialize the model with fallback options
|
| 275 |
try:
|
| 276 |
+
# Try powerful model first - but use one that's more widely available
|
| 277 |
+
model_id = "meta-llama/Llama-3.1-8B-Instruct"
|
| 278 |
self.model = InferenceClientModel(model_id=model_id)
|
| 279 |
print(f"β
Model initialized successfully: {model_id}")
|
| 280 |
except Exception as e:
|
| 281 |
print(f"β οΈ Error with primary model: {e}")
|
| 282 |
try:
|
| 283 |
+
# Fallback to a widely available model
|
| 284 |
fallback_model = "microsoft/DialoGPT-medium"
|
| 285 |
self.model = InferenceClientModel(model_id=fallback_model)
|
| 286 |
print(f"β
Fallback model initialized: {fallback_model}")
|
| 287 |
except Exception as e2:
|
| 288 |
print(f"β οΈ Error with fallback model: {e2}")
|
| 289 |
try:
|
| 290 |
+
# Last resort - use default (should work without authentication)
|
| 291 |
self.model = InferenceClientModel()
|
| 292 |
print("β
Default model initialized")
|
| 293 |
except Exception as e3:
|
|
|
|
| 344 |
|
| 345 |
Answer:"""
|
| 346 |
|
| 347 |
+
# Run the agent with error handling for quota issues
|
| 348 |
+
try:
|
| 349 |
+
result = self.agent.run(enhanced_prompt)
|
| 350 |
+
except Exception as api_error:
|
| 351 |
+
if "402" in str(api_error) or "Payment Required" in str(api_error) or "exceeded" in str(api_error):
|
| 352 |
+
print(f"β οΈ API quota exceeded, trying simpler approach...")
|
| 353 |
+
# Fallback: try to answer with basic tools only
|
| 354 |
+
result = f"Unable to process due to API limits: {str(api_error)}"
|
| 355 |
+
else:
|
| 356 |
+
raise api_error
|
| 357 |
|
| 358 |
# Clean up the result to ensure it's just the answer
|
| 359 |
if isinstance(result, str):
|
|
|
|
| 548 |
- π **Data Analysis**: Statistical analysis of numerical data
|
| 549 |
- π’ **Number Extraction**: Intelligent number parsing from text
|
| 550 |
- π **Text Analysis**: Counting and text processing utilities
|
| 551 |
+
- π€ **LLM Model**: Llama-3.1-8B-Instruct for advanced reasoning
|
| 552 |
|
| 553 |
**Instructions:**
|
| 554 |
1. π **Clone this space** and customize the agent as needed
|