Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -10,14 +10,31 @@ 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
+
14
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
15
+
16
  class BasicAgent:
17
  def __init__(self):
18
+ token = os.environ["HF_TOKEN"]
19
+
20
+ self.agent = CodeAgent(
21
+ tools=[DuckDuckGoSearchTool(max_results=5)],
22
+ model=InferenceClientModel(token=token),
23
+ max_steps=6,
24
+ )
25
+
26
  def __call__(self, question: str) -> str:
27
+ prompt = (
28
+ "Solve this question carefully. "
29
+ "Use your available tools when needed. "
30
+ "Return only the exact final answer, "
31
+ "without explanation or a prefix.\n\n"
32
+ f"Question: {question}"
33
+ )
34
+
35
+ result = self.agent.run(prompt)
36
+ return str(result).strip()
37
+
38
 
39
  def run_and_submit_all( profile: gr.OAuthProfile | None):
40
  """