{"id":15837,"date":"2024-11-18T12:03:02","date_gmt":"2024-11-18T04:03:02","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=15837"},"modified":"2024-12-18T12:07:50","modified_gmt":"2024-12-18T04:07:50","slug":"atomic-agent","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/pt\/atomic-agent\/","title":{"rendered":"Atomic Agents\uff1a\u6784\u5efa\u8f7b\u91cf\u7ea7\u6a21\u5757\u5316AI\u667a\u80fd\u4f53\u6846\u67b6"},"content":{"rendered":"<p>Atomic Agents \u662f\u4e00\u4e2a\u56f4\u7ed5\u539f\u5b50\u6027\u6982\u5ff5\u8bbe\u8ba1\u7684\u6781\u5176\u8f7b\u91cf\u7ea7\u548c\u6a21\u5757\u5316\u7684\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u4ee3\u7406AI\u7ba1\u9053\u548c\u5e94\u7528\u7a0b\u5e8f\u3002\u8be5\u6846\u67b6\u63d0\u4f9b\u4e86\u4e00\u7ec4\u5de5\u5177\u548c\u4ee3\u7406\uff0c\u53ef\u4ee5\u7ec4\u5408\u521b\u5efa\u5f3a\u5927\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u57fa\u4e8e <a href=\"https:\/\/www.kdjingpai.com\/pt\/instructor\/\">Instructor<\/a> \u6784\u5efa\uff0c\u5e76\u5229\u7528 Pydantic \u8fdb\u884c\u6570\u636e\u548c\u6a21\u5f0f\u9a8c\u8bc1\u4e0e\u5e8f\u5217\u5316\u3002\u6240\u6709\u903b\u8f91\u548c\u63a7\u5236\u6d41\u90fd\u7528 Python \u7f16\u5199\uff0c\u4f7f\u5f00\u53d1\u8005\u80fd\u591f\u5e94\u7528\u4f20\u7edf\u8f6f\u4ef6\u5f00\u53d1\u4e2d\u7684\u6700\u4f73\u5b9e\u8df5\u548c\u5de5\u4f5c\u6d41\u7a0b\uff0c\u800c\u4e0d\u5f71\u54cd\u7075\u6d3b\u6027\u6216\u6e05\u6670\u5ea6\u3002Atomic Agents \u65e8\u5728\u901a\u8fc7\u6a21\u5757\u5316\u3001\u53ef\u9884\u6d4b\u6027\u3001\u53ef\u6269\u5c55\u6027\u548c\u63a7\u5236\u6027\u6765\u6ee1\u8db3\u4f01\u4e1a\u5bf9\u4e00\u81f4\u6027\u548c\u53ef\u9760\u6027\u8f93\u51fa\u7684\u9700\u6c42\u3002<\/p>\n<p>\u63a8\u8350\u9605\u8bfb\uff1a<a href=\"https:\/\/www.kdjingpai.com\/zaijian-langchaina\/\">\u518d\u89c1 LangChain\uff01Atomic Agent\u706b\u4e86\uff01<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15838\" title=\"Atomic Agents\uff1a\u6784\u5efa\u8f7b\u91cf\u7ea7\u6a21\u5757\u5316AI\u667a\u80fd\u4f53\u6846\u67b6-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/3330ce3dabae03f.jpg\" alt=\"Atomic Agents\uff1a\u6784\u5efa\u8f7b\u91cf\u7ea7\u6a21\u5757\u5316AI\u667a\u80fd\u4f53\u6846\u67b6-1\" width=\"1414\" height=\"827\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/3330ce3dabae03f.jpg 1414w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/3330ce3dabae03f-300x175.jpg 300w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/3330ce3dabae03f-1024x599.jpg 1024w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/3330ce3dabae03f-768x449.jpg 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/3330ce3dabae03f-18x12.jpg 18w\" sizes=\"auto, (max-width: 1414px) 100vw, 1414px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li><strong>\u6a21\u5757\u5316<\/strong>\uff1a\u901a\u8fc7\u7ec4\u5408\u5c0f\u578b\u3001\u53ef\u91cd\u7528\u7684\u7ec4\u4ef6\u6765\u6784\u5efaAI\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li><strong>\u53ef\u9884\u6d4b\u6027<\/strong>\uff1a\u5b9a\u4e49\u6e05\u6670\u7684\u8f93\u5165\u548c\u8f93\u51fa\u6a21\u5f0f\uff0c\u786e\u4fdd\u884c\u4e3a\u4e00\u81f4\u3002<\/li>\n<li><strong>\u53ef\u6269\u5c55\u6027<\/strong>\uff1a\u8f7b\u677e\u66ff\u6362\u7ec4\u4ef6\u6216\u96c6\u6210\u65b0\u7ec4\u4ef6\uff0c\u800c\u4e0d\u4f1a\u7834\u574f\u6574\u4e2a\u7cfb\u7edf\u3002<\/li>\n<li><strong>\u63a7\u5236\u6027<\/strong>\uff1a\u5355\u72ec\u5fae\u8c03\u7cfb\u7edf\u7684\u6bcf\u4e2a\u90e8\u5206\uff0c\u4ece\u7cfb\u7edf\u63d0\u793a\u5230\u5de5\u5177\u96c6\u6210\u3002<\/li>\n<li><strong>\u6570\u636e\u9a8c\u8bc1<\/strong>\uff1a\u5229\u7528 Pydantic \u8fdb\u884c\u6570\u636e\u548c\u6a21\u5f0f\u9a8c\u8bc1\u4e0e\u5e8f\u5217\u5316\u3002<\/li>\n<li><strong>Python\u5f00\u53d1<\/strong>\uff1a\u6240\u6709\u903b\u8f91\u548c\u63a7\u5236\u6d41\u90fd\u7528 Python \u7f16\u5199\uff0c\u4fbf\u4e8e\u5f00\u53d1\u8005\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<ol>\n<li>\u786e\u4fdd\u5df2\u5b89\u88c5 Python 3.11 \u6216\u66f4\u9ad8\u7248\u672c\u3002<\/li>\n<li>\u4f7f\u7528 pip \u5b89\u88c5 Atomic Agents\uff1a<\/li>\n<\/ol>\n<pre><code>   pip install atomic-agents\r\n<\/code><\/pre>\n<ol start=\"3\">\n<li>\u6839\u636e\u9700\u8981\u5b89\u88c5\u63d0\u4f9b\u8005\uff0c\u4f8b\u5982 OpenAI \u548c Groq\uff1a<\/li>\n<\/ol>\n<pre><code>   pip install openai <a href=\"https:\/\/www.kdjingpai.com\/pt\/groqaidamoxingbai\/\">groq<\/a>\r\n<\/code><\/pre>\n<h3>\u4f7f\u7528\u6307\u5357<\/h3>\n<h4>\u521b\u5efa\u4ee3\u7406<\/h4>\n<ol>\n<li><strong>\u5b9a\u4e49\u7cfb\u7edf\u63d0\u793a<\/strong>\uff1a\u786e\u5b9a\u4ee3\u7406\u7684\u884c\u4e3a\u548c\u76ee\u7684\u3002<\/li>\n<li><strong>\u5b9a\u4e49\u8f93\u5165\u6a21\u5f0f<\/strong>\uff1a\u6307\u5b9a\u4ee3\u7406\u8f93\u5165\u7684\u7ed3\u6784\u548c\u9a8c\u8bc1\u89c4\u5219\u3002<\/li>\n<li><strong>\u5b9a\u4e49\u8f93\u51fa\u6a21\u5f0f<\/strong>\uff1a\u6307\u5b9a\u4ee3\u7406\u8f93\u51fa\u7684\u7ed3\u6784\u548c\u9a8c\u8bc1\u89c4\u5219\u3002<\/li>\n<li><strong>\u5b58\u50a8\u8bb0\u5fc6<\/strong>\uff1a\u4fdd\u5b58\u5bf9\u8bdd\u5386\u53f2\u6216\u5176\u4ed6\u76f8\u5173\u6570\u636e\u3002<\/li>\n<li><strong>\u4e0a\u4e0b\u6587\u63d0\u4f9b\u8005<\/strong>\uff1a\u5728\u8fd0\u884c\u65f6\u5c06\u52a8\u6001\u4e0a\u4e0b\u6587\u6ce8\u5165\u4ee3\u7406\u7684\u7cfb\u7edf\u63d0\u793a\u4e2d\u3002<\/li>\n<\/ol>\n<h4>\u793a\u4f8b\u4ee3\u7801<\/h4>\n<pre><code>from atomic_agents import Agent, SystemPrompt, InputSchema, OutputSchema\r\n# \u5b9a\u4e49\u7cfb\u7edf\u63d0\u793a\r\nsystem_prompt = SystemPrompt(\"\u4f60\u662f\u4e00\u4e2a\u5e2e\u52a9\u7528\u6237\u89e3\u51b3\u95ee\u9898\u7684AI\u52a9\u624b\u3002\")\r\n# \u5b9a\u4e49\u8f93\u5165\u548c\u8f93\u51fa\u6a21\u5f0f\r\ninput_schema = InputSchema({\"type\": \"object\", \"properties\": {\"question\": {\"type\": \"string\"}}})\r\noutput_schema = OutputSchema({\"type\": \"object\", \"properties\": {\"answer\": {\"type\": \"string\"}}})\r\n# \u521b\u5efa\u4ee3\u7406\r\nagent = Agent(system_prompt=system_prompt, input_schema=input_schema, output_schema=output_schema)\r\n# \u4f7f\u7528\u4ee3\u7406\r\nresponse = agent.run({\"question\": \"\u4eca\u5929\u7684\u5929\u6c14\u600e\u4e48\u6837\uff1f\"})\r\nprint(response[\"answer\"])\r\n<\/code><\/pre>\n<h3>\u5f00\u53d1\u5de5\u4f5c\u6d41\u7a0b<\/h3>\n<ol>\n<li><strong>\u521b\u5efa\u65b0\u5206\u652f<\/strong>\uff1a\u4e3a\u65b0\u529f\u80fd\u6216\u4fee\u590d\u521b\u5efa\u5206\u652f\u3002<\/li>\n<\/ol>\n<pre><code>   git checkout -b feature-branch\r\n<\/code><\/pre>\n<ol start=\"2\">\n<li><strong>\u8fdb\u884c\u4ee3\u7801\u66f4\u6539<\/strong>\uff1a\u5728\u9002\u5f53\u7684\u9879\u76ee\u76ee\u5f55\u4e2d\u8fdb\u884c\u66f4\u6539\u3002<\/li>\n<li><strong>\u683c\u5f0f\u5316\u4ee3\u7801<\/strong>\uff1a\u4f7f\u7528 Black \u683c\u5f0f\u5316\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<pre><code>   black atomic_agents\r\n<\/code><\/pre>\n<ol start=\"4\">\n<li><strong>\u4ee3\u7801\u68c0\u67e5<\/strong>\uff1a\u4f7f\u7528 Flake8 \u8fdb\u884c\u4ee3\u7801\u68c0\u67e5\u3002<\/li>\n<\/ol>\n<pre><code>   flake8 atomic_agents\r\n<\/code><\/pre>\n<ol start=\"5\">\n<li><strong>\u8fd0\u884c\u6d4b\u8bd5<\/strong>\uff1a\u786e\u4fdd\u6240\u6709\u6d4b\u8bd5\u901a\u8fc7\u3002<\/li>\n<\/ol>\n<pre><code>   pytest --cov atomic_agents\r\n<\/code><\/pre>\n<ol start=\"6\">\n<li><strong>\u63d0\u4ea4\u66f4\u6539<\/strong>\uff1a\u63d0\u4ea4\u5e76\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/li>\n<\/ol>\n<pre><code>   git commit -m 'Add some feature'\r\ngit push origin feature-branch\r\n<\/code><\/pre>\n<ol start=\"7\">\n<li><strong>\u521b\u5efa\u62c9\u53d6\u8bf7\u6c42<\/strong>\uff1a\u5728 GitHub \u4e0a\u521b\u5efa\u62c9\u53d6\u8bf7\u6c42\uff0c\u63cf\u8ff0\u66f4\u6539\u5185\u5bb9\u5e76\u94fe\u63a5\u76f8\u5173\u95ee\u9898\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Atomic Agents \u662f\u4e00\u4e2a\u56f4\u7ed5\u539f\u5b50\u6027\u6982\u5ff5\u8bbe\u8ba1\u7684\u6781\u5176\u8f7b\u91cf\u7ea7\u548c\u6a21\u5757\u5316\u7684\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u4ee3\u7406AI\u7ba1\u9053\u548c\u5e94\u7528\u7a0b\u5e8f\u3002\u8be5\u6846\u67b6\u63d0\u4f9b\u4e86\u4e00\u7ec4\u5de5\u5177\u548c\u4ee3\u7406\uff0c\u53ef\u4ee5\u7ec4\u5408\u521b\u5efa\u5f3a\u5927\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u57fa\u4e8e Instructor \u6784\u5efa\uff0c\u5e76\u5229\u7528 Pydantic \u8fdb\u884c\u6570\u636e\u548c&#8230;<\/p>\n","protected":false},"author":1,"featured_media":61256,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[230,201],"class_list":["post-15837","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaiyuanxiangmu","tag-aizhinengti"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts\/15837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/comments?post=15837"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts\/15837\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/media\/61256"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/media?parent=15837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/categories?post=15837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/tags?post=15837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}