Files changed (1) hide show
  1. app.py +21 -6
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
- # --- Basic Agent Definition ---
12
- # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
13
  class BasicAgent:
14
  def __init__(self):
15
- print("BasicAgent initialized.")
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  def __call__(self, question: str) -> str:
17
- print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
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):