Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions units/en/unit2/smolagents/code_agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/smolagents/alfred-playlist.jpg" alt="Alfred Playlist"/>

Expand All @@ -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.")
```
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions units/en/unit2/smolagents/multi_agent_systems.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<img src="https://mermaid.ink/img/pako:eNp1kc1qhTAQRl9FUiQb8wIpdNO76eKubrmFks1oRg3VSYgjpYjv3lFL_2hnMWQOJwn5sqgmelRWleUSKLAtFs09jqhtoWuYUFfFAa6QA9QDTnpzamheuhxn8pt40-6l13UtS0ddhtQXj6dbR4XUGQg6zEYasTF393KjeSDGnDJKNxzj8I_7hLW5IOSmP9CH9hv_NL-d94d4DVNg84p1EnK4qlIj5hGClySWbadT-6OdsrL02MI8sFOOVkciw8zx8kaNspxnrJQE0fXKtjBMMs3JA-MpgOQwftIE9Bzj14w-cMznI_39E9Z3p0uFoA?type=png" style='background: white;'>

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion units/en/unit2/smolagents/quiz2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Which statement best captures the purpose and contents of the default toolbox in
<Question
choices={[
{
text: "It provides a set of commonly-used tools such as DuckDuckGo search, PythonInterpreterTool, and a final answer tool for quick prototyping",
text: "It provides a set of commonly-used tools such as `WebSearchTool`, PythonInterpreterTool, and a final answer tool for quick prototyping",
explain: "Correct. The default toolbox contains these ready-made tools for easy integration when building agents.",
correct: true
},
Expand Down
10 changes: 5 additions & 5 deletions units/en/unit2/smolagents/retrieval_agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Traditional RAG systems face key limitations, such as **relying on a single retr

Agentic RAG addresses these issues by allowing the agent to autonomously formulate search queries, critique retrieved results, and conduct multiple retrieval steps for a more tailored and comprehensive output.

## Basic Retrieval with DuckDuckGo
## Basic Retrieval with Web Search Tool

Let's build a simple agent that can search the web using DuckDuckGo. This agent will retrieve information and synthesize responses to answer queries. With Agentic RAG, Alfred's agent can:
Let's build a simple agent that can search the web using `WebSearchTool`. This agent will retrieve information and synthesize responses to answer queries. With Agentic RAG, Alfred's agent can:

* Search for latest superhero party trends
* Refine results to include luxury elements
Expand All @@ -32,10 +32,10 @@ Let's build a simple agent that can search the web using DuckDuckGo. This agent
Here's how Alfred's agent can achieve this:

```python
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
from smolagents import CodeAgent, WebSearchTool, InferenceClientModel

# Initialize the search tool
search_tool = DuckDuckGoSearchTool()
search_tool = WebSearchTool()

# Initialize the model
model = InferenceClientModel()
Expand All @@ -55,7 +55,7 @@ print(response)
The agent follows this process:

1. **Analyzes the Request:** Alfred’s agent identifies the key elements of the query—luxury superhero-themed party planning, with focus on decor, entertainment, and catering.
2. **Performs Retrieval:** The agent leverages DuckDuckGo to search for the most relevant and up-to-date information, ensuring it aligns with Alfred’s refined preferences for a luxurious event.
2. **Performs Retrieval:** The agent leverages `WebSearchTool` to search for the most relevant and up-to-date information, ensuring it aligns with Alfred’s refined preferences for a luxurious event.
3. **Synthesizes Information:** After gathering the results, the agent processes them into a cohesive, actionable plan for Alfred, covering all aspects of the party.
4. **Stores for Future Reference:** The agent stores the retrieved information for easy access when planning future events, optimizing efficiency in subsequent tasks.

Expand Down
6 changes: 3 additions & 3 deletions units/en/unit2/smolagents/tool_calling_agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ The key difference is in **how they structure their actions**: instead of execut

## Example: Running a Tool Calling Agent

Let's revisit the previous example where Alfred started party preparations, but this time we'll use a `ToolCallingAgent` to highlight the difference. We'll build an agent that can search the web using DuckDuckGo, just like in our Code Agent example. The only difference is the agent type - the framework handles everything else:
Let's revisit the previous example where Alfred started party preparations, but this time we'll use a `ToolCallingAgent` to highlight the difference. We'll build an agent that can search the web using `WebSearchTool`, just like in our Code Agent example. The only difference is the agent type - the framework handles everything else:

```python
from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, InferenceClientModel
from smolagents import ToolCallingAgent, WebSearchTool, InferenceClientModel

agent = ToolCallingAgent(tools=[DuckDuckGoSearchTool()], model=InferenceClientModel())
agent = ToolCallingAgent(tools=[WebSearchTool()], model=InferenceClientModel())

agent.run("Search for the best music recommendations for a party at the Wayne's mansion.")
```
Expand Down
4 changes: 2 additions & 2 deletions units/en/unit2/smolagents/tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ With this tool, Alfred will be the ultimate super host, impressing his guests wi
- **PythonInterpreterTool**
- **FinalAnswerTool**
- **UserInputTool**
- **DuckDuckGoSearchTool**
- **WebSearchTool**
- **GoogleSearchTool**
- **VisitWebpageTool**

Alfred could use various tools to ensure a flawless party at Wayne Manor:

- First, he could use the `DuckDuckGoSearchTool` to find creative superhero-themed party ideas.
- First, he could use the `WebSearchTool` to find creative superhero-themed party ideas.

- For catering, he'd rely on the `GoogleSearchTool` to find the highest-rated services in Gotham.

Expand Down
6 changes: 3 additions & 3 deletions units/en/unit2/smolagents/vision_agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ def save_screenshot(step_log: ActionStep, agent: CodeAgent) -> 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],
Expand Down