From 5506897122dfd34d66e424bd21fe21b989e29ab1 Mon Sep 17 00:00:00 2001 From: Y M <90426808+yuka-with-data@users.noreply.github.com> Date: Sun, 15 Jun 2025 15:57:00 -0700 Subject: [PATCH 1/2] Replace DuckDuckGoSearchTool with WebSearchTool --- units/en/unit2/smolagents/code_agents.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/units/en/unit2/smolagents/code_agents.mdx b/units/en/unit2/smolagents/code_agents.mdx index 0e78c5e2..dcfbbb30 100644 --- a/units/en/unit2/smolagents/code_agents.mdx +++ b/units/en/unit2/smolagents/code_agents.mdx @@ -82,7 +82,7 @@ login() ### Selecting a Playlist for the Party Using `smolagents` -Music is an essential part of a successful party! Alfred needs some help selecting the playlist. Luckily, `smolagents` has got us covered! We can build an agent capable of searching the web using DuckDuckGo. To give the agent access to this tool, we include it in the tool list when creating the agent. +Music is an essential part of a successful party! Alfred needs some help selecting the playlist. Luckily, `smolagents` has got us covered! We can build an agent capable of searching the web using our native `WebSearchTool` tool. To give the agent access to this tool, we include it in the tool list when creating the agent. Alfred Playlist @@ -91,9 +91,9 @@ For the model, we'll rely on `InferenceClientModel`, which provides access to Hu Running an agent is quite straightforward: ```python -from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel +from smolagents import CodeAgent, WebSearchTool, InferenceClientModel -agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=InferenceClientModel()) +agent = CodeAgent(tools=[WebSearchTool()], model=InferenceClientModel()) agent.run("Search for the best music recommendations for a party at the Wayne's mansion.") ``` @@ -226,7 +226,7 @@ For example, the _AlfredAgent_ is available [here](https://huggingface.co/spaces You may be wondering—how did Alfred build such an agent using `smolagents`? By integrating several tools, he can generate an agent as follows. Don't worry about the tools for now, as we'll have a dedicated section later in this unit to explore that in detail: ```python -from smolagents import CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool, InferenceClientModel, Tool, tool, VisitWebpageTool +from smolagents import CodeAgent, WebSearchTool, FinalAnswerTool, InferenceClientModel, Tool, tool, VisitWebpageTool @tool def suggest_menu(occasion: str) -> str: @@ -292,7 +292,7 @@ class SuperheroPartyThemeTool(Tool): # Alfred, the butler, preparing the menu for the party agent = CodeAgent( tools=[ - DuckDuckGoSearchTool(), + WebSearchTool(), VisitWebpageTool(), suggest_menu, catering_service_tool, From df2e08ce40db3860fbe788e1f36801f0b1ac843b Mon Sep 17 00:00:00 2001 From: Y M <90426808+yuka-with-data@users.noreply.github.com> Date: Thu, 26 Jun 2025 13:02:53 -0700 Subject: [PATCH 2/2] Update remaining course files to use WebSearchTool --- units/en/unit2/smolagents/multi_agent_systems.mdx | 4 ++-- units/en/unit2/smolagents/quiz2.mdx | 2 +- units/en/unit2/smolagents/retrieval_agents.mdx | 10 +++++----- units/en/unit2/smolagents/tool_calling_agents.mdx | 6 +++--- units/en/unit2/smolagents/tools.mdx | 4 ++-- units/en/unit2/smolagents/vision_agents.mdx | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/units/en/unit2/smolagents/multi_agent_systems.mdx b/units/en/unit2/smolagents/multi_agent_systems.mdx index ba1d767f..4976db2b 100644 --- a/units/en/unit2/smolagents/multi_agent_systems.mdx +++ b/units/en/unit2/smolagents/multi_agent_systems.mdx @@ -16,7 +16,7 @@ A typical setup might include: - A **Code Interpreter Agent** for code execution - A **Web Search Agent** for information retrieval -The diagram below illustrates a simple multi-agent architecture where a **Manager Agent** coordinates a **Code Interpreter Tool** and a **Web Search Agent**, which in turn utilizes tools like the `DuckDuckGoSearchTool` and `VisitWebpageTool` to gather relevant information. +The diagram below illustrates a simple multi-agent architecture where a **Manager Agent** coordinates a **Code Interpreter Tool** and a **Web Search Agent**, which in turn utilizes tools like the `WebSearchTool` and `VisitWebpageTool` to gather relevant information. @@ -129,7 +129,7 @@ For the model provider, we use Together AI, one of the new [inference providers The GoogleSearchTool uses the [Serper API](https://serper.dev) to search the web, so this requires either having setup env variable `SERPAPI_API_KEY` and passing `provider="serpapi"` or having `SERPER_API_KEY` and passing `provider=serper`. -If you don't have any Serp API provider setup, you can use `DuckDuckGoSearchTool` but beware that it has a rate limit. +If you don't have any Serp API provider setup, you can use `WebSearchTool` but beware that it has a rate limit. ```python import os diff --git a/units/en/unit2/smolagents/quiz2.mdx b/units/en/unit2/smolagents/quiz2.mdx index 682fbbf2..fc8e7d2a 100644 --- a/units/en/unit2/smolagents/quiz2.mdx +++ b/units/en/unit2/smolagents/quiz2.mdx @@ -123,7 +123,7 @@ Which statement best captures the purpose and contents of the default toolbox in None: This function is passed to the agent as `step_callback`, as it's triggered at the end of each step during the agent's execution. This allows the agent to dynamically capture and store screenshots throughout its process. -Now, we can generate our vision agent for browsing the web, providing it with the tools we created, along with the `DuckDuckGoSearchTool` to explore the web. This tool will help the agent retrieve necessary information for verifying guests' identities based on visual cues. +Now, we can generate our vision agent for browsing the web, providing it with the tools we created, along with the `WebSearchTool` to explore the web. This tool will help the agent retrieve necessary information for verifying guests' identities based on visual cues. ```python -from smolagents import CodeAgent, OpenAIServerModel, DuckDuckGoSearchTool +from smolagents import CodeAgent, OpenAIServerModel, WebSearchTool model = OpenAIServerModel(model_id="gpt-4o") agent = CodeAgent( - tools=[DuckDuckGoSearchTool(), go_back, close_popups, search_item_ctrl_f], + tools=[WebSearchTool(), go_back, close_popups, search_item_ctrl_f], model=model, additional_authorized_imports=["helium"], step_callbacks=[save_screenshot],