From 7a81cb92efbdb36a73b1a79c7226af30002245e8 Mon Sep 17 00:00:00 2001 From: Aymeric Date: Mon, 6 Jan 2025 16:40:35 +0100 Subject: [PATCH] Fix multiagent web assistant notebook --- notebooks/en/multiagent_web_assistant.ipynb | 33 +++++++++------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/notebooks/en/multiagent_web_assistant.ipynb b/notebooks/en/multiagent_web_assistant.ipynb index ec0b283b..84d62e28 100644 --- a/notebooks/en/multiagent_web_assistant.ipynb +++ b/notebooks/en/multiagent_web_assistant.ipynb @@ -32,11 +32,6 @@ "```\n", "Let's set up this system. \n", "\n", -<<<<<<< Updated upstream -======= - "⚡️ 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", - "\n", ->>>>>>> Stashed changes "Run the line below to install the required dependencies:" ] }, @@ -46,7 +41,7 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install markdownify duckduckgo-search smolagents --upgrade -q" + "!pip install markdownify duckduckgo-search \"transformers[agents]\" --upgrade -q" ] }, { @@ -109,7 +104,7 @@ "import requests\n", "from markdownify import markdownify as md\n", "from requests.exceptions import RequestException\n", - "from smolagents import tool\n", + "from transformers.agents import tool\n", "\n", "\n", "@tool\n", @@ -192,7 +187,7 @@ "Now that we have all the tools `search` and `visit_webpage`, we can use them to create the web agent.\n", "\n", "Which configuration to choose for this agent?\n", - "- 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", + "- 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", "- 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." ] }, @@ -202,19 +197,19 @@ "metadata": {}, "outputs": [], "source": [ - "from smolagents import (\n", - " CodeAgent,\n", - " ToolCallingAgent,\n", - " HfApiModel,\n", + "from transformers.agents import (\n", + " ReactCodeAgent,\n", + " ReactJsonAgent,\n", + " HfApiEngine,\n", " ManagedAgent,\n", ")\n", - "from smolagents.search import DuckDuckGoSearchTool\n", + "from transformers.agents.search import DuckDuckGoSearchTool\n", "\n", - "model = HfApiModel(model)\n", + "llm_engine = HfApiEngine(model)\n", "\n", - "web_agent = ToolCallingAgent(\n", + "web_agent = ReactJsonAgent(\n", " tools=[DuckDuckGoSearchTool(), visit_webpage],\n", - " model=model,\n", + " llm_engine=llm_engine,\n", " max_iterations=10,\n", ")" ] @@ -245,7 +240,7 @@ "source": [ "Finally we create a manager agent, and upon initialization we pass our managed agent to it in its `managed_agents` argument.\n", "\n", - "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", + "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", "\n", "Also, we want to ask a question that involves the current year: so let us add `additional_authorized_imports=[\"time\", \"datetime\"]`" ] @@ -256,9 +251,9 @@ "metadata": {}, "outputs": [], "source": [ - "manager_agent = CodeAgent(\n", + "manager_agent = ReactCodeAgent(\n", " tools=[],\n", - " model=model,\n", + " llm_engine=llm_engine,\n", " managed_agents=[managed_web_agent],\n", " additional_authorized_imports=[\"time\", \"datetime\"],\n", ")"