Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.12"

# Setup venv
# TODO: revisit when https://github.com/astral-sh/uv/issues/1526 is addressed.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ limitations under the License.

🌐 **Support for any LLM**: it supports models hosted on the Hub loaded in their `transformers` version or through our inference API, but also supports models from OpenAI, Anthropic and many others via our [LiteLLM](https://www.litellm.ai/) integration.

Full documentation can be found [here](https://huggingface.co/docs/smolagents/index).

> [!NOTE]
> Check the our [launch blog post](https://huggingface.co/blog/smolagents) to learn more about `smolagents`!

Expand Down
6 changes: 3 additions & 3 deletions docs/source/en/examples/multiagents.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ Run the line below to install the required dependencies:

Let's login in order to call the HF Inference API:

```py
from huggingface_hub import notebook_login
```
from huggingface_hub import login

notebook_login()
login()
```

⚡️ Our agent will be powered by [Qwen/Qwen2.5-Coder-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct) using `HfApiModel` class that uses HF's Inference API: the Inference API allows to quickly and easily run any OS model.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/en/examples/rag.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ _Note:_ The Inference API hosts models based on various criteria, and deployed m
from smolagents import HfApiModel, CodeAgent

agent = CodeAgent(
tools=[retriever_tool], model=HfApiModel("meta-llama/Llama-3.3-70B-Instruct"), max_steps=4, verbose=True
tools=[retriever_tool], model=HfApiModel("meta-llama/Llama-3.3-70B-Instruct"), max_steps=4, verbosity_level=2
)
```

Expand Down
11 changes: 5 additions & 6 deletions docs/source/en/guided_tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ The Python interpreter also doesn't allow imports by default outside of a safe l
You can authorize additional imports by passing the authorized modules as a list of strings in argument `additional_authorized_imports` upon initialization of your [`CodeAgent`]:

```py
from smolagents import CodeAgent

model = HfApiModel()
agent = CodeAgent(tools=[], model=model, additional_authorized_imports=['requests', 'bs4'])
agent.run("Could you get me the title of the page at url 'https://huggingface.co/blog'?")
```
Expand Down Expand Up @@ -161,15 +160,15 @@ When the agent is initialized, the tool attributes are used to generate a tool d
Transformers comes with a default toolbox for empowering agents, that you can add to your agent upon initialization with argument `add_base_tools = True`:

- **DuckDuckGo web search***: performs a web search using DuckDuckGo browser.
- **Python code interpreter**: runs your the 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
- **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
- **Transcriber**: a speech-to-text pipeline built on Whisper-Turbo that transcribes an audio to text.

You can manually use a tool by calling the [`load_tool`] function and a task to perform.
You can manually use a tool by calling it with its arguments.

```python
from smolagents import load_tool
from smolagents import DuckDuckGoSearchTool

search_tool = load_tool("web_search")
search_tool = DuckDuckGoSearchTool()
print(search_tool("Who's the current president of Russia?"))
```

Expand Down
2 changes: 1 addition & 1 deletion docs/source/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rendered properly in your Markdown viewer.

# `smolagents`

This library is the simplest framework out there to build powerful agents! By the way, wtf are "agents"? We provide our definition [in this page](conceptual_guides/intro_agents), whe're you'll also find tips for when to use them or not (spoilers: you'll often be better off without agents).
This library is the simplest framework out there to build powerful agents! By the way, wtf are "agents"? We provide our definition [in this page](conceptual_guides/intro_agents), where you'll also find tips for when to use them or not (spoilers: you'll often be better off without agents).

This library offers:

Expand Down
4 changes: 0 additions & 4 deletions docs/source/en/reference/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ contains the API docs for the underlying classes.

[[autodoc]] Tool

### Toolbox

[[autodoc]] Toolbox

### launch_gradio_demo

[[autodoc]] launch_gradio_demo
Expand Down
2 changes: 1 addition & 1 deletion docs/source/en/tutorials/secure_code_execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Code is just a better way to express actions on a computer. It has better:
- **Composability:** could you nest JSON actions within each other, or define a set of JSON actions to re-use later, the same way you could just define a python function?
- **Object management:** how do you store the output of an action like `generate_image` in JSON?
- **Generality:** code is built to express simply anything you can do have a computer do.
- **Representation in LLM training corpuses:** why not leverage this benediction of the sky that plenty of quality actions have already been included in LLM training corpuses?
- **Representation in LLM training corpus:** why not leverage this benediction of the sky that plenty of quality actions have already been included in LLM training corpus?

This is illustrated on the figure below, taken from [Executable Code Actions Elicit Better LLM Agents](https://huggingface.co/papers/2402.01030).

Expand Down
9 changes: 2 additions & 7 deletions docs/source/en/tutorials/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ agent.run("How many more blocks (also denoted as layers) are in BERT base encode

### Manage your agent's toolbox

You can manage an agent's toolbox by adding or replacing a tool.
You can manage an agent's toolbox by adding or replacing a tool in attribute `agent.tools`, since it is a standard dictionary.

Let's add the `model_download_tool` to an existing agent initialized with only the default toolbox.

Expand All @@ -187,7 +187,7 @@ from smolagents import HfApiModel
model = HfApiModel("Qwen/Qwen2.5-Coder-32B-Instruct")

agent = CodeAgent(tools=[], model=model, add_base_tools=True)
agent.toolbox.add_tool(model_download_tool)
agent.tools[model_download_tool.name] = model_download_tool
```
Now we can leverage the new tool:

Expand All @@ -202,11 +202,6 @@ agent.run(
> Beware of not adding too many tools to an agent: this can overwhelm weaker LLM engines.


Use the `agent.toolbox.update_tool()` method to replace an existing tool in the agent's toolbox.
This is useful if your new tool is a one-to-one replacement of the existing tool because the agent already knows how to perform that specific task.
Just make sure the new tool follows the same API as the replaced tool or adapt the system prompt template to ensure all examples using the replaced tool are updated.


### Use a collection of tools

You can leverage tool collections by using the ToolCollection object, with the slug of the collection you want to use.
Expand Down
Loading
Loading