{"id":19212,"date":"2025-08-16T22:22:58","date_gmt":"2025-08-16T14:22:58","guid":{"rendered":"https:\/\/92it.top\/?p=19212"},"modified":"2025-08-16T22:38:53","modified_gmt":"2025-08-16T14:38:53","slug":"%e4%bb%80%e4%b9%88%e6%98%afautogen%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=19212","title":{"rendered":"AutoGen\u5b98\u65b9\u6587\u6863\u4f8b\u5b50"},"content":{"rendered":"\n<p>\u60f3\u8c61\u4e00\u4e0b\uff0c\u4f60\u6709\u4e00\u652f\u56e2\u961f\uff0c\u6bcf\u4e2a\u6210\u5458\u90fd\u5f88\u64c5\u957f\u505a\u4e0d\u540c\u7684\u4e8b\u60c5\u3002\u4e00\u4e2a\u4eba\u64c5\u957f\u89c4\u5212\u884c\u7a0b\uff0c\u4e00\u4e2a\u4eba\u4e86\u89e3\u5f53\u5730\u6709\u8da3\u7684\u5730\u65b9\uff0c\u4e00\u4e2a\u4eba\u4f1a\u6559\u4f60\u8bf4\u5f53\u5730\u7684\u8bed\u8a00\uff0c\u8fd8\u6709\u4e00\u4e2a\u4eba\u8d1f\u8d23\u628a\u6240\u6709\u60f3\u6cd5\u6574\u5408\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u8ba1\u5212\u3002<br>AutoGen\u5c31\u662f\u8ba9AI\u7ec4\u6210\u8fd9\u6837\u4e00\u4e2a\u56e2\u961f\u7684\u5de5\u5177\uff0c\u8ba9\u5b83\u4eec\u4e00\u8d77\u5408\u4f5c\u5b8c\u6210\u4efb\u52a1\uff0c\u800c\u4e0d\u662f\u53ea\u6709\u4e00\u4e2aAI\u8bd5\u56fe\u505a\u6240\u6709\u4e8b\u60c5\u3002<\/p>\n\n\n\n<p><strong>\u4ee3\u7801\u89e3\u6790<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>\u7b2c\u4e00\u90e8\u5206\uff1a\u51c6\u5907\u5de5\u4f5c<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import asyncio \nimport os\nfrom dotenv import load__dotenv\nfrom autogen_agentchat.agents import AssistantAgent \nfrom autogen_agentchat.conditions import TextMentionTermination \nfrom autogen_agentchat.teams import RoundRobinGroupChat \nfrom autogen_agentchat.ui import Console \nfrom autogen_ext.models.openai import OpenAIChatCompletionClient\n\nload_dotenv()<\/pre>\n\n\n\n<p>\u8fd9\u5c31\u50cf\u5728\u505a\u996d\u524d\u51c6\u5907\u6240\u6709\u6750\u6599\u3002\u6211\u4eec\u5f15\u5165\u4e86\u6240\u6709\u9700\u8981\u7684\u5de5\u5177\uff1a<\/p>\n\n\n\n<ul>\n<li>asyncio\uff1a\u8ba9\u7a0b\u5e8f\u80fd\u591f\u540c\u65f6\u5904\u7406\u591a\u4e2a\u4efb\u52a1<\/li>\n\n\n\n<li>dotenv\uff1a\u5e2e\u52a9\u6211\u4eec\u5b89\u5168\u5730\u5b58\u50a8API\u5bc6\u94a5<\/li>\n\n\n\n<li>\u5176\u4ed6\u51e0\u4e2a\u5bfc\u5165\u662fAutoGen\u6846\u67b6\u7684\u7ec4\u4ef6\uff0c\u7528\u6765\u521b\u5efa\u548c\u7ba1\u7406AI\u4ee3\u7406load_dotenv() \u52a0\u8f7d\u4f60\u5b58\u50a8\u5728.env \u6587\u4ef6\u4e2d\u7684\u73af\u5883\u53d8\u91cf\uff0c\u6bd4\u5982API\u5bc6\u94a5\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u7b2c\u4e8c\u90e8\u5206\uff1a\u8bbe\u7f6eAI\u6a21\u578b<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">model_client = OpenAIChatCompletionClient (\n      mode1=\"gpt-4o\"\n      api_key=os. getenv\"OPENAI_API_KEY\")\n\uff09<\/pre>\n\n\n\n<p>\u8fd9\u5c31\u50cf\u9009\u62e9\u6211\u4eec\u56e2\u961f\u6210\u5458\u5c06\u4f7f\u7528\u7684\u201c\u5927\u8111\u201d\u3002\u6240\u6709\u4ee3\u7406\u90fd\u4f1a\u4f7f\u7528GPT-4o\u6a21\u578b\uff0c\u4f46\u6bcf\u4e2a\u4ee3\u7406\u4f1a\u6709\u4e0d\u540c\u7684\u89d2\u8272\u548c\u4e13\u957f\u3002\u6211\u4eec\u4f7f\u7528 os.getenv\uff08\u201dOPENAI_API_KEY&#8221;\uff09\u4ece\u73af\u5883\u53d8\u91cf\u4e2d\u83b7\u53d6API\u5bc6\u94a5\uff0c\u8fd9\u6bd4\u76f4\u63a5\u5728\u4ee3\u7801\u4e2d\u5199\u5bc6\u94a5\u66f4\u5b89\u5168\u3002<\/p>\n\n\n\n<p><strong>\u7b2c\u4e09\u90e8\u5206\uff1a\u521b\u5efa\u56db\u4e2a\u4e13\u5bb6\u4ee3\u7406<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">planner_agent = AssistantAgent (\n              \"planner _agent\"\n              model_client=model_Client\uff0c\n              description=\u201d\u4e00\u4e2a\u80fd\u591f\u5e2e\u52a9\u89c4\u5212\u65c5\u884c\u7684\u52a9\u624b\u3002\u201c\uff0c\n              system_message=\u201d\u4f60\u662f\u4e00\u4e2a\u6709\u7528\u7684\u52a9\u624b\uff0c\u80fd\u591f\u6839\u636e\u7528\u6237\u7684\u8bf7\u6c42\u63d0\u4f9b\u65c5\u884c\u8ba1\u5212\u5efa\u8bae\u3002\u201c\n)<\/pre>\n\n\n\n<p>\u6211\u4eec\u521b\u5efa\u4e86\u7b2c\u4e00\u4e2a\u56e2\u961f\u6210\u5458\uff1a\u65c5\u884c\u89c4\u5212\u4e13\u5bb6\u3002<\/p>\n\n\n\n<ul>\n<li>planner_agent\uff1a\u8fd9\u662f\u4ee3\u7406\u7684\u540d\u5b57\uff0c\u7c7b\u4f3c\u7ed9\u56e2\u961f\u6210\u5458\u7684\u540d\u724c<\/li>\n\n\n\n<li>model_client=model_client\uff1a\u544a\u8bc9\u4ee3\u7406\u4f7f\u7528\u54ea\u4e2a&#8221;\u5927\u8111\u201d<\/li>\n\n\n\n<li>description\uff1a\u7b80\u77ed\u63cf\u8ff0\u8fd9\u4e2a\u4ee3\u7406\u7684\u5de5\u4f5c<\/li>\n\n\n\n<li>system_message\uff1a\u8fd9\u662f\u7ed9\u4ee3\u7406\u7684\u8be6\u7ec6\u6307\u4ee4\uff0c\u8fd9\u4e2a\u662f\u6700\u91cd\u8981\u7684\u4e86\uff0c\u5c31\u50cf\u5de5\u4f5c\u8bf4\u660e<\/li>\n<\/ul>\n\n\n\n<p>\u63a5\u7740\u6211\u4eec\u521b\u5efa\u4e86\u53e6\u5916\u4e09\u4e2a\u4ee3\u7406\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">local_agent = AssistantAgent (\n    \"local_agent\"\n    model_client=model_client,\n    description=\"\u4e00\u4e2a\u80fd\u591f\u63a8\u8350\u5f53\u5730\u6d3b\u52a8\u6216\u666f\u70b9\u7684\u672c\u5730\u52a9\u624b\u3002\u201c\n    system_message=\"\u4f60\u662f\u4e00\u4e2a\u6709\u7528\u7684\u52a9\u624b\uff0c\u80fd\u591f\u4e3a\u7528\u6237\u63a8\u8350\u6b63\u5b97\u6709\u8da3\u7684\u5f53\u5730\u6d3b\u52a8\u6216\u666f\u70b9.\n\uff09\n\nlanguage_agent = AssistantAgent (\n    \"language_agent\"\n    model_client=model_client,\n    description=\u201d\u4e00\u4e2a\u80fd\u591f\u63d0\u4f9b\u8bed\u8a00\u6280\u5de7\u7684\u52a9\u624b\u3002\u201d\uff0c\n    system_message=\"\u4f60\u662f\u4e00\u4e2a\u6709\u7528\u7684\u52a9\u624b\uff0c\u80fd\u591f\u5ba1\u67e5\u65c5\u884c\u8ba1\u5212\uff0c\u5c31\u5982\u4f55\u6700\u597d\u5730\u89e3\u51b3\u7ed9\u5b9a\u76ee\u7684\u5730\u7684\u8bed\u8a00\u95ee\u9898\u3002\n\uff09\n\ntravel_summary_agent = AssistantAgent\uff08\n    \"travel_summary_agent\"\n    model_client=model_client,\n    description=\"\u4e00\u4e2a\u80fd\u591f\u603b\u7ed3\u65c5\u884c\u8ba1\u5212\u7684\u52a9\u624b\u3002\u201d\uff0c\n    system_message=\u201d\u4f60\u662f\u4e00\u4e2a\u6709\u7528\u7684\u52a9\u624b\uff0c\u80fd\u591f\u63a5\u6536\u5176\u4ed6\u4ee3\u7406\u7684\u6240\u6709\u5efa\u8bae\u548c\u610f\u89c1\uff0c\u5e76\u63d0\u4f9b\u8be6\u7ec6\u7684\u6700\u7ec8\u65c5\u884c\u8ba1\u5212\u3002\n\uff09<\/pre>\n\n\n\n<p>\u63a5\u7740\u6211\u4eec\u521b\u5efa\u4e86\u53e6\u5916\u4e09\u4e2a\u4ee3\u7406\uff1a<\/p>\n\n\n\n<ul>\n<li>\u672c\u5730\u4e13\u5bb6\uff08local_agent\uff09\uff1a\u4e86\u89e3\u5f53\u5730\u597d\u73a9\u7684\u5730\u65b9\u548c\u6d3b\u52a8<\/li>\n\n\n\n<li>\u8bed\u8a00\u4e13\u5bb6\uff08language_agent\uff09\uff1a\u5e2e\u4f60\u5b66\u4f1a\u5728\u65c5\u884c\u5730\u5982\u4f55\u6c9f\u901a<\/li>\n\n\n\n<li>\u603b\u7ed3\u4e13\u5bb6\uff08travel_summary_agent\uff09\uff1a\u8d1f\u8d23\u6574\u5408\u6240\u6709\u5efa\u8bae\uff0c\u5236\u4f5c\u6700\u7ec8\u8ba1\u5212\u6bcf\u4e2a\u4ee3\u7406\u7684 system_message \u90fd\u4e0d\u540c\uff0c\u8fd9\u5c31\u50cf\u7ed9\u6bcf\u4e2a\u56e2\u961f\u6210\u5458\u4e0d\u540c\u7684\u5de5\u4f5c\u6307\u5357\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6bcf\u4e2a\u4ee3\u7406\u7684 system_message \u90fd\u4e0d\u540c\uff0c\u8fd9\u5c31\u50cf\u7ed9\u6bcf\u4e2a\u56e2\u961f\u6210\u5458\u4e0d\u540c\u7684\u5de5\u4f5c\u6307\u5357\u3002<\/p>\n\n\n\n<p><strong>\u7b2c\u56db\u90e8\u5206\uff1a\u8bbe\u7f6e\u4f1a\u8bae\u89c4\u5219<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">termination = TextMentionTermination \"TERMINATE\")\n\ngroup_chat = RoundRobinGroupChat (\n           [planner_agent, local_agent, language_agent, travel_summary_agent], \n           termination_condition=termination\n\uff09<\/pre>\n\n\n\n<p>\u8fd9\u90e8\u5206\u8bbe\u7f6e\u4e86\u56e2\u961f\u4f1a\u8bae\u7684\u89c4\u5219\uff1a<\/p>\n\n\n\n<p>TextMentionTermination\uff08\u201cTERMINATE\u201d\uff09\uff1a\u5f53\u4efb\u4f55\u4ee3\u7406\u8bf4\u51fa\u201cTERMINATE\u201d\u8fd9\u4e2a\u8bcd\u65f6\uff0c\u4f1a\u8bae\u5c31\u7ed3\u675f\u4e86\u3002\u8fd9\u544a\u8bc9\u7cfb\u7edf\u4ec0\u4e48\u65f6\u5019\u4efb\u52a1\u5b8c\u6210\u3002<\/p>\n\n\n\n<p>RoundRobinGroupChat\uff1a\u8fd9\u51b3\u5b9a\u4e86\u4ee3\u7406\u4eec\u600e\u4e48\u4ea4\u6d41\u3002\u201c\u8f6e\u6d41\u53d1\u8a00&#8221;\u7684\u65b9\u5f0f\u610f\u5473\u7740\u4ee3\u7406\u4eec\u4f1a\u6309\u7167\u5217\u8868\u4e2d\u7684\u987a\u5e8f\u4e00\u4e2a\u63a5\u4e00\u4e2a\u5730\u53d1\u8a00\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5148\u662f\u65c5\u884c\u89c4\u5212\u4e13\u5bb6<\/li>\n\n\n\n<li>\u7136\u540e\u662f\u672c\u5730\u4e13\u5bb6<\/li>\n\n\n\n<li>\u63a5\u7740\u662f\u8bed\u8a00\u4e13\u5bb6<\/li>\n\n\n\n<li>\u6700\u540e\u662f\u603b\u7ed3\u4e13\u5bb6<\/li>\n<\/ul>\n\n\n\n<p><strong>\u7b2c\u4e94\u90e8\u5206\uff1a\u542f\u52a8\u7cfb\u7edf<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sync def main():\n    await Console\uff08group_chat.run_stream\uff08task=\"\u8ba1\u5212\u4e00\u4e2a\u4e3a\u671f3\u5929\u7684\u7f8e\u56fd\u65c5\u884c\u3002\u201c\uff09\uff09\n    await model_client.close\uff08\uff09\n\nif _name_\" == \"_main_\"\n    asyncio.run(main())<\/pre>\n\n\n\n<p>\u8fd9\u662f\u542f\u52a8\u6574\u4e2a\u7cfb\u7edf\u7684\u90e8\u5206\uff1a<\/p>\n\n\n\n<ul>\n<li>1. \u521b\u5efa main\uff08\uff09\u51fd\u6570\uff0c\u4f7f\u7528async \u8868\u793a\u5b83\u662f\u5f02\u6b65\u7684\uff08\u53ef\u4ee5\u7b49\u5f85\u5176\u4ed6\u64cd\u4f5c\u5b8c\u6210\uff09<\/li>\n\n\n\n<li>2. group_chat.run_stream\uff08task=\u201d\u8ba1\u5212\u4e00\u4e2a\u4e3a\u671f3\u5929\u7684\u7f8e\u56fd\u65c5\u884c\u3002\u201c\uff09\u7ed9\u56e2\u961f\u4e00\u4e2a\u4efb\u52a1<\/li>\n\n\n\n<li>3. Console\uff08\uff09\u5c06\u6240\u6709\u5bf9\u8bdd\u663e\u793a\u5728\u5c4f\u5e55\u4e0a<\/li>\n\n\n\n<li>4.model_client.close\uff08\uff09\u5728\u5b8c\u6210\u540e\u5173\u95ed\u8fde\u63a5<\/li>\n\n\n\n<li>5. asyncio.run\uff08main\uff08\uff09\uff09\u542f\u52a8\u6574\u4e2a\u7a0b\u5e8f<\/li>\n<\/ul>\n\n\n\n<p><strong>\u8fd0\u884c\u7ed3\u679c<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"900\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-1024x900.png\" alt=\"\" class=\"wp-image-19218\" style=\"width:632px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-1024x900.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-300x264.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-768x675.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-1536x1350.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-830x729.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-230x202.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-350x308.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104-480x422.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-104.png 1732w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"1024\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-991x1024.png\" alt=\"\" class=\"wp-image-19220\" style=\"width:626px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-991x1024.png 991w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-290x300.png 290w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-768x793.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-1487x1536.png 1487w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-830x857.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-230x238.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-350x362.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106-480x496.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-106.png 1630w\" sizes=\"(max-width: 991px) 100vw, 991px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"707\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-1024x707.png\" alt=\"\" class=\"wp-image-19222\" style=\"width:624px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-1024x707.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-300x207.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-768x530.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-1536x1060.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-830x573.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-230x159.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-350x242.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108-480x331.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-108.png 1730w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>\u7cfb\u7edf\u5982\u4f55\u5de5\u4f5c\u7684\u6d41\u7a0b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u5f53\u4f60\u8fd0\u884c\u8fd9\u4e2a\u7a0b\u5e8f\u65f6\uff0c\u4ee5\u4e0b\u662f\u53d1\u751f\u7684\u4e8b\u60c5\uff1a\n\n1. \u5f00\u59cb\u4f1a\u8bae\uff1a\u7cfb\u7edf\u544a\u8bc9\u56e2\u961f\"\u8ba1\u5212\u4e00\u4e2a\u4e3a\u671f3\u5929\u7684\u7f8e\u56fd\u65c5\u884c\"\n\n\uff12. \u89c4\u5212\u4e13\u5bb6\u53d1\u8a00\uff1a\u9996\u5148\uff0c\u65c5\u884c\u89c4\u5212\u4e13\u5bb6\u4f1a\u521b\u5efa\u4e00\u4e2a\u57fa\u7840\u884c\u7a0b\uff0c\u4f8b\u5982\uff1a\n      \u7b2c1\u5929\uff1a\u62b5\u8fbe\u7ebd\u7ea6\uff0c\u53c2\u89c2\u81ea\u7531\u5973\u795e\u50cf\u548c\u65f6\u4ee3\u5e7f\u573a\n      \u7b2c2\u5929\uff1a\u53c2\u89c2\u535a\u7269\u9986\u548c\u4e2d\u592e\u516c\u56ed\n      \u7b2c3\u5929\uff1a\u8d2d\u7269\u548c\u79bb\u5f00\n\n3.\u672c\u5730\u4e13\u5bb6\u8865\u5145\uff1a\u672c\u5730\u4e13\u5bb6\u770b\u5230\u89c4\u5212\u540e\uff0c\u4f1a\u6dfb\u52a0\u5f53\u5730\u7279\u8272\u7684\u5efa\u8bae\uff1a\n      \u63a8\u8350\u6b63\u5b97\u7684\u7f8e\u98df\n      \u63d0\u4f9b\u66f4\u9690\u853d\u4f46\u6709\u8da3\u7684\u5730\u70b9\n      \u6dfb\u52a0\u672c\u5730\u6587\u5316\u4f53\u9a8c\n\n4.\u8bed\u8a00\u4e13\u5bb6\u8d21\u732e\uff1a\u8bed\u8a00\u4e13\u5bb6\u4f1a\u63d0\u4f9b\u5728\u7f8e\u56fd\u65c5\u884c\u7684\u6c9f\u901a\u63d0\u793a\uff1a\n     \u7f8e\u56fd\u7684\u793c\u4eea\u4e60\u60ef\n     \u5c0f\u8d39\u6587\u5316\u6ce8\u610f\u4e8b\u9879\n     \u6709\u7528\u7684\u7f8e\u56fd\u4fda\u8bed\u8868\u8fbe\n\n5.\u603b\u7ed3\u4e13\u5bb6\u6574\u5408\uff1a\u6700\u540e\uff0c\u603b\u7ed3\u4e13\u5bb6\u4f1a\u628a\u6240\u6709\u5efa\u8bae\u6574\u5408\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u65c5\u884c\u8ba1\u5212\uff0c\u5e76\u5728\u5b8c\u6210\u540e\u8bf4\"TERMINATE\"\u7ed3\u675f\u4f1a\u8bae\n\n\u6bcf\u4e2a\u4ee3\u7406\u90fd\u80fd\u770b\u5230\u524d\u9762\u4ee3\u7406\u8bf4\u7684\u8bdd\uff0c\u6240\u4ee5\u4ed6\u4eec\u53ef\u4ee5\u4e92\u76f8\u8865\u5145\uff0c\u4e00\u8d77\u521b\u5efa\u4e00\u4e2a\u6bd4\u5355\u4e2aAI\u80fd\u505a\u51fa\u7684\u66f4\u5168\u9762\u7684\u8ba1\u5212\u3002<\/pre>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u4e3a\u4ec0\u4e48\u8fd9\u79cd\u65b9\u6cd5\u5f88\u5f3a\u5927\uff1f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u8fd9\u79cd\u591a\u4ee3\u7406\u534f\u4f5c\u6709\u51e0\u4e2a\u91cd\u8981\u4f18\u52bf\uff1a<\/p>\n\n\n\n<ul>\n<li>1. \u4e13\u4e1a\u5316\uff1a\u6bcf\u4e2a\u4ee3\u7406\u4e13\u6ce8\u4e8e\u81ea\u5df1\u6700\u64c5\u957f\u7684\u9886\u57df\uff0c\u5c31\u50cf\u4e13\u4e1a\u56e2\u961f\u4e00\u6837<\/li>\n\n\n\n<li>2. \u77e5\u8bc6\u4e92\u8865\uff1a\u4ee3\u7406\u4eec\u4e92\u76f8\u5f25\u8865\u77e5\u8bc6\u7a7a\u767d<\/li>\n\n\n\n<li>3. \u6709\u5e8f\u6d41\u7a0b\uff1a\u4ece\u57fa\u7840\u89c4\u5212\u5230\u672c\u5730\u77e5\u8bc6\uff0c\u518d\u5230\u8bed\u8a00\u63d0\u793a\uff0c\u6700\u540e\u6574\u5408\u6210\u5b8c\u6574\u8ba1\u5212<\/li>\n\n\n\n<li>4. \u6e05\u6670\u7684\u7ec8\u70b9\uff1a\u7cfb\u7edf\u77e5\u9053\u4f55\u65f6\u4efb\u52a1\u5b8c\u6210\uff08\u770b\u5230&#8221;TERMINATE&#8221;\uff09<\/li>\n<\/ul>\n\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>\u5982\u4f55\u4fee\u6539\u7528\u4e8e\u5176\u4ed6\u76ee\u7684\uff1f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5982\u679c\u4f60\u60f3\u6539\u53d8\u8fd9\u4e2a\u7cfb\u7edf\uff0c\u53ef\u4ee5\uff1a<\/p>\n\n\n\n<ul>\n<li>1. \u4fee\u6539\u4efb\u52a1\uff1a\u628a\u201c\u8ba1\u5212\u4e00\u4e2a\u4e3a\u671f3\u5929\u7684\u7f8e\u56fd\u65c5\u884c\u3002\u201c\u6539\u4e3a\u4efb\u4f55\u4f60\u60f3\u8981\u7684\u4efb\u52a1<\/li>\n\n\n\n<li>2. \u66f4\u6539\u4ee3\u7406\u89d2\u8272\uff1a\u4fee\u6539\u6bcf\u4e2a\u4ee3\u7406\u7684 system_message \u6765\u6539\u53d8\u5176\u4e13\u957f<\/li>\n\n\n\n<li>3. \u589e\u51cf\u4ee3\u7406\u6570\u91cf\uff1a\u6839\u636e\u9700\u8981\u6dfb\u52a0\u6216\u51cf\u5c11\u4e13\u5bb6<\/li>\n\n\n\n<li>4. \u6362\u7528\u4e0d\u540c\u6a21\u578b\uff1a\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684AI\u6a21\u578b\uff0c\u5982 gpt-3.5-turbo \u6765\u8282\u7701\u6210\u672c<\/li>\n<\/ul>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u5b9e\u7528\u5e94\u7528\u793a\u4f8b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u8fd9\u79cd\u591a\u4ee3\u7406\u7cfb\u7edf\u53ef\u4ee5\u7528\u4e8e\uff1a<\/p>\n\n\n\n<ul>\n<li>1.\u5b66\u4e60\u8ba1\u5212\uff1a\u4e00\u4e2a\u4e13\u5bb6\u89c4\u5212\u8bfe\u7a0b\uff0c\u4e00\u4e2a\u4e13\u5bb6\u63d0\u4f9b\u8d44\u6e90\uff0c\u4e00\u4e2a\u4e13\u5bb6\u8bbe\u8ba1\u6d4b\u8bd5\uff0c\u4e00\u4e2a\u6574\u5408\u6210\u5b8c\u6574\u5b66\u4e60\u8ba1\u5212<\/li>\n\n\n\n<li>2.\u4ea7\u54c1\u5f00\u53d1\uff1a\u5e02\u573a\u4e13\u5bb6\u3001\u6280\u672f\u4e13\u5bb6\u3001\u8d22\u52a1\u4e13\u5bb6\u548c\u9879\u76ee\u4e13\u5bb6\u5171\u540c\u5de5\u4f5c<\/li>\n\n\n\n<li>3.\u5185\u5bb9\u521b\u4f5c\uff1a\u521b\u610f\u4e13\u5bb6\u3001\u7814\u7a76\u4e13\u5bb6\u3001\u7ed3\u6784\u4e13\u5bb6\u548c\u7f16\u8f91\u4e13\u5bb6\u5408\u4f5c\u521b\u4f5c\u5185\u5bb9<\/li>\n<\/ul>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u8fd0\u884c\u8fd9\u4e2a\u4ee3\u7801\u9700\u8981\u4ec0\u4e48\uff1f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u8981\u8fd0\u884c\u8fd9\u4e2a\u4ee3\u7801\uff0c\u4f60\u9700\u8981\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5b89\u88c5\u5fc5\u8981\u7684\u5e93\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pip install -U \"autogen-agentchat\" \npip install \"autogen-ext [openai]\"\npip install python-dotenv<\/pre>\n\n\n\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a.env \u6587\u4ef6\uff0c\u91cc\u9762\u5305\u542b\u4f60\u7684OpenAI API\u5bc6\u94a5\uff1aOPENAI_API_KEY-\u4f60\u7684\u5bc6\u94a5<\/li>\n\n\n\n<li>\u8fd0\u884c\u4ee3\u7801\uff1apython \u4f60\u7684\u6587\u4ef6\u540d.py<\/li>\n<\/ul>\n\n\n\n<p>\u8bb0\u4f4f\uff0c\u4f7f\u7528API\u4f1a\u4ea7\u751f\u8d39\u7528\uff0c\u56e0\u4e3a\u4f60\u662f\u5728\u4f7f\u7528OpenAI\u7684\u670d\u52a1<\/p>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p><strong>\u7b80\u5355\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u60f3\u8c61\u8fd9\u6bb5\u4ee3\u7801\u5c31\u50cf\u7ec4\u5efa\u4e86\u4e00\u4e2a\u65c5\u884c\u89c4\u5212\u56e2\u961f\uff1a<\/p>\n\n\n\n<ul>\n<li>\u4e00\u4e2a\u4eba\u64c5\u957f\u93ca\u4f53\u89c4\u5212<\/li>\n\n\n\n<li>\u4e00\u4e2a\u4eba\u4e86\u89e3\u5f53\u5730\u7684\u597d\u5730\u65b9<\/li>\n\n\n\n<li>\u4e00\u4e2a\u4eba\u5e2e\u4f60\u5b66\u5f53\u5730\u8bed\u8a00<\/li>\n\n\n\n<li>\u4e00\u4e2a\u4eba\u628a\u6240\u6709\u70b9\u5b50\u6574\u5408\u6210\u4e00\u4e2a\u5b8c\u7f8e\u8ba1\u5212<br>\u4ed6\u4eec\u8f6e\u6d41\u53d1\u8a00\uff0c\u6bcf\u4e2a\u4eba\u90fd\u80fd\u770b\u5230\u524d\u9762\u7684\u4eba\u8bf4\u4e86\u4ec0\u4e48\uff0c\u6700\u540e\u4e00\u8d77\u521b\u9020\u51fa\u4e00\u4e2a\u6bd4\u5355\u4e2aAI\u505a\u5f97\u66f4\u597d\u7684\u65c5\u884c\u8ba1\u5212\u3002\u8fd9\u79cd&#8221;\u591a\u4eba\u534f\u4f5c\u201d\u7684\u65b9\u6cd5\u53ef\u4ee5\u5e94\u7528\u5230\u51e0\u4e4e\u4efb\u4f55\u9700\u8981\u591a\u79cd\u4e13\u4e1a\u77e5\u8bc6\u7684\u4efb\u52a1\u4e2d\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u60f3\u8c61\u4e00\u4e0b\uff0c\u4f60\u6709\u4e00\u652f\u56e2\u961f\uff0c\u6bcf\u4e2a\u6210\u5458\u90fd\u5f88\u64c5\u957f\u505a\u4e0d\u540c\u7684\u4e8b\u60c5\u3002\u4e00\u4e2a\u4eba\u64c5\u957f\u89c4\u5212\u884c\u7a0b\uff0c\u4e00\u4e2a\u4eba\u4e86\u89e3\u5f53\u5730\u6709\u8da3\u7684\u5730\u65b9\uff0c\u4e00\u4e2a\u4eba\u4f1a\u6559 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/19212"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19212"}],"version-history":[{"count":7,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/19212\/revisions"}],"predecessor-version":[{"id":19225,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/19212\/revisions\/19225"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}