Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import inspect
|
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
# smolagents imports
|
| 8 |
-
from smolagents import CodeAgent,
|
| 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
|
| 239 |
try:
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
| 242 |
except Exception as e:
|
| 243 |
print(f"โ Error initializing model: {e}")
|
| 244 |
-
# Fallback to
|
| 245 |
-
self.model =
|
| 246 |
|
| 247 |
-
# Initialize tools
|
| 248 |
-
self.
|
| 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.
|
| 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
|