Scripts2026年4月6日·1 分钟阅读

Smolagents — Lightweight Agent Framework by HuggingFace

Minimalist Python agent framework by HuggingFace. Build agents with tool use in under 30 lines of code. Supports code-based agents that write and execute Python instead of JSON tool calls. 15,000+ stars.

介绍

Smolagents is HuggingFace's minimalist Python agent framework, with 15,000+ GitHub stars. Build a full agent in fewer than 30 lines of code. Its signature Code Agent mode lets the LLM write Python directly to call tools. Ideal for developers who want the shortest path to building an agent.


Quick Use

pip install smolagents
from smolagents import CodeAgent, tool, LiteLLMModel

@tool
def get_weather(city: str) -> str:
    'Get city weather'
    return f"{city}: 22°C, clear"

agent = CodeAgent(tools=[get_weather], model=LiteLLMModel("anthropic/claude-sonnet-4-20250514"))
agent.run("What's the weather in Tokyo?")

Intro

Smolagents is HuggingFace's minimalist Python agent framework, with 15,000+ GitHub stars. Build a full agent in fewer than 30 lines of code. Its signature Code Agent mode lets the LLM write Python directly to call tools. Ideal for developers who want the shortest path to building an agent.


Source & Thanks

Created by HuggingFace. Licensed under Apache 2.0.

smolagents — ⭐ 15,000+

🙏

来源与感谢

Created by HuggingFace. Licensed under Apache 2.0.

smolagents — ⭐ 15,000+

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产