deanoreese commited on
Commit
27e8727
·
verified ·
1 Parent(s): 08eb6d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -10,14 +10,30 @@ 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):
23
  """
 
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
+ from smolagents.agent import ToolCallingAgent
14
+ from smolagents.models.hf_api import HfApiModel
15
+ from smolagents.tools.duckduckgo import DuckDuckGoSearchTool
16
+ import os
17
+
18
  class BasicAgent:
19
  def __init__(self):
20
+ print("✅ Initializing BasicAgent with model + tools...")
21
+ self.model = HfApiModel(
22
+ model="mistralai/Mistral-7B-Instruct-v0.2",
23
+ api_key=os.getenv("HF_API_KEY")
24
+ )
25
+ self.agent = ToolCallingAgent(
26
+ name="search_agent",
27
+ description="Answers GAIA questions using search and reasoning.",
28
+ model=self.model,
29
+ tools=[DuckDuckGoSearchTool()],
30
+ max_steps=4
31
+ )
32
+
33
  def __call__(self, question: str) -> str:
34
+ print(f"🧠 Running agent on: {question}")
35
+ return self.agent.run(question).strip()
36
+
 
37
 
38
  def run_and_submit_all( profile: gr.OAuthProfile | None):
39
  """