Update app.py
#161
by
deanoreese
- opened
app.py
CHANGED
@@ -8,15 +8,30 @@ import pandas as pd
|
|
8 |
# --- Constants ---
|
9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
class BasicAgent:
|
14 |
def __init__(self):
|
15 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def __call__(self, question: str) -> str:
|
17 |
-
print(f"
|
18 |
-
|
19 |
-
|
20 |
return fixed_answer
|
21 |
|
22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
8 |
# --- Constants ---
|
9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
10 |
|
11 |
+
from smolagents.agent import ToolCallingAgent
|
12 |
+
from smolagents.models.hf_api import HfApiModel
|
13 |
+
from smolagents.tools.duckduckgo import DuckDuckGoSearchTool
|
14 |
+
|
15 |
class BasicAgent:
|
16 |
def __init__(self):
|
17 |
+
print("π§ Initializing real agent with web search...")
|
18 |
+
self.model = HfApiModel(
|
19 |
+
model="mistralai/Mistral-7B-Instruct-v0.2",
|
20 |
+
api_key=os.getenv("HF_API_KEY")
|
21 |
+
)
|
22 |
+
self.agent = ToolCallingAgent(
|
23 |
+
name="gaia_agent",
|
24 |
+
description="Agent that answers questions using web search and reasoning.",
|
25 |
+
model=self.model,
|
26 |
+
tools=[DuckDuckGoSearchTool()],
|
27 |
+
max_steps=4,
|
28 |
+
verbose=True
|
29 |
+
)
|
30 |
+
|
31 |
def __call__(self, question: str) -> str:
|
32 |
+
print(f"π§ Question: {question}")
|
33 |
+
return self.agent.run(question).strip()
|
34 |
+
|
35 |
return fixed_answer
|
36 |
|
37 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|