Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huggingface/smolagents
π€ Smolagents: a barebones library for agents. Agents just write python code to call/orchestrate tools.
https://github.com/huggingface/smolagents
Last synced: 16 days ago
JSON representation
π€ Smolagents: a barebones library for agents. Agents just write python code to call/orchestrate tools.
- Host: GitHub
- URL: https://github.com/huggingface/smolagents
- Owner: huggingface
- License: apache-2.0
- Created: 2024-12-05T11:28:04.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-12-26T11:10:20.000Z (20 days ago)
- Last Synced: 2024-12-26T11:30:35.308Z (20 days ago)
- Language: Python
- Homepage:
- Size: 1.26 MB
- Stars: 81
- Watchers: 8
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - huggingface/smolagents - π€ smolagents: a barebones library for agents. Agents write python code to call tools and orchestrate other agents. (Python)
- StarryDivineSky - huggingface/smolagents
- awesome-LLM-resourses - smolagents
README
π€ smolagents - a smol library to build great agents!
`smolagents` is a library that enables you to run powerful agents in a few lines of code. It offers:
β¨ **Simplicity**: the logic for agents fits in ~thousand lines of code. We kept abstractions to their minimal shape above raw code!
π **Support for any LLM**: it supports models hosted on the Hub loaded in their `transformers` version or through our inference API, but also models from OpenAI, Anthropic, and many more through our LiteLLM integration.
π§βπ» **First-class support for Code Agents**, i.e. agents that write their actions in code (as opposed to "agents being used to write code"), [read more here](https://huggingface.co/docs/smolagents/tutorials/secure_code_execution).
π€ **Hub integrations**: you can share and load tools to/from the Hub, and more is to come!
## Quick demo
First install the package.
```bash
pip install smolagents
```
Then define your agent, give it the tools it needs and run it!
```py
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModelagent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
```https://github.com/user-attachments/assets/cd0226e2-7479-4102-aea0-57c22ca47884
## Code agents?
In our `CodeAgent`, the LLM engine writes its actions in code. This approach is demonstrated to work better than the current industry practice of letting the LLM output a dictionary of the tools it wants to calls: [uses 30% fewer steps](https://huggingface.co/papers/2402.01030) (thus 30% fewer LLM calls)
and [reaches higher performance on difficult benchmarks](https://huggingface.co/papers/2411.01747). Head to [our high-level intro to agents](https://huggingface.co/docs/smolagents/conceptual_guides/intro_agents) to learn more on that.Especially, since code execution can be a security concern (arbitrary code execution!), we provide options at runtime:
- a secure python interpreter to run code more safely in your environment
- a sandboxed environment using [E2B](https://e2b.dev/).## How smol is it really?
We strived to keep abstractions to a strict minimum: the main code in `agents.py` is only ~1,000 lines of code.
Still, we implement several types of agents: `CodeAgent` writes its actions as Python code snippets, and the more classic `ToolCallingAgent` leverages built-in tool calling methods.By the way, why use a framework at all? Well, because a big part of this stuff is non-trivial. For instance, the code agent has to keep a consistent format for code throughout its system prompt, its parser, the execution. So our framework handles this complexity for you. But of course we still encourage you to hack into the source code and use only the bits that you need, to the exclusion of everything else!
## Citing smolagents
If you use `smolagents` in your publication, please cite it by using the following BibTeX entry.
```bibtex
@Misc{smolagents,
title = {`smolagents`: The easiest way to build efficient agentic systems.},
author = {Aymeric Roucher and Thomas Wolf and Leandro von Werra and Erik KaunismΓ€ki},
howpublished = {\url{https://github.com/huggingface/smolagents}},
year = {2025}
}
```