smolagents क्या है?
smolagents Python की कुछ लाइनों में ऐसे AI एजेंट बनाएं जो कोड में सोचते हैं. यह Agents & Automation टूल्स की Agent Frameworks & Builders श्रेणी में आता है; ओपन सोर्स है, Python में लिखा गया है और Apache-2.0 लाइसेंस के तहत है। शुरू करने के लिए: इंस्टॉल करें.
सारांश
smolagents Hugging Face की एक छोटी एजेंट लाइब्रेरी है। मॉडल से structured tool calls भेजवाने के बजाय इसका मुख्य एजेंट टाइप अपने कदम Python कोड में लिखता है और उन्हें चलाता है। पूरी एजेंट लॉजिक लगभग 1,000 लाइनों तक सीमित रखी गई है, ताकि एब्सट्रैक्शन उस कच्चे कोड के करीब रहें जो आप खुद लिखते।
यह उन डेवलपर्स के लिए है जो बड़ा framework अपनाए बिना LLM को tools से जोड़ना चाहते हैं। आप CodeAgent को tools की सूची और एक model देते हैं, फिर task के साथ run() कॉल करते हैं। चूँकि यह model-agnostic है, इसे आप लोकल transformers या Ollama मॉडल से, Hugging Face Inference provider से, या LiteLLM के ज़रिए OpenAI, Anthropic और दूसरों से जोड़ सकते हैं।
एक सामान्य agent framework के रूप में smolagents का ज़ोर code लिखकर काम करने वाले पैटर्न और शेयरिंग पर है। आप Hugging Face Hub से tools और एजेंट ला सकते हैं, किसी भी MCP server या LangChain के tools इस्तेमाल कर सकते हैं, और जब आइसोलेशन चाहिए हो तो जनरेट किया गया कोड sandboxed environments (Blaxel, E2B, Modal, या Docker) में चला सकते हैं।
यह क्या करता है
- CodeAgent अपने कदम पहले से तय tool-call payloads के बजाय Python कोड में लिखता है
- Model-agnostic: लोकल transformers/Ollama, Hugging Face inference providers, या LiteLLM के ज़रिए OpenAI/Anthropic/अन्य
- Tool-agnostic: MCP servers, LangChain, या Hugging Face Hub Space के tools इस्तेमाल करें
- Blaxel, E2B, Modal, या Docker के ज़रिए sandboxed कोड execution
- Hugging Face Hub के ज़रिए tools और एजेंट शेयर करें और लोड करें
- दो CLI कमांड, smolagent और webagent, ताकि टर्मिनल से एजेंट चलाए जा सकें
शुरू करें
डिफ़ॉल्ट toolkit के साथ package इंस्टॉल करें, फिर एक CodeAgent बनाएं, उसे tools और एक model दें, और एक task चलाएं।
इंस्टॉल करें
डिफ़ॉल्ट tools के सेट के साथ smolagents इंस्टॉल करें।
pip install "smolagents[toolkit]"एजेंट बनाएं और चलाएं
एक model परिभाषित करें, वेब सर्च tool के साथ CodeAgent बनाएं, और अपने task के साथ run() कॉल करें।
from smolagents import CodeAgent, WebSearchTool, InferenceClientModel
model = InferenceClientModel()
agent = CodeAgent(tools=[WebSearchTool()], model=model, stream_outputs=True)
agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")कोई दूसरा model provider इस्तेमाल करें
smolagents LLM-agnostic है। उदाहरण के लिए, LiteLLM के ज़रिए किसी model की ओर route करें।
from smolagents import LiteLLMModel
model = LiteLLMModel(
model_id="anthropic/claude-4-sonnet-latest",
temperature=0.2,
api_key=os.environ["ANTHROPIC_API_KEY"]
)CLI से चलाएं
अपने टर्मिनल से multi-step CodeAgent चलाने के लिए smolagent कमांड इस्तेमाल करें।
smolagent "Plan a trip to Tokyo, Kyoto and Osaka between Mar 28 and Apr 7." --model-type "InferenceClientModel" --model-id "Qwen/Qwen3-Next-80B-A3B-Thinking" --imports pandas numpyकमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।
कब इस्तेमाल करें
- एक रिसर्च असिस्टेंट बनाएं जो वेब पर सर्च करे और नतीजों पर चरण-दर-चरण तर्क करे
- बड़ा framework अपनाए बिना किसी ऐप में tool-calling एजेंट जोड़ें
- एक ही interface के पीछे अलग-अलग LLM providers (लोकल, Hugging Face, OpenAI, Anthropic) पर एजेंट चलाएं
- किसी एजेंट को मौजूदा MCP servers या LangChain tools से जोड़ें और उसे Hugging Face Hub के ज़रिए शेयर करें
How smolagents compares
smolagents alongside other open-source agent frameworks & builders tools AI/TLDR tracks, ranked by GitHub stars.
| टूल | स्टार | यह क्या करता है |
|---|---|---|
| DeepSeek Harness | ★ 290k | DeepSeek का ओपन एजेंट हार्नेस, जहाँ हर क्षमता एक प्लगइन है |
| AutoGPT | ★ 188k | दोबारा इस्तेमाल होने वाले ब्लॉक्स से निरंतर AI एजेंट बनाएं, डिप्लॉय करें और चलाएं |
| DeerFlow | ★ 86.1k | सब कुछ पहले से शामिल सुपर एजेंट हार्नेस, जिसमें स्किल्स, सब-एजेंट्स, सैंडबॉक्स और मेमोरी हैं |
| nanobot | ★ 50.5k | WebUI, मेमोरी, MCP और चैट ऐप्स वाला सेल्फ-होस्टेड पर्सनल एजेंट रनटाइम |
| LangGraph | ★ 45.7k | लंबे समय तक चलने वाले, stateful AI agents बनाने के लिए low-level orchestration framework |
| Agno | ★ 43.4k | AI agent प्लेटफ़ॉर्म बनाने, चलाने और मैनेज करने के लिए Python SDK |
| AgentGPT | ★ 36.3k | ब्राउज़र में ही ऑटोनॉमस AI एजेंट बनाएं, कॉन्फ़िगर करें और डिप्लॉय करें |
| smolagents | ★ 30.6k | Python की कुछ लाइनों में ऐसे AI एजेंट बनाएं जो कोड में सोचते हैं |

