SrcLurker commited on
Commit
7376a97
·
1 Parent(s): 9b27e1d

hit google limits.

Browse files
Files changed (3) hide show
  1. basic_agent.py +27 -10
  2. basic_agent_test.py +4 -0
  3. requirements.txt +1 -0
basic_agent.py CHANGED
@@ -23,9 +23,6 @@ class BasicAgent:
23
  # Logs appear to be swallowed.
24
  LOG.warning("logging BasicAgent initialized.")
25
 
26
- # Force google for now.
27
- model_id = "google"
28
-
29
  # Assume we will use the default model creation
30
  self.model = None
31
 
@@ -63,35 +60,55 @@ class BasicAgent:
63
  )
64
  print(f"NEW2: BasicAgent {self.model_id=} {self.model=}")
65
 
66
- self.tools = [
67
  smolagents.DuckDuckGoSearchTool(),
68
  smolagents.VisitWebpageTool(),
69
  smolagents.FinalAnswerTool()
70
  ]
71
 
72
  print("BasicAgent making search tool.")
73
- self.search_agent = smolagents.CodeAgent(
74
- name="search_agent",
75
  description="Search the web",
76
  model=self.model,
77
- tools=self.tools,
78
  max_steps=6,
79
  verbosity_level=2,
80
  planning_interval=None,
81
  additional_authorized_imports=["duckduckgo_search"],
82
  )
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  print("BasicAgent making manager.")
85
  self.manager_agent = smolagents.CodeAgent(
86
  name="manager_agent",
87
  description="Manger of other agents",
88
  tools=[smolagents.FinalAnswerTool()],
89
  model=self.model,
90
- max_steps=6,
91
  verbosity_level=2,
92
  planning_interval=None,
93
- additional_authorized_imports=["duckduckgo_search"],
94
- managed_agents=[self.search_agent])
95
 
96
  def __call__(self, question: str) -> str:
97
  # Avoid rate limiting issues
 
23
  # Logs appear to be swallowed.
24
  LOG.warning("logging BasicAgent initialized.")
25
 
 
 
 
26
  # Assume we will use the default model creation
27
  self.model = None
28
 
 
60
  )
61
  print(f"NEW2: BasicAgent {self.model_id=} {self.model=}")
62
 
63
+ web_search_tools = [
64
  smolagents.DuckDuckGoSearchTool(),
65
  smolagents.VisitWebpageTool(),
66
  smolagents.FinalAnswerTool()
67
  ]
68
 
69
  print("BasicAgent making search tool.")
70
+ self.web_search_agent = smolagents.CodeAgent(
71
+ name="web_search_agent",
72
  description="Search the web",
73
  model=self.model,
74
+ tools=web_search_tools,
75
  max_steps=6,
76
  verbosity_level=2,
77
  planning_interval=None,
78
  additional_authorized_imports=["duckduckgo_search"],
79
  )
80
 
81
+ wiki_search_tools = [
82
+ smolagents.WikipediaSearchTool(),
83
+ smolagents.VisitWebpageTool(),
84
+ smolagents.FinalAnswerTool()
85
+ ]
86
+
87
+ self.wiki_search_agent = smolagents.CodeAgent(
88
+ name="wikipedia_search_agent",
89
+ description="Search wikipedia",
90
+ model=self.model,
91
+ tools=wiki_search_tools,
92
+ max_steps=6,
93
+ verbosity_level=2,
94
+ planning_interval=None,
95
+ additional_authorized_imports=["wikipedia-api"],
96
+ )
97
+
98
+ print("BasicAgent making wikipedia search tool.")
99
+
100
+
101
  print("BasicAgent making manager.")
102
  self.manager_agent = smolagents.CodeAgent(
103
  name="manager_agent",
104
  description="Manger of other agents",
105
  tools=[smolagents.FinalAnswerTool()],
106
  model=self.model,
107
+ max_steps=10,
108
  verbosity_level=2,
109
  planning_interval=None,
110
+ additional_authorized_imports=["duckduckgo_search", "wikipedia-api"],
111
+ managed_agents=[self.web_search_agent, self.wiki_search_agent])
112
 
113
  def __call__(self, question: str) -> str:
114
  # Avoid rate limiting issues
basic_agent_test.py CHANGED
@@ -8,8 +8,12 @@ LOG = logging.getLogger(__name__)
8
 
9
  ba = basic_agent.BasicAgent()
10
 
 
11
  answer = ba(
12
  "Who is the 47th president of the united states? If necessary, use a web search to get the most up to date information."
13
  )
 
 
 
14
 
15
  LOG.warning(f"{answer=}")
 
8
 
9
  ba = basic_agent.BasicAgent()
10
 
11
+ """
12
  answer = ba(
13
  "Who is the 47th president of the united states? If necessary, use a web search to get the most up to date information."
14
  )
15
+ """
16
+ answer = ba("What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?"
17
+ )
18
 
19
  LOG.warning(f"{answer=}")
requirements.txt CHANGED
@@ -3,6 +3,7 @@ requests
3
  huggingface_hub[hf_xet]
4
  smolagents
5
  smolagents[openai]
 
6
 
7
  # Only needed for running locally
8
  #compressed-tensors
 
3
  huggingface_hub[hf_xet]
4
  smolagents
5
  smolagents[openai]
6
+ wikipedia-api
7
 
8
  # Only needed for running locally
9
  #compressed-tensors