|
32 | 32 | "```\n",
|
33 | 33 | "Let's set up this system. \n",
|
34 | 34 | "\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 |
40 | 35 | "Run the line below to install the required dependencies:"
|
41 | 36 | ]
|
42 | 37 | },
|
|
46 | 41 | "metadata": {},
|
47 | 42 | "outputs": [],
|
48 | 43 | "source": [
|
49 |
| - "!pip install markdownify duckduckgo-search smolagents --upgrade -q" |
| 44 | + "!pip install markdownify duckduckgo-search \"transformers[agents]\" --upgrade -q" |
50 | 45 | ]
|
51 | 46 | },
|
52 | 47 | {
|
|
109 | 104 | "import requests\n",
|
110 | 105 | "from markdownify import markdownify as md\n",
|
111 | 106 | "from requests.exceptions import RequestException\n",
|
112 |
| - "from smolagents import tool\n", |
| 107 | + "from transformers.agents import tool\n", |
113 | 108 | "\n",
|
114 | 109 | "\n",
|
115 | 110 | "@tool\n",
|
|
192 | 187 | "Now that we have all the tools `search` and `visit_webpage`, we can use them to create the web agent.\n",
|
193 | 188 | "\n",
|
194 | 189 | "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", |
196 | 191 | "- 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."
|
197 | 192 | ]
|
198 | 193 | },
|
|
202 | 197 | "metadata": {},
|
203 | 198 | "outputs": [],
|
204 | 199 | "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", |
209 | 204 | " ManagedAgent,\n",
|
210 | 205 | ")\n",
|
211 |
| - "from smolagents.search import DuckDuckGoSearchTool\n", |
| 206 | + "from transformers.agents.search import DuckDuckGoSearchTool\n", |
212 | 207 | "\n",
|
213 |
| - "model = HfApiModel(model)\n", |
| 208 | + "llm_engine = HfApiEngine(model)\n", |
214 | 209 | "\n",
|
215 |
| - "web_agent = ToolCallingAgent(\n", |
| 210 | + "web_agent = ReactJsonAgent(\n", |
216 | 211 | " tools=[DuckDuckGoSearchTool(), visit_webpage],\n",
|
217 |
| - " model=model,\n", |
| 212 | + " llm_engine=llm_engine,\n", |
218 | 213 | " max_iterations=10,\n",
|
219 | 214 | ")"
|
220 | 215 | ]
|
|
245 | 240 | "source": [
|
246 | 241 | "Finally we create a manager agent, and upon initialization we pass our managed agent to it in its `managed_agents` argument.\n",
|
247 | 242 | "\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", |
249 | 244 | "\n",
|
250 | 245 | "Also, we want to ask a question that involves the current year: so let us add `additional_authorized_imports=[\"time\", \"datetime\"]`"
|
251 | 246 | ]
|
|
256 | 251 | "metadata": {},
|
257 | 252 | "outputs": [],
|
258 | 253 | "source": [
|
259 |
| - "manager_agent = CodeAgent(\n", |
| 254 | + "manager_agent = ReactCodeAgent(\n", |
260 | 255 | " tools=[],\n",
|
261 |
| - " model=model,\n", |
| 256 | + " llm_engine=llm_engine,\n", |
262 | 257 | " managed_agents=[managed_web_agent],\n",
|
263 | 258 | " additional_authorized_imports=[\"time\", \"datetime\"],\n",
|
264 | 259 | ")"
|
|
0 commit comments