vissutagunawan commited on
Commit
1e94011
Β·
verified Β·
1 Parent(s): bf92be5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
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 = "mistralai/Mistral-7B-Instruct-v0.1"
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 different 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
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
- result = self.agent.run(enhanced_prompt)
 
 
 
 
 
 
 
 
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.3-70B-Instruct for advanced reasoning
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