dotsagent.io
语言:简体中文
框架 · Hugging Face

快速了解 smolagents

Hugging Face 的轻量级 Python 库,代码量约千行;它的 CodeAgent 会用 Python 代码编写操作,并在 Modal、E2B 或 Docker 等沙箱中运行。代理和工具也可以分享到 Hub。

适用于: 学习和研究,尤其适用于通过编写代码来执行操作的代理。

关键信息

维护者
Hugging Face
语言
Python
许可证
Apache-2.0
最新版本
1.26.0 · 2026年5月29日
代码仓库
huggingface/smolagents · 29,617 个 stars
托管选项
无

快速入门

安装软件包、设置凭据,然后运行官方文档中的最简 agent。这里使用的模型 ID 与文档一致,但你的账户可能尚未启用这些模型。

安装
pip install 'smolagents[toolkit]'

需要 HF token for Inference API

Python
from smolagents import CodeAgent, InferenceClientModel

# Initialize a model (using Hugging Face Inference API)
model = InferenceClientModel()  # Uses a default model

# Create an agent with no tools
agent = CodeAgent(tools=[], model=model)

# Run the agent with a task
result = agent.run("Calculate the sum of numbers from 1 to 10")
print(result)

快速入门来源

功能

支持任意模型是HF Inference Providers、LiteLLM、本地 Transformers 和 Ollama
MCP 客户端是来自任意 MCP server、LangChain 或 Hub Spaces 的工具
MCP 服务器尚未确认
多 agent是代理可以协调其他代理
持久化运行尚未确认
人工审批尚未确认
追踪尚未确认
评测否

近期更新

  • 自 2026 年 5 月 29 日发布 1.26.0 后,PyPI 上没有新版本;不过该仓库在 2026 年 9 月下旬仍有提交。

同一语言的替代方案

来源

  1. huggingface.co/docs/smolagents/index
  2. pypi.org/pypi/smolagents/json
  3. api.github.com/repos/huggingface/smolagents

为 AI agent 开发者提供的独立参考资料。与此处提及的任何厂商均无关联。

© 2026 DotsAgent · 事实核查日期:2026年10月1日