Skip to content

Commit 0dc2ba1

Browse files
Merge branch 'main' of github.com:huggingface/cookbook
2 parents 3fc27a3 + 2566e5b commit 0dc2ba1

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

notebooks/en/multiagent_web_assistant.ipynb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
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
3540
"Run the line below to install the required dependencies:"
3641
]
3742
},
@@ -41,7 +46,7 @@
4146
"metadata": {},
4247
"outputs": [],
4348
"source": [
44-
"!pip install markdownify duckduckgo-search \"transformers[agents]\" --upgrade -q"
49+
"!pip install markdownify duckduckgo-search smolagents --upgrade -q"
4550
]
4651
},
4752
{
@@ -104,7 +109,7 @@
104109
"import requests\n",
105110
"from markdownify import markdownify as md\n",
106111
"from requests.exceptions import RequestException\n",
107-
"from transformers.agents import tool\n",
112+
"from smolagents import tool\n",
108113
"\n",
109114
"\n",
110115
"@tool\n",
@@ -187,7 +192,7 @@
187192
"Now that we have all the tools `search` and `visit_webpage`, we can use them to create the web agent.\n",
188193
"\n",
189194
"Which configuration to choose for this agent?\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",
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",
191196
"- 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."
192197
]
193198
},
@@ -197,19 +202,19 @@
197202
"metadata": {},
198203
"outputs": [],
199204
"source": [
200-
"from transformers.agents import (\n",
201-
" ReactCodeAgent,\n",
202-
" ReactJsonAgent,\n",
203-
" HfApiEngine,\n",
205+
"from smolagents import (\n",
206+
" CodeAgent,\n",
207+
" ToolCallingAgent,\n",
208+
" HfApiModel,\n",
204209
" ManagedAgent,\n",
205210
")\n",
206-
"from transformers.agents.search import DuckDuckGoSearchTool\n",
211+
"from smolagents.search import DuckDuckGoSearchTool\n",
207212
"\n",
208-
"llm_engine = HfApiEngine(model)\n",
213+
"model = HfApiModel(model)\n",
209214
"\n",
210-
"web_agent = ReactJsonAgent(\n",
215+
"web_agent = ToolCallingAgent(\n",
211216
" tools=[DuckDuckGoSearchTool(), visit_webpage],\n",
212-
" llm_engine=llm_engine,\n",
217+
" model=model,\n",
213218
" max_iterations=10,\n",
214219
")"
215220
]
@@ -240,7 +245,7 @@
240245
"source": [
241246
"Finally we create a manager agent, and upon initialization we pass our managed agent to it in its `managed_agents` argument.\n",
242247
"\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",
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",
244249
"\n",
245250
"Also, we want to ask a question that involves the current year: so let us add `additional_authorized_imports=[\"time\", \"datetime\"]`"
246251
]
@@ -251,9 +256,9 @@
251256
"metadata": {},
252257
"outputs": [],
253258
"source": [
254-
"manager_agent = ReactCodeAgent(\n",
259+
"manager_agent = CodeAgent(\n",
255260
" tools=[],\n",
256-
" llm_engine=llm_engine,\n",
261+
" model=model,\n",
257262
" managed_agents=[managed_web_agent],\n",
258263
" additional_authorized_imports=[\"time\", \"datetime\"],\n",
259264
")"

0 commit comments

Comments
 (0)