Skip to content

Commit efc9d2f

Browse files
Merge pull request #7 from huggingface/main
Update from HF.
2 parents d59a8dc + d4b5e81 commit efc9d2f

26 files changed

+803
-857
lines changed

.github/workflows/quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Set up Python
1414
uses: actions/setup-python@v2
1515
with:
16-
python-version: "3.10"
16+
python-version: "3.12"
1717

1818
# Setup venv
1919
# TODO: revisit when https://github.com/astral-sh/uv/issues/1526 is addressed.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ limitations under the License.
3838

3939
🌐 **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.
4040

41+
Full documentation can be found [here](https://huggingface.co/docs/smolagents/index).
42+
4143
> [!NOTE]
4244
> Check the our [launch blog post](https://huggingface.co/blog/smolagents) to learn more about `smolagents`!
4345

docs/source/en/examples/multiagents.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ Run the line below to install the required dependencies:
4848

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

51-
```py
52-
from huggingface_hub import notebook_login
51+
```
52+
from huggingface_hub import login
5353
54-
notebook_login()
54+
login()
5555
```
5656

5757
⚡️ 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.

docs/source/en/examples/rag.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ _Note:_ The Inference API hosts models based on various criteria, and deployed m
137137
from smolagents import HfApiModel, CodeAgent
138138

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

docs/source/en/guided_tour.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ The Python interpreter also doesn't allow imports by default outside of a safe l
113113
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`]:
114114

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

163162
- **DuckDuckGo web search***: performs a web search using DuckDuckGo browser.
164-
- **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
163+
- **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
165164
- **Transcriber**: a speech-to-text pipeline built on Whisper-Turbo that transcribes an audio to text.
166165

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

169168
```python
170-
from smolagents import load_tool
169+
from smolagents import DuckDuckGoSearchTool
171170

172-
search_tool = load_tool("web_search")
171+
search_tool = DuckDuckGoSearchTool()
173172
print(search_tool("Who's the current president of Russia?"))
174173
```
175174

docs/source/en/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rendered properly in your Markdown viewer.
1515

1616
# `smolagents`
1717

18-
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).
18+
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).
1919

2020
This library offers:
2121

docs/source/en/reference/tools.md

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

4040
[[autodoc]] Tool
4141

42-
### Toolbox
43-
44-
[[autodoc]] Toolbox
45-
4642
### launch_gradio_demo
4743

4844
[[autodoc]] launch_gradio_demo

docs/source/en/tutorials/secure_code_execution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Code is just a better way to express actions on a computer. It has better:
3030
- **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?
3131
- **Object management:** how do you store the output of an action like `generate_image` in JSON?
3232
- **Generality:** code is built to express simply anything you can do have a computer do.
33-
- **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?
33+
- **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?
3434

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

docs/source/en/tutorials/tools.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ agent.run("How many more blocks (also denoted as layers) are in BERT base encode
177177

178178
### Manage your agent's toolbox
179179

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

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

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

189189
agent = CodeAgent(tools=[], model=model, add_base_tools=True)
190-
agent.toolbox.add_tool(model_download_tool)
190+
agent.tools[model_download_tool.name] = model_download_tool
191191
```
192192
Now we can leverage the new tool:
193193

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

205-
Use the `agent.toolbox.update_tool()` method to replace an existing tool in the agent's toolbox.
206-
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.
207-
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.
208-
209-
210205
### Use a collection of tools
211206

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

0 commit comments

Comments
 (0)