Skip to content

Commit baef260

Browse files
Merge pull request #16 from huggingface/v1.15-release
V1.15 release
2 parents 3883aee + 31389a4 commit baef260

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+738
-290
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ Full documentation can be found [here](https://huggingface.co/docs/smolagents/in
5151
5252
## Quick demo
5353

54-
First install the package.
54+
First install the package with a default set of tools:
5555
```bash
56-
pip install smolagents
56+
pip install smolagents[toolkit]
5757
```
5858
Then define your agent, give it the tools it needs and run it!
5959
```py
60-
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
60+
from smolagents import CodeAgent, WebSearchTool, InferenceClientModel
6161

6262
model = InferenceClientModel()
63-
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
63+
agent = CodeAgent(tools=[WebSearchTool()], model=model)
6464

6565
agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
6666
```

docs/source/en/_toctree.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
sections:
33
- local: index
44
title: 🤗 Agents
5+
- local: installation
6+
title: Installation
57
- local: guided_tour
68
title: Guided tour
79
- title: Tutorials
@@ -32,6 +34,8 @@
3234
title: Orchestrate a multi-agent system
3335
- local: examples/web_browser
3436
title: Build a web browser agent using vision models
37+
- local: examples/using_different_models
38+
title: Using different models
3539
- title: Reference
3640
sections:
3741
- local: reference/agents

docs/source/en/examples/multiagents.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Let's set up this system.
2525
Run the line below to install the required dependencies:
2626

2727
```py
28-
! pip install markdownify duckduckgo-search smolagents --upgrade -q
28+
!pip install smolagents[toolkit] --upgrade -q
2929
```
3030

3131
Let's login to HF in order to call Inference Providers:
@@ -46,9 +46,9 @@ model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
4646

4747
## 🔍 Create a web search tool
4848

49-
For web browsing, we can already use our pre-existing [`DuckDuckGoSearchTool`](https://github.com/huggingface/smolagents/blob/main/src/smolagents/default_tools.py#L151-L176) tool to provide a Google search equivalent.
49+
For web browsing, we can already use our native [`WebSearchTool`] tool to provide a Google search equivalent.
5050

51-
But then we will also need to be able to peak into the page found by the `DuckDuckGoSearchTool`.
51+
But then we will also need to be able to peak into the page found by the `WebSearchTool`.
5252
To do so, we could import the library's built-in `VisitWebpageTool`, but we will build it again to see how it's done.
5353

5454
So let's create our `VisitWebpageTool` tool from scratch using `markdownify`.
@@ -109,14 +109,14 @@ from smolagents import (
109109
CodeAgent,
110110
ToolCallingAgent,
111111
InferenceClientModel,
112-
DuckDuckGoSearchTool,
112+
WebSearchTool,
113113
LiteLLMModel,
114114
)
115115

116116
model = InferenceClientModel(model_id=model_id)
117117

118118
web_agent = ToolCallingAgent(
119-
tools=[DuckDuckGoSearchTool(), visit_webpage],
119+
tools=[WebSearchTool(), visit_webpage],
120120
model=model,
121121
max_steps=10,
122122
name="web_search_agent",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Using different models
2+
3+
[[open-in-colab]]
4+
5+
`smolagents` provides a flexible framework that allows you to use various language models from different providers.
6+
This guide will show you how to use different model types with your agents.
7+
8+
## Available model types
9+
10+
`smolagents` supports several model types out of the box:
11+
1. [`InferenceClientModel`]: Uses Hugging Face's Inference API to access models
12+
2. [`TransformersModel`]: Runs models locally using the Transformers library
13+
3. [`VLLMModel`]: Uses vLLM for fast inference with optimized serving
14+
4. [`MLXModel`]: Optimized for Apple Silicon devices using MLX
15+
5. [`LiteLLMModel`]: Provides access to hundreds of LLMs through LiteLLM
16+
6. [`LiteLLMRouterModel`]: Distributes requests among multiple models
17+
7. [`OpenAIServerModel`]: Connects to OpenAI's API
18+
8. [`AzureOpenAIServerModel`]: Uses Azure's OpenAI service
19+
9. [`AmazonBedrockServerModel`]: Connects to AWS Bedrock's API
20+
21+
## Using Google Gemini Models
22+
23+
As explained in the Google Gemini API documentation (https://ai.google.dev/gemini-api/docs/openai),
24+
Google provides an OpenAI-compatible API for Gemini models, allowing you to use the [`OpenAIServerModel`]
25+
with Gemini models by setting the appropriate base URL.
26+
27+
First, install the required dependencies:
28+
```bash
29+
pip install smolagents[openai]
30+
```
31+
32+
Then, [get a Gemini API key](https://ai.google.dev/gemini-api/docs/api-key) and set it in your code:
33+
```python
34+
GEMINI_API_KEY = <YOUR-GEMINI-API-KEY>
35+
```
36+
37+
Now, you can initialize the Gemini model using the `OpenAIServerModel` class
38+
and setting the `api_base` parameter to the Gemini API base URL:
39+
```python
40+
from smolagents import OpenAIServerModel
41+
42+
model = OpenAIServerModel(
43+
model_id="gemini-2.0-flash",
44+
api_key=GEMINI_API_KEY,
45+
# Google Gemini OpenAI-compatible API base URL
46+
api_base="https://generativelanguage.googleapis.com/v1beta/openai/",
47+
)
48+
```

docs/source/en/guided_tour.mdx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ When the agent is initialized, the tool attributes are used to generate a tool d
281281

282282
### Default toolbox
283283

284-
`smolagents` comes with a default toolbox for empowering agents, that you can add to your agent upon initialization with argument `add_base_tools=True`:
284+
If you install `smolagents` with the "toolkit" extra, it comes with a default toolbox for empowering agents, that you can add to your agent upon initialization with argument `add_base_tools=True`:
285285

286286
- **DuckDuckGo web search***: performs a web search using DuckDuckGo browser.
287287
- **Python code interpreter**: runs your LLM generated Python code in a secure environment. This tool will only be added to [`ToolCallingAgent`] if you initialize it with `add_base_tools=True`, since code-based agent can already natively execute Python code
@@ -290,9 +290,10 @@ When the agent is initialized, the tool attributes are used to generate a tool d
290290
You can manually use a tool by calling it with its arguments.
291291

292292
```python
293-
from smolagents import DuckDuckGoSearchTool
293+
# !pip install smolagents[toolkit]
294+
from smolagents import WebSearchTool
294295

295-
search_tool = DuckDuckGoSearchTool()
296+
search_tool = WebSearchTool()
296297
print(search_tool("Who's the current president of Russia?"))
297298
```
298299

@@ -339,7 +340,7 @@ def model_download_tool(task: str) -> str:
339340
The function needs:
340341
- A clear name. The name should be descriptive enough of what this tool does to help the LLM brain powering the agent. Since this tool returns the model with the most downloads for a task, let's name it `model_download_tool`.
341342
- Type hints on both inputs and output
342-
- A description, that includes an 'Args:' part where each argument is described (without a type indication this time, it will be pulled from the type hint). Same as for the tool name, this description is an instruction manual for the LLM powering you agent, so do not neglect it.
343+
- A description, that includes an 'Args:' part where each argument is described (without a type indication this time, it will be pulled from the type hint). Same as for the tool name, this description is an instruction manual for the LLM powering your agent, so do not neglect it.
343344

344345
All these elements will be automatically baked into the agent's system prompt upon initialization: so strive to make them as clear as possible!
345346

@@ -364,7 +365,7 @@ class ModelDownloadTool(Tool):
364365

365366
The subclass needs the following attributes:
366367
- A clear `name`. The name should be descriptive enough of what this tool does to help the LLM brain powering the agent. Since this tool returns the model with the most downloads for a task, let's name it `model_download_tool`.
367-
- A `description`. Same as for the `name`, this description is an instruction manual for the LLM powering you agent, so do not neglect it.
368+
- A `description`. Same as for the `name`, this description is an instruction manual for the LLM powering your agent, so do not neglect it.
368369
- Input types and descriptions
369370
- Output type
370371
All these attributes will be automatically baked into the agent's system prompt upon initialization: so strive to make them as clear as possible!
@@ -423,15 +424,15 @@ You can easily build hierarchical multi-agent systems with `smolagents`.
423424
To do so, just ensure your agent has `name` and`description` attributes, which will then be embedded in the manager agent's system prompt to let it know how to call this managed agent, as we also do for tools.
424425
Then you can pass this managed agent in the parameter managed_agents upon initialization of the manager agent.
425426

426-
Here's an example of making an agent that managed a specific web search agent using our [`DuckDuckGoSearchTool`]:
427+
Here's an example of making an agent that managed a specific web search agent using our native [`WebSearchTool`]:
427428

428429
```py
429-
from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool
430+
from smolagents import CodeAgent, InferenceClientModel, WebSearchTool
430431

431432
model = InferenceClientModel()
432433

433434
web_agent = CodeAgent(
434-
tools=[DuckDuckGoSearchTool()],
435+
tools=[WebSearchTool()],
435436
model=model,
436437
name="web_search",
437438
description="Runs web searches for you. Give it your query as an argument."

docs/source/en/installation.mdx

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Installation Guide
2+
3+
The `smolagents` library can be installed using pip. Here are the different installation methods and options available.
4+
5+
## Prerequisites
6+
- Python 3.10 or newer
7+
- pip
8+
9+
## Basic Installation
10+
11+
Install `smolagents` core library with:
12+
```bash
13+
pip install smolagents
14+
```
15+
16+
## Installation with Extras
17+
18+
`smolagents` provides several optional dependencies (extras) that can be installed based on your needs.
19+
You can install these extras using the following syntax:
20+
```bash
21+
pip install "smolagents[extra1,extra2]"
22+
```
23+
24+
### Tools
25+
These extras include various tools and integrations:
26+
- **toolkit**: Install a default set of tools for common tasks.
27+
```bash
28+
pip install "smolagents[toolkit]"
29+
```
30+
- **mcp**: Add support for the Model Context Protocol (MCP) to integrate with external tools and services.
31+
```bash
32+
pip install "smolagents[mcp]"
33+
```
34+
35+
### Model Integration
36+
These extras enable integration with various AI models and frameworks:
37+
- **openai**: Add support for OpenAI API models.
38+
```bash
39+
pip install "smolagents[openai]"
40+
```
41+
- **transformers**: Enable Hugging Face Transformers models.
42+
```bash
43+
pip install "smolagents[transformers]"
44+
```
45+
- **vllm**: Add VLLM support for efficient model inference.
46+
```bash
47+
pip install "smolagents[vllm]"
48+
```
49+
- **mlx-lm**: Enable support for MLX-LM models.
50+
```bash
51+
pip install "smolagents[mlx-lm]"
52+
```
53+
- **litellm**: Add LiteLLM support for lightweight model inference.
54+
```bash
55+
pip install "smolagents[litellm]"
56+
```
57+
- **bedrock**: Enable support for AWS Bedrock models.
58+
```bash
59+
pip install "smolagents[bedrock]"
60+
```
61+
62+
### Multimodal Capabilities
63+
Extras for handling different types of media and input:
64+
- **vision**: Add support for image processing and computer vision tasks.
65+
```bash
66+
pip install "smolagents[vision]"
67+
```
68+
- **audio**: Enable audio processing capabilities.
69+
```bash
70+
pip install "smolagents[audio]"
71+
```
72+
73+
### Remote Execution
74+
Extras for executing code remotely:
75+
- **docker**: Add support for executing code in Docker containers.
76+
```bash
77+
pip install "smolagents[docker]"
78+
```
79+
- **e2b**: Enable E2B support for remote execution.
80+
```bash
81+
pip install "smolagents[e2b]"
82+
```
83+
84+
### Telemetry and User Interface
85+
Extras for telemetry, monitoring and user interface components:
86+
- **telemetry**: Add support for monitoring and tracing.
87+
```bash
88+
pip install "smolagents[telemetry]"
89+
```
90+
- **gradio**: Add support for interactive Gradio UI components.
91+
```bash
92+
pip install "smolagents[gradio]"
93+
```
94+
95+
### Complete Installation
96+
To install all available extras, you can use:
97+
```bash
98+
pip install "smolagents[all]"
99+
```
100+
101+
## Verifying Installation
102+
After installation, you can verify that `smolagents` is installed correctly by running:
103+
```python
104+
import smolagents
105+
print(smolagents.__version__)
106+
```
107+
108+
## Next Steps
109+
Once you have successfully installed `smolagents`, you can:
110+
- Follow the [guided tour](./guided_tour) to learn the basics.
111+
- Explore the [how-to guides](./examples/text_to_sql) for practical examples.
112+
- Read the [conceptual guides](./conceptual_guides/intro_agents) for high-level explanations.
113+
- Check out the [tutorials](./tutorials/building_good_agents) for in-depth tutorials on building agents.
114+
- Explore the [API reference](./reference/index) for detailed information on classes and functions.

docs/source/en/reference/tools.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ contains the API docs for the underlying classes.
4242

4343
[[autodoc]] UserInputTool
4444

45+
### WebSearchTool
46+
47+
[[autodoc]] WebSearchTool
48+
4549
### DuckDuckGoSearchTool
4650

4751
[[autodoc]] DuckDuckGoSearchTool

docs/source/en/tutorials/building_good_agents.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,15 @@ This also works with the [`ToolCallingAgent`].
397397
We provide a model for a supplementary planning step, that an agent can run regularly in-between normal action steps. In this step, there is no tool call, the LLM is simply asked to update a list of facts it knows and to reflect on what steps it should take next based on those facts.
398398

399399
```py
400-
from smolagents import load_tool, CodeAgent, InferenceClientModel, DuckDuckGoSearchTool
400+
from smolagents import load_tool, CodeAgent, InferenceClientModel, WebSearchTool
401401
from dotenv import load_dotenv
402402

403403
load_dotenv()
404404

405405
# Import tool from Hub
406406
image_generation_tool = load_tool("m-ric/text-to-image", trust_remote_code=True)
407407

408-
search_tool = DuckDuckGoSearchTool()
408+
search_tool = WebSearchTool()
409409

410410
agent = CodeAgent(
411411
tools=[search_tool, image_generation_tool],

docs/source/en/tutorials/inspect_runs.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Here's how it then looks like on the platform:
3030
First install the required packages. Here we install [Phoenix by Arize AI](https://github.com/Arize-ai/phoenix) because that's a good solution to collect and inspect the logs, but there are other OpenTelemetry-compatible platforms that you could use for this collection & inspection part.
3131

3232
```shell
33-
pip install 'smolagents[telemetry]'
33+
pip install 'smolagents[telemetry,toolkit]'
3434
```
3535

3636
Then run the collector in the background.
@@ -54,15 +54,15 @@ Then you can run your agents!
5454
from smolagents import (
5555
CodeAgent,
5656
ToolCallingAgent,
57-
DuckDuckGoSearchTool,
57+
WebSearchTool,
5858
VisitWebpageTool,
5959
InferenceClientModel,
6060
)
6161

6262
model = InferenceClientModel()
6363

6464
search_agent = ToolCallingAgent(
65-
tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
65+
tools=[WebSearchTool(), VisitWebpageTool()],
6666
model=model,
6767
name="search_agent",
6868
description="This is an agent that can do web search.",
@@ -143,7 +143,7 @@ SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
143143
from smolagents import (
144144
CodeAgent,
145145
ToolCallingAgent,
146-
DuckDuckGoSearchTool,
146+
WebSearchTool,
147147
VisitWebpageTool,
148148
InferenceClientModel,
149149
)
@@ -153,7 +153,7 @@ model = InferenceClientModel(
153153
)
154154

155155
search_agent = ToolCallingAgent(
156-
tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
156+
tools=[WebSearchTool(), VisitWebpageTool()],
157157
model=model,
158158
name="search_agent",
159159
description="This is an agent that can do web search.",

docs/source/en/tutorials/memory.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Then you should pass this function in the `step_callbacks` argument upon initial
8383

8484
```py
8585
CodeAgent(
86-
tools=[DuckDuckGoSearchTool(), go_back, close_popups, search_item_ctrl_f],
86+
tools=[WebSearchTool(), go_back, close_popups, search_item_ctrl_f],
8787
model=model,
8888
additional_authorized_imports=["helium"],
8989
step_callbacks=[update_screenshot],

0 commit comments

Comments
 (0)