{"id":533,"date":"2025-01-10T14:33:30","date_gmt":"2025-01-10T14:33:30","guid":{"rendered":"https:\/\/smolagents.org\/?p=533"},"modified":"2025-01-10T14:33:31","modified_gmt":"2025-01-10T14:33:31","slug":"smolagents-simplifying-ai-agent-development","status":"publish","type":"post","link":"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/","title":{"rendered":"smolagents\u2014Simplifying AI Agent Development"},"content":{"rendered":"<p>In the rapidly evolving world of artificial intelligence, AI agents have become integral in automating tasks, enhancing user experiences, and driving innovation across various industries. However, developing a robust AI agent often involves complex coding, intricate configurations, and a steep learning curve. Introducing <strong>smolagents<\/strong>, a minimalist AI agent framework developed by the Hugging Face team, designed to simplify AI agent creation while harnessing the power of large language models (LLMs).<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_71 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#What_is_smolagents\" title=\"What is smolagents?\">What is smolagents?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#Key_Features_of_smolagents\" title=\"Key Features of smolagents\">Key Features of smolagents<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#1_Simplicity_and_Ease_of_Use\" title=\"1. Simplicity and Ease of Use\">1. Simplicity and Ease of Use<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#2_Support_for_Code_Agents\" title=\"2. Support for Code Agents\">2. Support for Code Agents<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#3_Wide_Compatibility_with_Large_Language_Models\" title=\"3. Wide Compatibility with Large Language Models\">3. Wide Compatibility with Large Language Models<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#4_Deep_Integration_with_Hugging_Face_Hub\" title=\"4. Deep Integration with Hugging Face Hub\">4. Deep Integration with Hugging Face Hub<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#5_Support_for_Traditional_Tool-Calling_Agents\" title=\"5. Support for Traditional Tool-Calling Agents\">5. Support for Traditional Tool-Calling Agents<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#Advantages_of_Using_smolagents\" title=\"Advantages of Using smolagents\">Advantages of Using smolagents<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#Getting_Started_with_smolagents\" title=\"Getting Started with smolagents\">Getting Started with smolagents<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/smolagents.org\/vi\/smolagents-simplifying-ai-agent-development\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_smolagents\"><\/span><strong>What is smolagents?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>smolagents<\/strong> is an open-source, lightweight AI agent library that allows developers to create powerful agents with minimal code. With a core codebase of approximately 1,000 lines in <code>agents.py<\/code>, smolagents reduces unnecessary abstractions, making the development process straightforward and accessible. By focusing on simplicity and efficiency, smolagents enables LLMs to interact seamlessly with real-world tasks and data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Key_Features_of_smolagents\"><\/span><strong>Key Features of smolagents<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Simplicity_and_Ease_of_Use\"><\/span><strong>1. Simplicity and Ease of Use<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Minimalist Design<\/strong>: smolagents prioritizes a clean and concise codebase, allowing developers to understand and utilize the framework without getting bogged down by complexity.<\/li>\n\n\n\n<li><strong>Quick Setup<\/strong>: Developers can define agents, provide the required tools, and run them immediately. There&#8217;s no need for elaborate configurations or extensive boilerplate code.<\/li>\n\n\n\n<li><strong>User-Friendly Interface<\/strong>: The intuitive design ensures that both beginners and experienced developers can leverage the framework effectively.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Support_for_Code_Agents\"><\/span><strong>2. Support for Code Agents<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Code Agents Focus<\/strong>: Unlike traditional agents that generate actions as JSON or text blobs, smolagents emphasizes\u00a0<strong>code agents<\/strong>. These agents write and execute Python code snippets to perform actions, leveraging the LLM&#8217;s ability to generate and interpret code.<\/li>\n\n\n\n<li><strong>Increased Efficiency<\/strong>: Code agents enhance efficiency and accuracy, reducing steps and LLM calls by approximately 30%. They excel at handling complex tasks and benchmarks.<\/li>\n\n\n\n<li><strong>Secure Execution<\/strong>: To ensure safety, smolagents supports executing code in sandboxed environments like\u00a0<strong>E2B<\/strong>, providing a secure and isolated environment for code execution.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Wide_Compatibility_with_Large_Language_Models\"><\/span><strong>3. Wide Compatibility with Large Language Models<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Flexible Model Integration<\/strong>: smolagents seamlessly integrates with any LLM, including models hosted on the Hugging Face Hub via Transformers, and models from OpenAI, Anthropic, and more through LiteLLM integration.<\/li>\n\n\n\n<li><strong>Choice of Models<\/strong>: Developers have the flexibility to choose the most suitable LLM for their project needs without worrying about compatibility issues.<\/li>\n\n\n\n<li><strong>Future-Proof Design<\/strong>: As new models emerge, smolagents can incorporate them, ensuring that developers always have access to cutting-edge technology.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Deep_Integration_with_Hugging_Face_Hub\"><\/span><strong>4. Deep Integration with Hugging Face Hub<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Tool Sharing<\/strong>: smolagents allows developers to share and load tools directly from the Hugging Face Hub, fostering a collaborative community.<\/li>\n\n\n\n<li><strong>Ecosystem Growth<\/strong>: This integration promotes the continuous expansion of functionalities and tools available within smolagents, enhancing its capabilities over time.<\/li>\n\n\n\n<li><strong>Community Engagement<\/strong>: Developers can contribute to the ecosystem, share insights, and collaborate on agent development projects.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Support_for_Traditional_Tool-Calling_Agents\"><\/span><strong>5. Support for Traditional Tool-Calling Agents<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Versatility<\/strong>: In addition to code agents, smolagents supports traditional\u00a0<strong>tool-calling agents<\/strong>\u00a0where actions are generated as JSON or text blocks.<\/li>\n\n\n\n<li><strong>Specific Use Cases<\/strong>: This flexibility allows developers to choose the appropriate agent type based on the specific requirements of their projects.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Advantages_of_Using_smolagents\"><\/span><strong>Advantages of Using smolagents<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Enhanced Composability<\/strong>: Code agents facilitate function nesting and reuse, making it easier to express complex logic.<\/li>\n\n\n\n<li><strong>Efficient Object Handling<\/strong>: Managing and passing objects is more straightforward in code compared to JSON structures.<\/li>\n\n\n\n<li><strong>Unlimited Flexibility<\/strong>: Code can represent any computational operation, providing infinite possibilities for agent capabilities.<\/li>\n\n\n\n<li><strong>Leverage Rich Training Data<\/strong>: LLMs are trained on vast amounts of code, making them proficient at generating and understanding code snippets.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Getting_Started_with_smolagents\"><\/span><strong>Getting Started with smolagents<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>Installation<\/strong><\/p>\n\n\n\n<p>To install smolagents, simply run:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bash\u590d\u5236<code>pip install smolagents\n<\/code><\/pre>\n\n\n\n<p><strong>Basic Usage Example<\/strong><\/p>\n\n\n\n<p>Here&#8217;s how you can use smolagents to create a simple agent:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python\u590d\u5236<code>from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel\n\n# Initialize the agent with necessary tools and model\nagent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())\n\n# Execute the agent's task\nagent.run(\"How many seconds would it take a cheetah at top speed to run across the Golden Gate Bridge?\")\n<\/code><\/pre>\n\n\n\n<p><strong>Sample Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vbnet\u590d\u5236<code>The Golden Gate Bridge is approximately 1.7 miles long.\nA cheetah's top speed is about 60-70 mph.\n\nFirst, convert the bridge length to miles:\n1.7 miles = 1.7 miles\n\nCalculate time:\nTime = Distance \/ Speed\n\nUsing 70 mph for the cheetah's speed:\nTime = 1.7 miles \/ 70 mph \u2248 0.0243 hours\n\nConvert hours to seconds:\n0.0243 hours * 3600 seconds\/hour \u2248 87.5 seconds\n\nSo, it would take a cheetah approximately 87.5 seconds to run across the Golden Gate Bridge at top speed.\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>smolagents revolutionizes the way developers create AI agents by offering a simple yet powerful framework. Its emphasis on code agents, wide model compatibility, and deep integration with the Hugging Face ecosystem make it an invaluable tool for AI development. Whether you&#8217;re a seasoned AI expert or new to the field, smolagents provides the tools you need to build intelligent agents efficiently.<\/p>","protected":false},"excerpt":{"rendered":"<p>In the rapidly evolving world of artificial intelligence, AI agents have become integral in automating tasks, enhancing user experiences, and driving innovation across various industries. However, developing a robust AI agent often involves complex coding, intricate configurations, and a steep learning curve. Introducing smolagents, a minimalist AI agent framework developed by the Hugging Face team,&#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-533","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/posts\/533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/comments?post=533"}],"version-history":[{"count":1,"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/posts\/533\/revisions"}],"predecessor-version":[{"id":534,"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/posts\/533\/revisions\/534"}],"wp:attachment":[{"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/media?parent=533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/categories?post=533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smolagents.org\/vi\/wp-json\/wp\/v2\/tags?post=533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}