Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
@@ -7,4 +7,65 @@ sdk: static
|
|
7 |
pinned: false
|
8 |
---
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
pinned: false
|
8 |
---
|
9 |
|
10 |
+
<p align="center">
|
11 |
+
<!-- Uncomment when CircleCI is set up
|
12 |
+
<a href="https://circleci.com/gh/huggingface/accelerate"><img alt="Build" src="https://img.shields.io/circleci/build/github/huggingface/transformers/master"></a>
|
13 |
+
-->
|
14 |
+
<a href="https://github.com/huggingface/smolagents/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/huggingface/smolagents.svg?color=blue"></a>
|
15 |
+
<a href="https://huggingface.co/docs/smolagents"><img alt="Documentation" src="https://img.shields.io/website/http/huggingface.co/docs/smolagents/index.html.svg?down_color=red&down_message=offline&up_message=online"></a>
|
16 |
+
<a href="https://github.com/huggingface/smolagents/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/smolagents.svg"></a>
|
17 |
+
<a href="https://github.com/huggingface/smolagents/blob/main/CODE_OF_CONDUCT.md"><img alt="Contributor Covenant" src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg"></a>
|
18 |
+
</p>
|
19 |
+
|
20 |
+
<h3 align="center">
|
21 |
+
<div style="display:flex;flex-direction:row;">
|
22 |
+
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/smolagents/smolagents.png" alt="Hugging Face mascot as James Bond" width=400px>
|
23 |
+
<p>Agents that think in code!</p>
|
24 |
+
</div>
|
25 |
+
</h3>
|
26 |
+
|
27 |
+
`smolagents` is a library that enables you to run powerful agents in a few lines of code. It offers:
|
28 |
+
|
29 |
+
β¨ **Simplicity**: the logic for agents fits in ~1,000 lines of code (see [agents.py](https://github.com/huggingface/smolagents/blob/main/src/smolagents/agents.py)). We kept abstractions to their minimal shape above raw code!
|
30 |
+
|
31 |
+
π§βπ» **First-class support for Code Agents**. Our [`CodeAgent`](https://huggingface.co/docs/smolagents/reference/agents#smolagents.CodeAgent) writes its actions in code (as opposed to "agents being used to write code"). To make it secure, we support executing in sandboxed environments via [E2B](https://e2b.dev/) or via Docker.
|
32 |
+
|
33 |
+
π€ **Hub integrations**: you can [share/pull tools or agents to/from the Hub](https://huggingface.co/docs/smolagents/reference/tools#smolagents.Tool.from_hub) for instant sharing of the most efficient agents!
|
34 |
+
|
35 |
+
π **Model-agnostic**: smolagents supports any LLM. It can be a local `transformers` or `ollama` model, one of [many providers on the Hub](https://huggingface.co/blog/inference-providers), or any model from OpenAI, Anthropic and many others via our [LiteLLM](https://www.litellm.ai/) integration.
|
36 |
+
|
37 |
+
ποΈ **Modality-agnostic**: Agents support text, vision, video, even audio inputs! Cf [this tutorial](https://huggingface.co/docs/smolagents/examples/web_browser) for vision.
|
38 |
+
|
39 |
+
π οΈ **Tool-agnostic**: you can use tools from any [MCP server](https://huggingface.co/docs/smolagents/reference/tools#smolagents.ToolCollection.from_mcp), from [LangChain](https://huggingface.co/docs/smolagents/reference/tools#smolagents.Tool.from_langchain), you can even use a [Hub Space](https://huggingface.co/docs/smolagents/reference/tools#smolagents.Tool.from_space) as a tool.
|
40 |
+
|
41 |
+
Full documentation can be found [here](https://huggingface.co/docs/smolagents/index).
|
42 |
+
|
43 |
+
> [!NOTE]
|
44 |
+
> Check the our [launch blog post](https://huggingface.co/blog/smolagents) to learn more about `smolagents`!
|
45 |
+
|
46 |
+
## Quick demo
|
47 |
+
|
48 |
+
First install the package with a default set of tools:
|
49 |
+
```bash
|
50 |
+
pip install smolagents[toolkit]
|
51 |
+
```
|
52 |
+
Then define your agent, give it the tools it needs and run it!
|
53 |
+
```py
|
54 |
+
from smolagents import CodeAgent, WebSearchTool, InferenceClientModel
|
55 |
+
|
56 |
+
model = InferenceClientModel()
|
57 |
+
agent = CodeAgent(tools=[WebSearchTool()], model=model, stream_outputs=True)
|
58 |
+
|
59 |
+
agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
|
60 |
+
```
|
61 |
+
|
62 |
+
https://github.com/user-attachments/assets/84b149b4-246c-40c9-a48d-ba013b08e600
|
63 |
+
|
64 |
+
You can even share your agent to the Hub, as a Space repository:
|
65 |
+
```py
|
66 |
+
agent.push_to_hub("m-ric/my_agent")
|
67 |
+
|
68 |
+
# agent.from_hub("m-ric/my_agent") to load an agent from Hub
|
69 |
+
```
|
70 |
+
|
71 |
+
Our library is LLM-agnostic: you could switch the example above to any inference provider: our InferenceClient, OpenAI, Anthropic...
|