vissutagunawan commited on
Commit
9a7d309
ยท
verified ยท
1 Parent(s): 6823c3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -5,7 +5,7 @@ import inspect
5
  import pandas as pd
6
 
7
  # smolagents imports
8
- from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, tool
9
  import re
10
  from typing import Optional, Union, Any
11
  import json
@@ -235,18 +235,19 @@ class GAIAAgent:
235
  def __init__(self):
236
  print("GAIAAgent initializing with smolagents...")
237
 
238
- # Initialize the model (using HuggingFace free inference API)
239
  try:
240
- self.model = HfApiModel()
241
- print("โœ… Model initialized successfully")
 
 
242
  except Exception as e:
243
  print(f"โŒ Error initializing model: {e}")
244
- # Fallback to a basic model
245
- self.model = HfApiModel()
246
 
247
- # Initialize tools
248
- self.tools = [
249
- DuckDuckGoSearchTool(),
250
  visit_webpage,
251
  calculate_math,
252
  analyze_data,
@@ -257,8 +258,9 @@ class GAIAAgent:
257
  # Create the CodeAgent with enhanced capabilities
258
  try:
259
  self.agent = CodeAgent(
260
- tools=self.tools,
261
  model=self.model,
 
262
  additional_authorized_imports=[
263
  'requests', 'bs4', 'json', 'csv', 'math', 'statistics',
264
  're', 'urllib.parse', 'base64', 'datetime', 'calendar'
@@ -266,7 +268,7 @@ class GAIAAgent:
266
  max_steps=10, # Allow multiple reasoning steps
267
  verbosity_level=1 # Reduce verbosity for cleaner output
268
  )
269
- print("โœ… GAIA Agent initialized successfully with enhanced tools")
270
  except Exception as e:
271
  print(f"โŒ Error initializing agent: {e}")
272
  raise e
@@ -483,12 +485,14 @@ with gr.Blocks(title="GAIA Agent Evaluation") as demo:
483
  **Enhanced Agent for GAIA Benchmark Certification**
484
 
485
  This enhanced agent uses Hugging Face's **smolagents** framework with multiple specialized tools:
486
- - ๐Ÿ” **Web Search**: DuckDuckGoSearchTool for finding information
 
487
  - ๐ŸŒ **Web Scraping**: Custom webpage visitor for content extraction
488
  - ๐Ÿงฎ **Mathematics**: Advanced calculation capabilities
489
  - ๐Ÿ“Š **Data Analysis**: Statistical analysis of numerical data
490
  - ๐Ÿ”ข **Number Extraction**: Intelligent number parsing from text
491
  - ๐Ÿ“ **Text Analysis**: Counting and text processing utilities
 
492
 
493
  **Instructions:**
494
  1. ๐Ÿ”„ **Clone this space** and customize the agent as needed
 
5
  import pandas as pd
6
 
7
  # smolagents imports
8
+ from smolagents import CodeAgent, InferenceClientModel, tool
9
  import re
10
  from typing import Optional, Union, Any
11
  import json
 
235
  def __init__(self):
236
  print("GAIAAgent initializing with smolagents...")
237
 
238
+ # Initialize the model (using HuggingFace Inference Client)
239
  try:
240
+ # Use a powerful model for better reasoning on GAIA benchmark
241
+ model_id = "meta-llama/Llama-3.3-70B-Instruct"
242
+ self.model = InferenceClientModel(model_id=model_id)
243
+ print(f"โœ… Model initialized successfully: {model_id}")
244
  except Exception as e:
245
  print(f"โŒ Error initializing model: {e}")
246
+ # Fallback to default model
247
+ self.model = InferenceClientModel()
248
 
249
+ # Initialize tools (custom tools + base tools from smolagents)
250
+ self.custom_tools = [
 
251
  visit_webpage,
252
  calculate_math,
253
  analyze_data,
 
258
  # Create the CodeAgent with enhanced capabilities
259
  try:
260
  self.agent = CodeAgent(
261
+ tools=self.custom_tools,
262
  model=self.model,
263
+ add_base_tools=True, # Adds DuckDuckGoSearchTool and other base tools
264
  additional_authorized_imports=[
265
  'requests', 'bs4', 'json', 'csv', 'math', 'statistics',
266
  're', 'urllib.parse', 'base64', 'datetime', 'calendar'
 
268
  max_steps=10, # Allow multiple reasoning steps
269
  verbosity_level=1 # Reduce verbosity for cleaner output
270
  )
271
+ print("โœ… GAIA Agent initialized successfully with enhanced tools and base toolkit")
272
  except Exception as e:
273
  print(f"โŒ Error initializing agent: {e}")
274
  raise e
 
485
  **Enhanced Agent for GAIA Benchmark Certification**
486
 
487
  This enhanced agent uses Hugging Face's **smolagents** framework with multiple specialized tools:
488
+ - ๐Ÿ” **Web Search**: DuckDuckGoSearchTool (from base toolkit) for finding information
489
+ - ๐Ÿ **Python Interpreter**: Code execution capabilities (from base toolkit)
490
  - ๐ŸŒ **Web Scraping**: Custom webpage visitor for content extraction
491
  - ๐Ÿงฎ **Mathematics**: Advanced calculation capabilities
492
  - ๐Ÿ“Š **Data Analysis**: Statistical analysis of numerical data
493
  - ๐Ÿ”ข **Number Extraction**: Intelligent number parsing from text
494
  - ๐Ÿ“ **Text Analysis**: Counting and text processing utilities
495
+ - ๐Ÿค– **LLM Model**: Llama-3.3-70B-Instruct for advanced reasoning
496
 
497
  **Instructions:**
498
  1. ๐Ÿ”„ **Clone this space** and customize the agent as needed