Skip to content

Commit 7a81cb9

Browse files
Fix multiagent web assistant notebook
1 parent 0dc2ba1 commit 7a81cb9

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

notebooks/en/multiagent_web_assistant.ipynb

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232
"```\n",
3333
"Let's set up this system. \n",
3434
"\n",
35-
<<<<<<< Updated upstream
36-
=======
37-
"⚡️ Our agent will be powered by [meta-llama/Meta-Llama-3.1-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct) using `HfApiModel` class that uses HF's Inference API: the Inference API allows to quickly and easily run any OS model.\n",
38-
"\n",
39-
>>>>>>> Stashed changes
4035
"Run the line below to install the required dependencies:"
4136
]
4237
},
@@ -46,7 +41,7 @@
4641
"metadata": {},
4742
"outputs": [],
4843
"source": [
49-
"!pip install markdownify duckduckgo-search smolagents --upgrade -q"
44+
"!pip install markdownify duckduckgo-search \"transformers[agents]\" --upgrade -q"
5045
]
5146
},
5247
{
@@ -109,7 +104,7 @@
109104
"import requests\n",
110105
"from markdownify import markdownify as md\n",
111106
"from requests.exceptions import RequestException\n",
112-
"from smolagents import tool\n",
107+
"from transformers.agents import tool\n",
113108
"\n",
114109
"\n",
115110
"@tool\n",
@@ -192,7 +187,7 @@
192187
"Now that we have all the tools `search` and `visit_webpage`, we can use them to create the web agent.\n",
193188
"\n",
194189
"Which configuration to choose for this agent?\n",
195-
"- Web browsing is a single-timeline task that does not require parallel tool calls, so JSON tool calling works well for that. We thus choose a `ToolCallingAgent`.\n",
190+
"- Web browsing is a single-timeline task that does not require parallel tool calls, so JSON tool calling works well for that. We thus choose a `ReactJsonAgent`.\n",
196191
"- Also, since sometimes web search requires exploring many pages before finding the correct answer, we prefer to increase the number of `max_iterations` to 10."
197192
]
198193
},
@@ -202,19 +197,19 @@
202197
"metadata": {},
203198
"outputs": [],
204199
"source": [
205-
"from smolagents import (\n",
206-
" CodeAgent,\n",
207-
" ToolCallingAgent,\n",
208-
" HfApiModel,\n",
200+
"from transformers.agents import (\n",
201+
" ReactCodeAgent,\n",
202+
" ReactJsonAgent,\n",
203+
" HfApiEngine,\n",
209204
" ManagedAgent,\n",
210205
")\n",
211-
"from smolagents.search import DuckDuckGoSearchTool\n",
206+
"from transformers.agents.search import DuckDuckGoSearchTool\n",
212207
"\n",
213-
"model = HfApiModel(model)\n",
208+
"llm_engine = HfApiEngine(model)\n",
214209
"\n",
215-
"web_agent = ToolCallingAgent(\n",
210+
"web_agent = ReactJsonAgent(\n",
216211
" tools=[DuckDuckGoSearchTool(), visit_webpage],\n",
217-
" model=model,\n",
212+
" llm_engine=llm_engine,\n",
218213
" max_iterations=10,\n",
219214
")"
220215
]
@@ -245,7 +240,7 @@
245240
"source": [
246241
"Finally we create a manager agent, and upon initialization we pass our managed agent to it in its `managed_agents` argument.\n",
247242
"\n",
248-
"Since this agent is the one tasked with the planning and thinking, advanced reasoning will be beneficial, so a `CodeAgent` will be the best choice.\n",
243+
"Since this agent is the one tasked with the planning and thinking, advanced reasoning will be beneficial, so a `ReactCodeAgent` will be the best choice.\n",
249244
"\n",
250245
"Also, we want to ask a question that involves the current year: so let us add `additional_authorized_imports=[\"time\", \"datetime\"]`"
251246
]
@@ -256,9 +251,9 @@
256251
"metadata": {},
257252
"outputs": [],
258253
"source": [
259-
"manager_agent = CodeAgent(\n",
254+
"manager_agent = ReactCodeAgent(\n",
260255
" tools=[],\n",
261-
" model=model,\n",
256+
" llm_engine=llm_engine,\n",
262257
" managed_agents=[managed_web_agent],\n",
263258
" additional_authorized_imports=[\"time\", \"datetime\"],\n",
264259
")"

0 commit comments

Comments
 (0)