zonca commited on
Commit
c57f869
·
1 Parent(s): 291f2e5

smolagents web search

Browse files
Files changed (2) hide show
  1. app.py +13 -2
  2. requirements.txt +2 -1
app.py CHANGED
@@ -4,6 +4,10 @@ import requests
4
  import inspect
5
  import pandas as pd
6
 
 
 
 
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -12,10 +16,17 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
  class MyAgent:
13
  def __init__(self):
14
  print("MyAgent initialized.")
 
 
 
 
 
 
15
 
16
  def __call__(self, question: str) -> str:
17
- fixed_answer = None
18
- return fixed_answer
 
19
 
20
 
21
  def run_and_submit_all(profile: gr.OAuthProfile | None):
 
4
  import inspect
5
  import pandas as pd
6
 
7
+ # Add smolagents import
8
+ import smolagents
9
+ from smolagents.tools import WebSearchTool
10
+
11
  # (Keep Constants as is)
12
  # --- Constants ---
13
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
16
  class MyAgent:
17
  def __init__(self):
18
  print("MyAgent initialized.")
19
+ # Standard tools from smolagents
20
+ self.tools = smolagents.get_standard_tools()
21
+ # Add web search tool
22
+ self.tools.append(WebSearchTool())
23
+ # Create the agent with tools
24
+ self.agent = smolagents.Agent(tools=self.tools)
25
 
26
  def __call__(self, question: str) -> str:
27
+ # Use the agent to answer the question
28
+ result = self.agent.run(question)
29
+ return result
30
 
31
 
32
  def run_and_submit_all(profile: gr.OAuthProfile | None):
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  gradio
2
- requests
 
 
1
  gradio
2
+ requests
3
+ smolagents