{"id":3610,"date":"2026-08-16T12:49:34","date_gmt":"2026-08-16T04:49:34","guid":{"rendered":"http:\/\/ai.zhousir.top\/?p=3610"},"modified":"2026-08-16T15:55:10","modified_gmt":"2026-08-16T07:55:10","slug":"function-calling%e8%ae%a9%e5%a4%a7%e6%a8%a1%e5%9e%8b%e4%bb%8e%e4%bc%9a%e8%af%b4%e5%88%b0%e4%bc%9a%e5%b9%b2","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=3610","title":{"rendered":"Function-Calling\u8ba9\u5927\u6a21\u578b\u4ece\u4f1a\u8bf4\u5230\u4f1a\u5e72"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; word-break: break-word; overflow-wrap: break-word; color: #000000; font-size: 16px; line-height: 1.75; caret-color: #000000;\" data-provider=\"WenYan\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u5f15\u8a00<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u4e0a\u5468\u641e\u5b9a\u4e86\u591a\u8f6e\u5bf9\u8bdd\uff0c\u804a\u5929\u673a\u5668\u4eba\u8dd1\u5f97\u6709\u6a21\u6709\u6837\u3002\u8fd9\u5468\u4e00\u4e0a\u73ed\uff0c\u8001\u677f\u53c8\u4e22\u6765\u4e00\u4e2a\u9700\u6c42\uff1a<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u54b1\u4eec\u7684 AI \u5ba2\u670d\u80fd\u4e0d\u80fd\u67e5\u8ba2\u5355\u72b6\u6001\uff1f\u7528\u6237\u95ee&#8217;\u6211\u7684\u8ba2\u5355\u5230\u54ea\u4e86&#8217;\uff0cAI \u76f4\u63a5\u56de\u7b54\uff0c\u522b\u8ba9\u7528\u6237\u81ea\u5df1\u53bb\u7cfb\u7edf\u91cc\u7ffb\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u5fc3\u60f3\u8fd9\u8fd8\u4e0d\u7b80\u5355\uff1f\u7ed9 AI \u52a0\u6761 system \u6d88\u606f\uff1a&#8221;\u4f60\u53ef\u4ee5\u67e5\u8be2\u8ba2\u5355\u72b6\u6001&#8221;\u3002\u7136\u540e\u6d4b\u8bd5\u2014\u2014<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u7528\u6237\u95ee\uff1a&#8221;\u6211\u7684\u8ba2\u5355 88899 \u5230\u54ea\u4e86\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">AI \u56de\u7b54\uff1a&#8221;\u60a8\u7684\u8ba2\u5355 88899 \u5df2\u53d1\u8d27\uff0c\u9884\u8ba1\u660e\u5929\u9001\u8fbe\uff0c\u5f53\u524d\u5728\u6210\u90fd\u8f6c\u8fd0\u4e2d\u5fc3\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u6123\u4e86\u3002\u8ba2\u5355\u7cfb\u7edf\u91cc\u6839\u672c\u6ca1\u6709\u8fd9\u4e2a\u8ba2\u5355\u53f7\u3002AI \u4e00\u672c\u6b63\u7ecf\u5730\u7f16\u4e86\u4e00\u4e2a\u7b54\u6848\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u4ed6\u53bb\u627e\u8001\u5f20\uff1a&#8221;AI \u53c8\u4e0d\u8001\u5b9e\u4e86\uff0c\u6211\u8ba9\u5b83\u67e5\u8ba2\u5355\uff0c\u5b83\u76f4\u63a5\u7f16\u4e86\u4e2a\u5047\u7684\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u8fd9\u53eb<strong style=\"color: #333333; font-weight: bold;\">\u5e7b\u89c9<\/strong>\u3002\u5927\u6a21\u578b\u7684\u8bad\u7ec3\u6570\u636e\u91cc\u6ca1\u6709\u4f60\u7684\u8ba2\u5355\u7cfb\u7edf\uff0c\u5b83\u4e0d\u77e5\u9053\u771f\u5b9e\u6570\u636e\uff0c\u5c31\u53ea\u80fd\u7f16\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u90a3\u600e\u4e48\u529e\uff1f\u8ba9\u5b83\u8fde\u6211\u7684\u6570\u636e\u5e93\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5927\u6a21\u578b\u8fde\u4e0d\u4e86\u4f60\u7684\u6570\u636e\u5e93\u3002\u4f46\u6709\u4e2a\u529e\u6cd5\u2014\u2014<strong style=\"color: #333333; font-weight: bold;\">Function Calling<\/strong>\u3002\u8ba9 AI \u77e5\u9053&#8217;\u6709\u4e2a\u67e5\u8ba2\u5355\u7684\u51fd\u6570\u53ef\u4ee5\u8c03&#8217;\uff0c\u5b83\u9700\u8981\u67e5\u7684\u65f6\u5019\u5c31\u544a\u8bc9\u4f60&#8217;\u8c03\u8fd9\u4e2a\u51fd\u6570\uff0c\u53c2\u6570\u662f\u8ba2\u5355\u53f7 88899&#8217;\uff0c\u7136\u540e\u4f60\u7684\u4ee3\u7801\u53bb\u771f\u6b63\u67e5\uff0c\u628a\u7ed3\u679c\u5582\u7ed9\u5b83\uff0c\u5b83\u518d\u57fa\u4e8e\u771f\u5b9e\u6570\u636e\u56de\u7b54\u7528\u6237\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u95ee\uff1a&#8221;\u6240\u4ee5 AI \u81ea\u5df1\u4e0d\u67e5\uff0c\u662f\u8ba9\u6211\u53bb\u67e5\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5bf9\u3002<strong style=\"color: #333333; font-weight: bold;\">AI \u53ea\u662f\u70b9\u83dc\uff0c\u4f60\u7684\u4ee3\u7801\u624d\u662f\u53a8\u623f\u3002<\/strong> \u4eca\u5929\u5c31\u5e26\u4f60\u641e\u61c2\u8fd9\u4e2a\u3002&#8221;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u6838\u5fc3\u8ba4\u77e5\uff1a\u6a21\u578b\u4e0d\u6267\u884c\u51fd\u6570\uff0c\u5b83\u53ea\u662f&#8221;\u70b9\u83dc&#8221;<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u5728\u767d\u677f\u4e0a\u753b\u4e86\u4e2a\u9910\u5385\u7684\u6d41\u7a0b\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">\u7528\u6237\uff1a\u300c\u6765\u4e00\u4efd\u5bab\u4fdd\u9e21\u4e01\u300d\n\u670d\u52a1\u5458\uff08\u6a21\u578b\uff09\uff1a\u300c\u597d\u7684\uff0c\u53a8\u623f\u8bf7\u505a\u5bab\u4fdd\u9e21\u4e01\u4e00\u4efd\u300d\uff08tool_call\uff09\n\u53a8\u623f\uff08\u4f60\u7684\u4ee3\u7801\uff09\uff1a\u771f\u6b63\u7092\u83dc\uff0c\u7aef\u51fa\u83dc\u54c1\uff08function result\uff09\n\u670d\u52a1\u5458\uff08\u6a21\u578b\uff09\uff1a\u300c\u60a8\u7684\u5bab\u4fdd\u9e21\u4e01\u6765\u4e86\uff0c\u8bf7\u6162\u7528\u300d\uff08\u6700\u7ec8\u56de\u7b54\uff09\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u7528\u6237\u662f\u987e\u5ba2\uff0c\u5927\u6a21\u578b\u662f\u670d\u52a1\u5458\uff0c\u4f60\u7684\u4ee3\u7801\u662f\u53a8\u623f\u3002&#8221;\u8001\u5f20\u8bf4\uff0c&#8221;\u670d\u52a1\u5458\u4e0d\u4f1a\u7092\u83dc\uff0c\u4f46\u4ed6\u77e5\u9053\u53a8\u623f\u6709\u4ec0\u4e48\u83dc\u3001\u6bcf\u9053\u83dc\u9700\u8981\u4ec0\u4e48\u98df\u6750\u3002\u4ed6\u8d1f\u8d23\u628a\u7528\u6237\u7684\u9700\u6c42\u7ffb\u8bd1\u6210&#8217;\u53a8\u623f\u542c\u5f97\u61c2\u7684\u6307\u4ee4&#8217;\uff0c\u53a8\u623f\u505a\u5b8c\u83dc\u518d\u7aef\u7ed9\u670d\u52a1\u5458\uff0c\u670d\u52a1\u5458\u6700\u540e\u7ed9\u7528\u6237\u4e0a\u83dc\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u95ee\uff1a&#8221;\u5f88\u591a\u4eba\u4ee5\u4e3a\u5927\u6a21\u578b\u80fd\u76f4\u63a5\u8fd0\u884c\u6211\u7684 Python \u51fd\u6570\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u662f\u6700\u5e38\u89c1\u7684\u8bef\u89e3\u3002&#8221;\u8001\u5f20\u6447\u5934\uff0c&#8221;\u5927\u6a21\u578b\u4ece\u5934\u5230\u5c3e<strong style=\"color: #333333; font-weight: bold;\">\u4e0d\u6267\u884c\u4efb\u4f55\u4ee3\u7801<\/strong>\u3002\u5b83\u53ea\u505a\u4e00\u4ef6\u4e8b\u2014\u2014\u8f93\u51fa\u4e00\u4e2a\u7ed3\u6784\u5316\u7684 JSON\uff0c\u544a\u8bc9\u4f60&#8217;\u5e94\u8be5\u8c03\u54ea\u4e2a\u51fd\u6570\u3001\u53c2\u6570\u662f\u4ec0\u4e48&#8217;\u3002\u771f\u6b63\u6267\u884c\u51fd\u6570\u7684\u662f\u4f60\u7684 Python \u7a0b\u5e8f\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5206\u5de5\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<table style=\"display: inline-block !important; width: auto; max-width: 100%; overflow: auto; border-spacing: 0px; border-collapse: collapse; margin: 1rem 0px;\">\n<thead style=\"background: #fff9eb; color: #333333; text-align: left;\">\n<tr>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u89d2\u8272<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u505a\u4ec0\u4e48<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5f00\u53d1\u8005\uff08\u4f60\uff09<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5b9a\u4e49\u5de5\u5177\u5217\u8868\uff08\u83dc\u5355\uff09\u3001\u5b9e\u73b0\u771f\u6b63\u7684\u51fd\u6570\u3001\u7f16\u6392\u5bf9\u8bdd\u5faa\u73af<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5927\u6a21\u578b<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5206\u6790\u7528\u6237\u610f\u56fe\uff0c\u51b3\u5b9a\u8c03\u7528\u54ea\u4e2a\u5de5\u5177\uff0c\u8f93\u51fa\u7ed3\u6784\u5316\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u7528\u6237<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u7528\u81ea\u7136\u8bed\u8a00\u63d0\u95ee<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u660e\u767d\u4e86\u3002&#8221;\u5c0f\u660e\u8bf4\uff0c&#8221;\u5927\u6a21\u578b\u662f\u4e2a&#8217;\u7ffb\u8bd1\u5b98&#8217;\uff0c\u628a\u7528\u6237\u7684\u81ea\u7136\u8bed\u8a00\u7ffb\u8bd1\u6210\u51fd\u6570\u8c03\u7528\u6307\u4ee4\u3002\u771f\u6b63\u7684\u6d3b\u8fd8\u662f\u6211\u5e72\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8bf4\u5230\u70b9\u5b50\u4e0a\u4e86\u3002&#8221;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u4e24\u8f6e\u5bf9\u8bdd\uff1aFunction Calling \u7684\u5b8c\u6574\u6d41\u7a0b<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u666e\u901a\u5bf9\u8bdd\u662f\u4e00\u8f6e\u2014\u2014\u4f60\u95ee\uff0cAI \u7b54\u3002Function Calling \u81f3\u5c11<strong style=\"color: #333333; font-weight: bold;\">\u4e24\u8f6e<\/strong>\u2014\u2014\u7b2c\u4e00\u8f6e AI \u51b3\u5b9a\u7528\u4ec0\u4e48\u5de5\u5177\uff0c\u7b2c\u4e8c\u8f6e AI \u57fa\u4e8e\u5de5\u5177\u7ed3\u679c\u751f\u6210\u56de\u7b54\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u4ed6\u5728\u767d\u677f\u4e0a\u753b\u4e86\u5f20\u5b8c\u6574\u7684\u6d41\u7a0b\u56fe\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">\u7528\u6237\uff1a\"\u4eca\u5929\u5317\u4eac\u5929\u6c14\u600e\u4e48\u6837\uff1f\"\n    \u2502\n    \u25bc\n\u250c\u2500 \u7b2c1\u6b21 API \u8c03\u7528 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  \u4f60\u53d1\u7ed9\u6a21\u578b\uff1a                  \u2502\n\u2502  messages = [\u7528\u6237\u95ee\u9898]             \u2502\n\u2502  tools = [get_weather \u51fd\u6570\u5b9a\u4e49]        \u2502\n\u2502                         \u2502\n\u2502  \u6a21\u578b\u8fd4\u56de\uff1a                  \u2502\n\u2502  tool_calls: get_weather(location=\"\u5317\u4eac\")   \u2502\n\u2502  \uff08\u6ce8\u610f\uff1a\u6b64\u65f6\u6a21\u578b\u6ca1\u6709\u751f\u6210\u6700\u7ec8\u56de\u7b54\uff09      \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n    \u2502\n    \u25bc\n\u250c\u2500 \u4f60\u7684\u4ee3\u7801\u6267\u884c\u51fd\u6570 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  \u8c03\u7528 get_weather(\"\u5317\u4eac\")            \u2502\n\u2502  \u8fd4\u56de\uff1a{\"weather\": \"25\u00b0C \u6674\"}          \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n    \u2502\n    \u25bc\n\u250c\u2500 \u7b2c2\u6b21 API \u8c03\u7528 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  \u4f60\u53d1\u7ed9\u6a21\u578b\uff1a                  \u2502\n\u2502  messages = [                \u2502\n\u2502    \u7528\u6237\u95ee\u9898,                  \u2502\n\u2502    \u6a21\u578b\u7684 tool_calls \u8bf7\u6c42,          \u2502\n\u2502    \u5de5\u5177\u8fd4\u56de\u7ed3\u679c\uff08role: \"tool\"\uff09         \u2502\n\u2502  ]                       \u2502\n\u2502                         \u2502\n\u2502  \u6a21\u578b\u8fd4\u56de\uff1a                  \u2502\n\u2502  \"\u5317\u4eac\u4eca\u5929\u6674\u5929\uff0c25\u00b0C\uff0c\u9002\u5408\u5916\u51fa\u3002\"       \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n    \u2502\n    \u25bc\n\u6700\u7ec8\u56de\u7b54\u5c55\u793a\u7ed9\u7528\u6237\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u770b\u5230\u4e86\u6ca1\uff1f&#8221;\u8001\u5f20\u8bf4\uff0c&#8221;\u7b2c\u4e00\u6b21\u8c03\u7528\u6a21\u578b<strong style=\"color: #333333; font-weight: bold;\">\u4e0d\u56de\u7b54\u95ee\u9898<\/strong>\uff0c\u800c\u662f\u544a\u8bc9\u4f60&#8217;\u6211\u9700\u8981\u8c03 get_weather \u8fd9\u4e2a\u51fd\u6570\uff0c\u53c2\u6570\u662f\u5317\u4eac&#8217;\u3002\u4f60\u6267\u884c\u5b8c\u51fd\u6570\uff0c\u628a\u7ed3\u679c\u585e\u56de messages \u5217\u8868\uff0c\u7b2c\u4e8c\u6b21\u8c03\u7528\u6a21\u578b\u624d\u57fa\u4e8e\u771f\u5b9e\u6570\u636e\u751f\u6210\u6700\u7ec8\u56de\u7b54\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u95ee\uff1a&#8221;\u6240\u4ee5 messages \u5217\u8868\u5728\u8fd9\u4e24\u8f6e\u91cc\u4e00\u76f4\u5728\u53d8\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5bf9\u3002<strong style=\"color: #333333; font-weight: bold;\">messages \u662f\u7d2f\u79ef\u7684<\/strong>\u2014\u2014\u7b2c\u4e00\u6b21\u8c03\u7528\u540e\uff0c\u4f60\u8981\u628a\u6a21\u578b\u7684 tool_calls \u8bf7\u6c42\u8ffd\u52a0\u8fdb\u53bb\uff1b\u51fd\u6570\u6267\u884c\u5b8c\uff0c\u518d\u628a tool \u7ed3\u679c\u8ffd\u52a0\u8fdb\u53bb\u3002\u7b2c\u4e8c\u6b21\u8c03\u7528\u65f6\uff0cmessages \u5217\u8868\u6bd4\u7b2c\u4e00\u6b21\u591a\u4e86\u4e24\u6761\u6d88\u606f\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u5c31\u662f\u4e0a\u6b21\u8bb2\u591a\u8f6e\u5bf9\u8bdd\u65f6\u8bf4\u7684&#8217;\u6d88\u606f\u5217\u8868\u662f\u7d2f\u79ef\u7684&#8217;\u2014\u2014Function Calling \u53ea\u662f\u591a\u4e86\u4e00\u79cd <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool<\/code> \u89d2\u8272\u7684\u6d88\u606f\u800c\u5df2\u3002&#8221;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u5de5\u5177\u5b9a\u4e49\uff1a\u7ed9\u6a21\u578b\u4e00\u4efd&#8221;\u83dc\u5355&#8221;<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u6a21\u578b\u8981\u77e5\u9053\u6709\u54ea\u4e9b\u5de5\u5177\u53ef\u7528\uff0c\u4f60\u5f97\u63d0\u524d\u544a\u8bc9\u5b83\u3002\u8fd9\u5c31\u662f tools \u5b9a\u4e49\u2014\u2014\u7528 JSON Schema \u683c\u5f0f\u63cf\u8ff0\u6bcf\u4e2a\u51fd\u6570\u7684\u540d\u5b57\u3001\u7528\u9014\u548c\u53c2\u6570\u3002&#8221;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">tools = [\n  {\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>: {\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>,       <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u51fd\u6570\u540d\uff0c\u5fc5\u987b\u4e0e\u5b9e\u9645\u51fd\u6570\u4e00\u81f4<\/span>\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"description\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u83b7\u53d6\u6307\u5b9a\u57ce\u5e02\u5f53\u524d\u7684\u5929\u6c14\u60c5\u51b5\"<\/span>,  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u6a21\u578b\u9760\u5b83\u5224\u65ad\u4f55\u65f6\u8c03\u7528<\/span>\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"parameters\"<\/span>: {              <span class=\"hljs-comment\" style=\"color: #657b83;\"># JSON Schema \u63cf\u8ff0\u53c2\u6570<\/span>\n        <span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"object\"<\/span>,\n        <span class=\"hljs-string\" style=\"color: #859900;\">\"properties\"<\/span>: {\n          <span class=\"hljs-string\" style=\"color: #859900;\">\"location\"<\/span>: {\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"string\"<\/span>,\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"description\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u57ce\u5e02\u540d\u79f0\uff0c\u4f8b\u5982\uff1a\u5317\u4eac\"<\/span>\n          },\n          <span class=\"hljs-string\" style=\"color: #859900;\">\"unit\"<\/span>: {\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"string\"<\/span>,\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"enum\"<\/span>: [<span class=\"hljs-string\" style=\"color: #859900;\">\"celsius\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"fahrenheit\"<\/span>],\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"description\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u6e29\u5ea6\u5355\u4f4d\"<\/span>\n          }\n        },\n        <span class=\"hljs-string\" style=\"color: #859900;\">\"required\"<\/span>: [<span class=\"hljs-string\" style=\"color: #859900;\">\"location\"<\/span>]        <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u5fc5\u586b\u53c2\u6570<\/span>\n      }\n    }\n  }\n]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u9010\u5b57\u6bb5\u89e3\u91ca\uff1a<\/p>\n<ol style=\"margin: 8px 0px; padding-left: 28px; list-style: outside decimal;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">type: \"function\"<\/code><\/strong> \u2014 \u56fa\u5b9a\u5199\u6cd5\uff0c\u76ee\u524d\u53ea\u6709\u8fd9\u4e00\u79cd\u7c7b\u578b<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">name<\/code><\/strong> \u2014 \u51fd\u6570\u540d\uff0c\u5fc5\u987b\u548c\u4f60 Python \u4ee3\u7801\u91cc\u7684\u51fd\u6570\u540d<strong style=\"color: #333333; font-weight: bold;\">\u5b8c\u5168\u4e00\u81f4<\/strong><\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">description<\/code><\/strong> \u2014 \u6700\u5173\u952e\u5b57\u6bb5\u3002\u6a21\u578b\u9760\u8fd9\u6bb5\u8bdd\u5224\u65ad&#8221;\u4ec0\u4e48\u65f6\u5019\u8be5\u8c03\u8fd9\u4e2a\u51fd\u6570&#8221;<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">parameters<\/code><\/strong> \u2014 JSON Schema \u683c\u5f0f\uff0c\u63cf\u8ff0\u53c2\u6570\u7684\u7c7b\u578b\u3001\u679a\u4e3e\u503c\u3001\u662f\u5426\u5fc5\u586b<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">required<\/code><\/strong> \u2014 \u54ea\u4e9b\u53c2\u6570\u4e0d\u80fd\u7701\u7565<\/section>\n<\/li>\n<\/ol>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u91cd\u70b9\u8bf4\u8fd9\u4e2a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">description<\/code>\u3002&#8221;\u8001\u5f20\u6572\u4e86\u6572\u767d\u677f\uff0c&#8221;\u5f88\u591a\u4eba\u5199 description \u5c31\u4e00\u53e5&#8217;\u83b7\u53d6\u5929\u6c14&#8217;\u2014\u2014\u592a\u6a21\u7cca\u4e86\u3002\u6a21\u578b\u4e0d\u77e5\u9053\u4ec0\u4e48\u573a\u666f\u8be5\u8c03\u3002\u5e94\u8be5\u5199\u6e05\u695a<strong style=\"color: #333333; font-weight: bold;\">\u505a\u4ec0\u4e48 + \u4ec0\u4e48\u65f6\u5019\u7528<\/strong>\u3002&#8221;<\/p>\n<table style=\"display: inline-block !important; width: auto; max-width: 100%; overflow: auto; border-spacing: 0px; border-collapse: collapse; margin: 1rem 0px;\">\n<thead style=\"background: #fff9eb; color: #333333; text-align: left;\">\n<tr>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u5199\u6cd5<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u6548\u679c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\"><code>\"\u83b7\u53d6\u5929\u6c14\"<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u592a\u6a21\u7cca\uff0c\u6a21\u578b\u53ef\u80fd\u5728\u8be5\u8c03\u65f6\u4e0d\u8c03\uff0c\u4e0d\u8be5\u8c03\u65f6\u4e71\u8c03<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\"><code>\"\u83b7\u53d6\u6307\u5b9a\u57ce\u5e02\u5f53\u524d\u7684\u5929\u6c14\u60c5\u51b5\"<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u6e05\u6670\uff0c\u6a21\u578b\u77e5\u9053\u7528\u6237\u95ee\u5929\u6c14\u65f6\u8be5\u8c03<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\"><code>\"\u67e5\u8be2\u5929\u6c14\u4fe1\u606f\uff0c\u652f\u6301\u4e2d\u56fd\u57ce\u5e02\uff0c\u8fd4\u56de\u5b9e\u65f6\u6570\u636e\"<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u66f4\u597d\uff0c\u8fde\u9002\u7528\u8303\u56f4\u90fd\u8bf4\u4e86<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd8\u6709\u53c2\u6570\u7684 description \u4e5f\u8981\u5199\u597d\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">location<\/code> \u5199&#8217;\u57ce\u5e02\u540d\u79f0&#8217;\u4e0d\u5982\u5199&#8217;\u57ce\u5e02\u540d\u79f0\uff0c\u4f8b\u5982\uff1a\u5317\u4eac&#8217;\u2014\u2014\u7ed9\u4e2a\u793a\u4f8b\u503c\uff0c\u6a21\u578b\u63d0\u53d6\u53c2\u6570\u7684\u51c6\u786e\u7387\u4f1a\u9ad8\u5f88\u591a\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u95ee\uff1a&#8221;\u90a3\u5982\u679c\u6211\u6709\u591a\u4e2a\u5de5\u5177\u5462\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5f80 tools \u5217\u8868\u91cc\u52a0\u5c31\u884c\u3002\u6a21\u578b\u4f1a\u6839\u636e\u7528\u6237\u7684\u95ee\u9898\uff0c\u81ea\u5df1\u5224\u65ad\u8be5\u8c03\u54ea\u4e2a\u2014\u2014\u6216\u8005\u4e00\u4e2a\u90fd\u4e0d\u8c03\u3002&#8221;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">tools = [\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>, ...}},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"query_order_status\"<\/span>, ...}},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"search_product\"<\/span>, ...}},\n]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5c31\u50cf\u83dc\u5355\u4e0a\u6709\u591a\u9053\u83dc\uff0c\u670d\u52a1\u5458\u6839\u636e\u987e\u5ba2\u7684\u9700\u6c42\u51b3\u5b9a\u4f20\u54ea\u5f20\u5355\u5b50\u5230\u53a8\u623f\u3002&#8221;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u6838\u5fc3\u4ee3\u7801\uff1a\u4e24\u8f6e\u8c03\u7528\u7684\u5b8c\u6574\u5b9e\u73b0<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u6982\u5ff5\u8bb2\u5b8c\u4e86\uff0c\u4e0a\u4ee3\u7801\u3002\u8fd9\u662f\u6700\u5c0f\u53ef\u8fd0\u884c\u7248\u672c\uff0c\u53bb\u6389\u6ce8\u91ca\u4e0d\u5230 40 \u884c\u3002&#8221;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\"><span class=\"hljs-keyword\" style=\"color: #6c71c4;\">import<\/span> json\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">from<\/span> config <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">import<\/span> MODEL, get_client\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># ===== \u7b2c\u4e00\u6b65\uff1a\u5b9a\u4e49\u5de5\u5177\u51fd\u6570\uff08\u53a8\u623f\u771f\u6b63\u505a\u7684\u4e8b\uff09=====<\/span>\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">def<\/span> <span class=\"hljs-title function_\" style=\"color: #268bd2;\">get_current_weather<\/span>(<span class=\"hljs-params\">location: <span class=\"hljs-built_in\" style=\"color: #2aa198;\">str<\/span>, unit: <span class=\"hljs-built_in\" style=\"color: #2aa198;\">str<\/span> = <span class=\"hljs-string\" style=\"color: #859900;\">\"celsius\"<\/span><\/span>) -&gt; <span class=\"hljs-built_in\" style=\"color: #2aa198;\">dict<\/span>:\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"\"\"\u6a21\u62df\u5929\u6c14\u67e5\u8be2\uff08\u5b9e\u9645\u9879\u76ee\u91cc\u8fd9\u91cc\u8c03\u771f\u5b9e\u5929\u6c14API\uff09\"\"\"<\/span>\n  weather_data = {\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"\u5317\u4eac\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"weather\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u6674\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"temperature\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"25\u00b0C\"<\/span>},\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4e0a\u6d77\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"weather\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u591a\u4e91\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"temperature\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"28\u00b0C\"<\/span>},\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"\u6210\u90fd\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"weather\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u9634\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"temperature\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"30\u00b0C\"<\/span>},\n  }\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">return<\/span> weather_data.get(location, {<span class=\"hljs-string\" style=\"color: #859900;\">\"weather\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u672a\u77e5\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"temperature\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u672a\u77e5\"<\/span>})\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># ===== \u7b2c\u4e8c\u6b65\uff1a\u5b9a\u4e49\u5de5\u5177\u5217\u8868\uff08\u83dc\u5355\uff09=====<\/span>\ntools = [\n  {\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>: {\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>,\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"description\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u83b7\u53d6\u6307\u5b9a\u57ce\u5e02\u5f53\u524d\u7684\u5929\u6c14\u60c5\u51b5\"<\/span>,\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"parameters\"<\/span>: {\n        <span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"object\"<\/span>,\n        <span class=\"hljs-string\" style=\"color: #859900;\">\"properties\"<\/span>: {\n          <span class=\"hljs-string\" style=\"color: #859900;\">\"location\"<\/span>: {\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"string\"<\/span>,\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"description\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u57ce\u5e02\u540d\u79f0\uff0c\u4f8b\u5982\uff1a\u5317\u4eac\"<\/span>\n          },\n          <span class=\"hljs-string\" style=\"color: #859900;\">\"unit\"<\/span>: {\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"string\"<\/span>,\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"enum\"<\/span>: [<span class=\"hljs-string\" style=\"color: #859900;\">\"celsius\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"fahrenheit\"<\/span>],\n            <span class=\"hljs-string\" style=\"color: #859900;\">\"description\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u6e29\u5ea6\u5355\u4f4d\"<\/span>\n          }\n        },\n        <span class=\"hljs-string\" style=\"color: #859900;\">\"required\"<\/span>: [<span class=\"hljs-string\" style=\"color: #859900;\">\"location\"<\/span>]\n      }\n    }\n  }\n]\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u51fd\u6570\u540d \u2192 \u5b9e\u9645\u51fd\u6570\u7684\u6620\u5c04\u8868<\/span>\navailable_functions = {\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>: get_current_weather,\n}\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># ===== \u7b2c\u4e09\u6b65\uff1a\u7f16\u6392\u4e24\u8f6e\u5bf9\u8bdd =====<\/span>\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">def<\/span> <span class=\"hljs-title function_\" style=\"color: #268bd2;\">run_conversation<\/span>(<span class=\"hljs-params\">user_message: <span class=\"hljs-built_in\" style=\"color: #2aa198;\">str<\/span><\/span>):\n  client = get_client()\n  messages = [{<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"user\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: user_message}]\n\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># ===== \u7b2c1\u6b21\u8c03\u7528\uff1a\u6a21\u578b\u51b3\u5b9a\u662f\u5426\u7528\u5de5\u5177 =====<\/span>\n  response = client.chat.completions.create(\n    model=MODEL,\n    messages=messages,\n    tools=tools,\n    tool_choice=<span class=\"hljs-string\" style=\"color: #859900;\">\"auto\"<\/span>,   <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u8ba9\u6a21\u578b\u81ea\u884c\u51b3\u5b9a<\/span>\n  )\n  response_message = response.choices[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>].message\n  tool_calls = response_message.tool_calls\n\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">not<\/span> tool_calls:\n    <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u6a21\u578b\u8ba4\u4e3a\u4e0d\u9700\u8981\u5de5\u5177\uff0c\u76f4\u63a5\u56de\u590d\u4e86<\/span>\n    <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(response_message.content)\n    <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">return<\/span>\n\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u628a\u6a21\u578b\u7684 tool_calls \u8bf7\u6c42\u52a0\u5165\u5386\u53f2<\/span>\n  messages.append(response_message)\n\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># ===== \u6267\u884c\u6bcf\u4e2a\u5de5\u5177\u8c03\u7528 =====<\/span>\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">for<\/span> tool_call <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">in<\/span> tool_calls:\n    func_name = tool_call.function.name\n    func_args = json.loads(tool_call.function.arguments)\n\n    <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u627e\u5230\u5e76\u6267\u884c\u672c\u5730\u51fd\u6570<\/span>\n    func_result = available_functions[func_name](**func_args)\n\n    <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u628a\u7ed3\u679c\u4ee5 tool \u89d2\u8272\u8ffd\u52a0\u5230 messages<\/span>\n    messages.append({\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"tool\"<\/span>,\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"tool_call_id\"<\/span>: tool_call.<span class=\"hljs-built_in\" style=\"color: #2aa198;\">id<\/span>,\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: func_name,\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: json.dumps(func_result, ensure_ascii=<span class=\"hljs-literal\" style=\"color: #cb4b16;\">False<\/span>),\n    })\n\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># ===== \u7b2c2\u6b21\u8c03\u7528\uff1a\u57fa\u4e8e\u5de5\u5177\u7ed3\u679c\u751f\u6210\u6700\u7ec8\u56de\u7b54 =====<\/span>\n  final = client.chat.completions.create(\n    model=MODEL,\n    messages=messages,\n  )\n  <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(final.choices[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>].message.content)\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># ===== \u8fd0\u884c =====<\/span>\nrun_conversation(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u4eca\u5929\u5317\u4eac\u5929\u6c14\u600e\u4e48\u6837\uff1f\"<\/span>)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u770b\u7740\u957f\uff0c\u62c6\u5f00\u5c31\u4e09\u6b65\u3002\u9010\u6bb5\u8bb2\u3002&#8221;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u9010\u6bb5\u62c6\u89e3<\/span><\/h2>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u7b2c\u4e00\u6b65\uff1a\u5b9a\u4e49\u5de5\u5177\u51fd\u6570<\/span><\/h3>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\"><span class=\"hljs-keyword\" style=\"color: #6c71c4;\">def<\/span> <span class=\"hljs-title function_\" style=\"color: #268bd2;\">get_current_weather<\/span>(<span class=\"hljs-params\">location: <span class=\"hljs-built_in\" style=\"color: #2aa198;\">str<\/span>, unit: <span class=\"hljs-built_in\" style=\"color: #2aa198;\">str<\/span> = <span class=\"hljs-string\" style=\"color: #859900;\">\"celsius\"<\/span><\/span>) -&gt; <span class=\"hljs-built_in\" style=\"color: #2aa198;\">dict<\/span>:\n  weather_data = {\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"\u5317\u4eac\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"weather\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u6674\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"temperature\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"25\u00b0C\"<\/span>},\n    ...\n  }\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">return<\/span> weather_data.get(location, ...)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u5c31\u662f&#8217;\u53a8\u623f&#8217;\u2014\u2014\u771f\u6b63\u5e72\u6d3b\u7684\u51fd\u6570\u3002\u51fd\u6570\u540d\u3001\u53c2\u6570\u540d\u5fc5\u987b\u548c tools \u5b9a\u4e49\u91cc<strong style=\"color: #333333; font-weight: bold;\">\u5b8c\u5168\u4e00\u81f4<\/strong>\u3002\u53c2\u6570\u540d\u4e0d\u4e00\u81f4\uff0c\u6a21\u578b\u4f20\u8fc7\u6765\u7684\u503c\u4f60\u63a5\u4e0d\u4f4f\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u91cc\u7528\u5047\u6570\u636e\u6a21\u62df\u3002\u5b9e\u9645\u9879\u76ee\u91cc\uff0c\u8fd9\u4e2a\u51fd\u6570\u5185\u90e8\u4f1a\u8c03\u771f\u5b9e\u7684\u5929\u6c14 API\u3001\u67e5\u6570\u636e\u5e93\u3001\u6216\u8005\u8bfb\u6587\u4ef6\u3002\u4f46\u5bf9\u5916\u63a5\u53e3\u4e0d\u53d8\u2014\u2014\u63a5\u6536\u53c2\u6570\uff0c\u8fd4\u56de dict\u3002&#8221;<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u7b2c\u4e8c\u6b65\uff1a\u5b9a\u4e49\u5de5\u5177\u5217\u8868\u548c\u6620\u5c04\u8868<\/span><\/h3>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">tools = [...]  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u544a\u8bc9\u6a21\u578b\u6709\u54ea\u4e9b\u5de5\u5177<\/span>\n\navailable_functions = {\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>: get_current_weather,\n}\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;tools \u662f\u7ed9\u6a21\u578b\u770b\u7684&#8217;\u83dc\u5355&#8217;\uff0cavailable_functions \u662f\u7ed9\u4f60\u7684\u4ee3\u7801\u7528\u7684&#8217;\u8def\u7531\u8868&#8217;\u2014\u2014\u6a21\u578b\u8bf4&#8217;\u8c03 get_current_weather&#8217;\uff0c\u4f60\u901a\u8fc7\u8fd9\u5f20\u8868\u627e\u5230\u771f\u6b63\u7684 Python \u51fd\u6570\u5e76\u6267\u884c\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u7528\u51fd\u6570\u540d\u8c03\uff1f\u56e0\u4e3a\u6a21\u578b\u8fd4\u56de\u7684\u662f\u5b57\u7b26\u4e32 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">'get_current_weather'<\/code>\uff0c\u4e0d\u662f\u51fd\u6570\u5bf9\u8c61\u3002\u4f60\u9700\u8981\u4e00\u4e2a\u6620\u5c04\u628a\u5b57\u7b26\u4e32\u8f6c\u6210\u53ef\u8c03\u7528\u7684\u51fd\u6570\u3002&#8221;<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u7b2c\u4e09\u6b65\uff1a\u7b2c\u4e00\u8f6e\u8c03\u7528\u2014\u2014\u6a21\u578b\u51b3\u5b9a\u7528\u4ec0\u4e48\u5de5\u5177<\/span><\/h3>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">response = client.chat.completions.create(\n  model=MODEL,\n  messages=messages,\n  tools=tools,      <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u628a\u83dc\u5355\u4f20\u7ed9\u6a21\u578b<\/span>\n  tool_choice=<span class=\"hljs-string\" style=\"color: #859900;\">\"auto\"<\/span>,   <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u8ba9\u6a21\u578b\u81ea\u5df1\u51b3\u5b9a\u8981\u4e0d\u8981\u8c03<\/span>\n)\nresponse_message = response.choices[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>].message\ntool_calls = response_message.tool_calls\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6ce8\u610f\u8fd9\u91cc\u6bd4\u666e\u901a\u8c03\u7528\u591a\u4e86\u4e24\u4e2a\u53c2\u6570\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tools<\/code> \u548c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_choice<\/code>\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tools<\/code> \u662f\u5de5\u5177\u5217\u8868\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_choice<\/code> \u63a7\u5236\u6a21\u578b\u7684\u884c\u4e3a\u2014\u2014<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">auto<\/code> \u662f\u8ba9\u6a21\u578b\u81ea\u5df1\u5224\u65ad\u8981\u4e0d\u8981\u8c03\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5982\u679c\u6a21\u578b\u8ba4\u4e3a\u4e0d\u9700\u8981\u5de5\u5177\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_calls<\/code> \u5c31\u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">None<\/code>\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">response_message.content<\/code> \u76f4\u63a5\u5c31\u662f\u6700\u7ec8\u56de\u7b54\u3002\u5982\u679c\u6a21\u578b\u8ba4\u4e3a\u9700\u8981\u5de5\u5177\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">content<\/code> \u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">None<\/code>\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_calls<\/code> \u91cc\u6709\u8c03\u7528\u8bf7\u6c42\u3002&#8221;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\"><span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">not<\/span> tool_calls:\n  <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(response_message.content)  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u4e0d\u9700\u8981\u5de5\u5177\uff0c\u76f4\u63a5\u56de\u7b54<\/span>\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">return<\/span>\n\nmessages.append(response_message)  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u628a tool_calls \u8bf7\u6c42\u52a0\u5165\u5386\u53f2<\/span>\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;<strong style=\"color: #333333; font-weight: bold;\">\u8fd9\u884c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">messages.append(response_message)<\/code> \u5f88\u5173\u952e\u3002<\/strong> \u6a21\u578b\u7684 tool_calls \u8bf7\u6c42\u4e5f\u662f\u4e00\u6761 assistant \u6d88\u606f\uff0c\u5fc5\u987b\u5b58\u5165\u5386\u53f2\u3002\u4e0d\u7136\u7b2c\u4e8c\u8f6e\u8c03\u7528\u65f6\uff0c\u6a21\u578b\u4e0d\u77e5\u9053\u81ea\u5df1\u4e4b\u524d\u8981\u6c42\u8c03\u4ec0\u4e48\u51fd\u6570\u3002&#8221;<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u7b2c\u56db\u6b65\uff1a\u6267\u884c\u51fd\u6570\uff0c\u628a\u7ed3\u679c\u5582\u56de\u53bb<\/span><\/h3>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\"><span class=\"hljs-keyword\" style=\"color: #6c71c4;\">for<\/span> tool_call <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">in<\/span> tool_calls:\n  func_name = tool_call.function.name\n  func_args = json.loads(tool_call.function.arguments)\n\n  func_result = available_functions[func_name](**func_args)\n\n  messages.append({\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"tool\"<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"tool_call_id\"<\/span>: tool_call.<span class=\"hljs-built_in\" style=\"color: #2aa198;\">id<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: func_name,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: json.dumps(func_result, ensure_ascii=<span class=\"hljs-literal\" style=\"color: #cb4b16;\">False<\/span>),\n  })\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u6307\u7740\u8fd9\u6bb5\u8bf4\uff1a&#8221;\u8fd9\u662f Function Calling \u6700\u6838\u5fc3\u7684\u56db\u884c\u3002&#8221;<\/p>\n<ol style=\"margin: 8px 0px; padding-left: 28px; list-style: outside decimal;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">func_name<\/code><\/strong> \u2014 \u6a21\u578b\u544a\u8bc9\u4f60\u8c03\u54ea\u4e2a\u51fd\u6570<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">func_args<\/code><\/strong> \u2014 \u6a21\u578b\u7ed9\u4f60\u7684\u53c2\u6570\uff0c\u662f JSON \u5b57\u7b26\u4e32\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">json.loads()<\/code> \u8f6c\u6210 dict<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">func_result<\/code><\/strong> \u2014 \u901a\u8fc7\u6620\u5c04\u8868\u627e\u5230\u51fd\u6570\uff0c\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">**func_args<\/code> \u89e3\u5305\u53c2\u6570\u6267\u884c<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">messages.append(...)<\/code><\/strong> \u2014 \u628a\u6267\u884c\u7ed3\u679c\u5305\u6210 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool<\/code> \u6d88\u606f\u585e\u56de\u5386\u53f2<\/section>\n<\/li>\n<\/ol>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u91cd\u70b9\u8bf4\u8fd9\u4e2a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool<\/code> \u6d88\u606f\u3002&#8221;\u8001\u5f20\u753b\u4e86\u4e2a\u6846\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">{\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"tool\"<\/span>,        <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u56fa\u5b9a\u503c<\/span>\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"tool_call_id\"<\/span>: tool_call.<span class=\"hljs-built_in\" style=\"color: #2aa198;\">id<\/span>, <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u5173\u8054\u6a21\u578b\u7684\u8c03\u7528\u8bf7\u6c42<\/span>\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: func_name,      <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u54ea\u4e2a\u51fd\u6570\u8fd4\u56de\u7684<\/span>\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">'{\"weather\": \"\u6674\", \"temperature\": \"25\u00b0C\"}'<\/span>  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u7ed3\u679c\uff0c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32<\/span>\n}\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_call_id<\/code> \u662f<strong style=\"color: #333333; font-weight: bold;\">\u5fc5\u987b\u7684<\/strong>\u2014\u2014\u5b83\u628a\u6a21\u578b\u7684\u8c03\u7528\u8bf7\u6c42\u548c\u4f60\u7684\u6267\u884c\u7ed3\u679c\u5173\u8054\u8d77\u6765\u3002\u6a21\u578b\u53ef\u80fd\u540c\u65f6\u8c03\u591a\u4e2a\u51fd\u6570\uff0c\u6bcf\u4e2a\u51fd\u6570\u7684\u7ed3\u679c\u8981\u7528\u5bf9\u5e94\u7684 id \u6807\u8bb0\uff0c\u6a21\u578b\u624d\u77e5\u9053\u54ea\u4e2a\u7ed3\u679c\u5bf9\u5e94\u54ea\u4e2a\u8bf7\u6c42\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">content<\/code> \u5fc5\u987b\u662f<strong style=\"color: #333333; font-weight: bold;\">\u5b57\u7b26\u4e32<\/strong>\u3002\u51fd\u6570\u8fd4\u56de\u7684\u662f dict\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">json.dumps()<\/code> \u8f6c\u6210 JSON \u5b57\u7b26\u4e32\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">ensure_ascii=False<\/code> \u4fdd\u8bc1\u4e2d\u6587\u4e0d\u88ab\u8f6c\u6210 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">\\uXXXX<\/code>\u3002&#8221;<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u7b2c\u4e94\u6b65\uff1a\u7b2c\u4e8c\u8f6e\u8c03\u7528\u2014\u2014\u6a21\u578b\u57fa\u4e8e\u771f\u5b9e\u6570\u636e\u751f\u6210\u56de\u7b54<\/span><\/h3>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">final = client.chat.completions.create(\n  model=MODEL,\n  messages=messages,\n)\n<span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(final.choices[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>].message.content)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u7b2c\u4e8c\u6b21\u8c03\u7528<strong style=\"color: #333333; font-weight: bold;\">\u4e0d\u9700\u8981\u4f20 tools<\/strong>\u2014\u2014\u56e0\u4e3a\u4e0d\u9700\u8981\u6a21\u578b\u518d\u51b3\u5b9a\u8c03\u4e0d\u8c03\u51fd\u6570\u4e86\u3002\u53ea\u9700\u8981\u628a\u5b8c\u6574\u7684 messages \u5386\u53f2\uff08\u5305\u542b\u5de5\u5177\u7ed3\u679c\uff09\u4f20\u8fc7\u53bb\uff0c\u8ba9\u6a21\u578b\u57fa\u4e8e\u771f\u5b9e\u6570\u636e\u751f\u6210\u81ea\u7136\u8bed\u8a00\u56de\u7b54\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u8f6e\u7684 messages \u5217\u8868\u957f\u8fd9\u6837\uff1a&#8221;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">[\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"user\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4eca\u5929\u5317\u4eac\u5929\u6c14\u600e\u4e48\u6837\uff1f\"<\/span>},\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u6a21\u578b\u7684 tool_calls \u8bf7\u6c42\uff08\u7b2c1\u8f6e\u8fd4\u56de\u7684 assistant \u6d88\u606f\uff09<\/span>\n  {\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-literal\" style=\"color: #cb4b16;\">None<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"tool_calls\"<\/span>: [{\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"id\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"call_abc123\"<\/span>,\n      <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>: {\n        <span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>,\n        <span class=\"hljs-string\" style=\"color: #859900;\">\"arguments\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">'{\"location\": \"\u5317\u4eac\"}'<\/span>\n      }\n    }]\n  },\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u4f60\u6267\u884c\u51fd\u6570\u540e\u7684\u7ed3\u679c\uff08tool \u6d88\u606f\uff09<\/span>\n  {\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"tool\"<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"tool_call_id\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"call_abc123\"<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">'{\"weather\": \"\u6674\", \"temperature\": \"25\u00b0C\"}'<\/span>\n  }\n]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6a21\u578b\u770b\u5230\u8fd9\u6761 tool \u6d88\u606f\uff0c\u5c31\u77e5\u9053&#8217;\u5317\u4eac\u5929\u6c14\u662f\u6674\uff0c25\u00b0C&#8217;\uff0c\u7136\u540e\u751f\u6210\u6700\u7ec8\u56de\u7b54\u3002<strong style=\"color: #333333; font-weight: bold;\">\u8fd9\u5c31\u662f\u4ece&#8217;\u7f16\u9020&#8217;\u5230&#8217;\u57fa\u4e8e\u771f\u5b9e\u6570\u636e&#8217;\u7684\u5173\u952e\u8de8\u8d8a\u3002<\/strong>&#8220;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u8dd1\u8d77\u6765\u770b\u770b<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u8fd0\u884c\u4e86\u7a0b\u5e8f\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-bash\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">python main.py\n<\/code><\/pre>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">\u5317\u4eac\u4eca\u5929\u6674\u5929\uff0c\u6c14\u6e2925\u00b0C\uff0c\u9002\u5408\u5916\u51fa\u6d3b\u52a8\u3002\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u53c8\u8bd5\u4e86\u51e0\u4e2a\u95ee\u9898\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">run_conversation(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u4e0a\u6d77\u5929\u6c14\u600e\u4e48\u6837\uff1f\"<\/span>)\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u8f93\u51fa\uff1a\u4e0a\u6d77\u4eca\u5929\u591a\u4e91\uff0c\u6c14\u6e2928\u00b0C\u3002<\/span>\n\nrun_conversation(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u597d\uff0c\u8bf7\u81ea\u6211\u4ecb\u7ecd\"<\/span>)\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u8f93\u51fa\uff1a\u4f60\u597d\uff01\u6211\u662f\u4e00\u4e2aAI\u52a9\u624b\uff0c\u53ef\u4ee5\u5e2e\u4f60\u67e5\u8be2\u5929\u6c14\u4fe1\u606f\u2026\u2026<\/span>\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u6ce8\u610f\u5230\uff1a&#8221;\u7b2c\u4e09\u4e2a\u95ee\u9898\u5b83\u6ca1\u8c03\u51fd\u6570\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5bf9\u3002&#8221;\u8001\u5f20\u8bf4\uff0c&#8221;\u56e0\u4e3a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_choice='auto'<\/code>\uff0c\u6a21\u578b\u81ea\u5df1\u5224\u65ad\u2014\u2014\u7528\u6237\u95ee\u5929\u6c14\u5c31\u8c03\u51fd\u6570\uff0c\u7528\u6237\u6253\u62db\u547c\u5c31\u4e0d\u8c03\uff0c\u76f4\u63a5\u56de\u590d\u3002\u8fd9\u5c31\u662f&#8217;\u667a\u80fd&#8217;\u7684\u5730\u65b9\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5982\u679c\u4f60\u95ee&#8217;\u6210\u90fd\u548c\u5317\u4eac\u54ea\u4e2a\u70ed&#8217;\u5462\uff1f&#8221;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">run_conversation(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u6210\u90fd\u548c\u5317\u4eac\u54ea\u4e2a\u70ed\uff1f\"<\/span>)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6a21\u578b\u4f1a<strong style=\"color: #333333; font-weight: bold;\">\u540c\u65f6\u8c03\u4e24\u6b21\u51fd\u6570<\/strong>\u2014\u2014\u4e00\u6b21\u67e5\u6210\u90fd\uff0c\u4e00\u6b21\u67e5\u5317\u4eac\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_calls<\/code> \u91cc\u6709\u4e24\u6761\uff0c\u4f60\u7684 for \u5faa\u73af\u5206\u522b\u6267\u884c\uff0c\u4e24\u4e2a\u7ed3\u679c\u90fd\u8ffd\u52a0\u5230 messages\uff0c\u7b2c\u4e8c\u8f6e\u8c03\u7528\u6a21\u578b\u7efc\u5408\u4e24\u4e2a\u7ed3\u679c\u56de\u7b54\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u77aa\u5927\u773c\u775b\uff1a&#8221;\u4e00\u4e2a for \u5faa\u73af\u5c31\u641e\u5b9a\u4e86\u5e76\u884c\u8c03\u7528\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5bf9\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_calls<\/code> \u662f\u4e2a\u6570\u7ec4\uff0c\u91cc\u9762\u6709\u51e0\u6761\u5c31\u8c03\u51e0\u6b21\u3002\u4f60\u5faa\u73af\u6267\u884c\u5c31\u884c\u3002\u6a21\u578b\u81ea\u5df1\u51b3\u5b9a\u8c03\u51e0\u6b21\u3001\u8c03\u54ea\u4e2a\u3002&#8221;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">tool_choice\uff1a\u63a7\u5236\u6a21\u578b\u7684\u884c\u4e3a<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_choice<\/code> \u8fd9\u4e2a\u53c2\u6570\u63a7\u5236\u6a21\u578b&#8217;\u8981\u4e0d\u8981\u8c03\u5de5\u5177&#8217;\u3002\u56db\u4e2a\u9009\u9879\uff1a&#8221;<\/p>\n<table style=\"display: inline-block !important; width: auto; max-width: 100%; overflow: auto; border-spacing: 0px; border-collapse: collapse; margin: 1rem 0px;\">\n<thead style=\"background: #fff9eb; color: #333333; text-align: left;\">\n<tr>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u503c<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u542b\u4e49<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u4f7f\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\"><code>\"auto\"<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u6a21\u578b\u81ea\u884c\u51b3\u5b9a\uff08\u9ed8\u8ba4\uff09<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u901a\u7528\u5bf9\u8bdd\uff0c\u8ba9\u6a21\u578b\u81ea\u5df1\u5224\u65ad<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\"><code>\"none\"<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u7981\u6b62\u8c03\u7528\u4efb\u4f55\u5de5\u5177<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u7eaf\u804a\u5929\u6a21\u5f0f\uff0c\u6a21\u578b\u53ea\u56de\u7b54\u4e0d\u8c03\u51fd\u6570<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\"><code>\"required\"<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5f3a\u5236\u5fc5\u987b\u8c03\u7528\u5de5\u5177<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u4e1a\u52a1\u6d41\u7a0b\u5fc5\u987b\u8d70\u5de5\u5177\uff0c\u4e0d\u5141\u8bb8\u76f4\u63a5\u56de\u7b54<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\"><code>{\"type\":\"function\",\"function\":{\"name\":\"xxx\"}}<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5f3a\u5236\u8c03\u7528\u6307\u5b9a\u51fd\u6570<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u660e\u786e\u77e5\u9053\u8981\u7528\u54ea\u4e2a\u5de5\u5177<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u95ee\uff1a&#8221;<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">auto<\/code> \u548c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">required<\/code> \u6709\u4ec0\u4e48\u533a\u522b\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">auto<\/code> \u65f6\u6a21\u578b\u53ef\u80fd\u4e0d\u8c03\u2014\u2014\u7528\u6237\u8bf4&#8217;\u4f60\u597d&#8217;\uff0c\u6a21\u578b\u76f4\u63a5\u56de\u590d\uff0c\u4e0d\u8c03\u51fd\u6570\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">required<\/code> \u65f6\u6a21\u578b<strong style=\"color: #333333; font-weight: bold;\">\u5fc5\u987b\u8c03<\/strong>\u2014\u2014\u4e0d\u7ba1\u7528\u6237\u95ee\u4ec0\u4e48\uff0c\u90fd\u8981\u8c03\u4e00\u4e2a\u51fd\u6570\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4ec0\u4e48\u65f6\u5019\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">required<\/code>\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6bd4\u5982\u4f60\u7684\u4e1a\u52a1\u6d41\u7a0b\u5fc5\u987b\u8d70\u5de5\u5177\u2014\u2014\u7528\u6237\u95ee\u4efb\u4f55\u95ee\u9898\u90fd\u5fc5\u987b\u5148\u67e5\u77e5\u8bc6\u5e93\u518d\u56de\u7b54\u3002\u6216\u8005\u4f60\u5728\u8c03\u8bd5\u9636\u6bb5\uff0c\u60f3\u5f3a\u5236\u6a21\u578b\u8c03\u67d0\u4e2a\u51fd\u6570\u770b\u770b\u53c2\u6570\u5bf9\u4e0d\u5bf9\u3002&#8221;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\"><span class=\"hljs-comment\" style=\"color: #657b83;\"># \u5f3a\u5236\u8c03 get_current_weather<\/span>\nresponse = client.chat.completions.create(\n  model=MODEL,\n  messages=messages,\n  tools=tools,\n  tool_choice={<span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>}},\n)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5165\u95e8\u9636\u6bb5\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">auto<\/code> \u5c31\u591f\u4e86\u3002\u7b49\u4f60\u5bf9\u6a21\u578b\u884c\u4e3a\u6709\u66f4\u9ad8\u8981\u6c42\u65f6\u518d\u8c03\u3002&#8221;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u56db\u4e2a\u5fc5\u8e29\u7684\u5751<\/span><\/h2>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u5751\u4e00\uff1a\u51fd\u6570\u540d\u4e0d\u5339\u914d<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">tools \u5b9a\u4e49\u91cc\u5199 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">\"name\": \"get_weather\"<\/code>\uff0cPython \u51fd\u6570\u5199 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">def get_current_weather()<\/code>\u2014\u2014\u540d\u5b57\u4e0d\u4e00\u6837\u3002<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">KeyError: 'get_weather'\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u6a21\u578b\u8fd4\u56de <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">'get_weather'<\/code>\uff0c\u4f60\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">available_functions<\/code> \u91cc\u6ca1\u6709\u8fd9\u4e2a\u952e\uff0c\u76f4\u63a5\u70b8\u4e86\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\"><strong style=\"color: #333333; font-weight: bold;\">\u89e3\u6cd5<\/strong>\uff1atools \u91cc\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">name<\/code> \u5fc5\u987b\u548c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">available_functions<\/code> \u7684\u952e<strong style=\"color: #333333; font-weight: bold;\">\u5b8c\u5168\u4e00\u81f4<\/strong>\u3002\u5efa\u8bae\u7528\u5e38\u91cf\u7ba1\u7406\uff0c\u907f\u514d\u624b\u5199\u62fc\u9519\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">FUNC_WEATHER = <span class=\"hljs-string\" style=\"color: #859900;\">\"get_current_weather\"<\/span>\n\ntools = [{<span class=\"hljs-string\" style=\"color: #859900;\">\"function\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: FUNC_WEATHER, ...}}]\navailable_functions = {FUNC_WEATHER: get_current_weather}\n<\/code><\/pre>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u5751\u4e8c\uff1a\u53c2\u6570 JSON \u89e3\u6790\u5931\u8d25<\/span><\/h3>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">func_args = json.loads(tool_call.function.arguments)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u6a21\u578b\u8fd4\u56de\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">arguments<\/code> \u662f JSON \u5b57\u7b26\u4e32\uff0c99% \u7684\u60c5\u51b5\u6ca1\u95ee\u9898\u3002\u4f46\u5076\u5c14\u6a21\u578b\u4f1a\u8fd4\u56de\u4e0d\u5408\u6cd5\u7684 JSON\u2014\u2014\u5c11\u4e86\u5f15\u53f7\u3001\u591a\u4e86\u9017\u53f7\u3001\u4e2d\u6587\u6ca1\u8f6c\u4e49\u3002<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">json.JSONDecodeError: Expecting property name enclosed in double quotes\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\"><strong style=\"color: #333333; font-weight: bold;\">\u89e3\u6cd5<\/strong>\uff1a\u52a0 try-except\uff0c\u89e3\u6790\u5931\u8d25\u65f6\u7ed9\u4e2a\u9ed8\u8ba4\u503c\u6216\u63d0\u793a\u7528\u6237\u6362\u79cd\u95ee\u6cd5\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\"><span class=\"hljs-keyword\" style=\"color: #6c71c4;\">try<\/span>:\n  func_args = json.loads(tool_call.function.arguments)\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">except<\/span> json.JSONDecodeError:\n  <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u53c2\u6570\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u6362\u79cd\u65b9\u5f0f\u63d0\u95ee\u3002\"<\/span>)\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">return<\/span>\n<\/code><\/pre>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u5751\u4e09\uff1a\u5fd8\u8bb0\u628a tool_calls \u8ffd\u52a0\u5230 messages<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u4e2a\u5751\u6700\u5e38\u89c1\u3002&#8221;\u8001\u5f20\u8bf4\uff0c&#8221;\u7b2c\u4e00\u8f6e\u8c03\u7528\u62ff\u5230 tool_calls \u540e\uff0c\u76f4\u63a5\u53bb\u6267\u884c\u51fd\u6570\u4e86\uff0c\u5fd8\u4e86\u628a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">response_message<\/code> \u8ffd\u52a0\u5230 messages\u3002\u7ed3\u679c\u7b2c\u4e8c\u8f6e\u8c03\u7528\u65f6\uff0cmessages \u91cc\u53ea\u6709 user \u6d88\u606f\u548c tool \u6d88\u606f\u2014\u2014<strong style=\"color: #333333; font-weight: bold;\">\u7f3a\u4e86\u4e2d\u95f4\u90a3\u6761 assistant \u6d88\u606f\u3002<\/strong>&#8220;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">Error: An assistant message with 'tool_calls' must be followed by tool messages\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">API \u76f4\u63a5\u62a5\u9519\u2014\u2014tool \u6d88\u606f\u524d\u9762\u5fc5\u987b\u6709\u5bf9\u5e94\u7684 assistant \u6d88\u606f\uff08\u5e26 tool_calls \u7684\u90a3\u6761\uff09\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\"><strong style=\"color: #333333; font-weight: bold;\">\u89e3\u6cd5<\/strong>\uff1a\u8bb0\u4f4f\u987a\u5e8f\u2014\u2014\u5148\u8ffd\u52a0 assistant \u6d88\u606f\uff0c\u518d\u8ffd\u52a0 tool \u6d88\u606f\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\"><span class=\"hljs-comment\" style=\"color: #657b83;\"># \u2705 \u6b63\u786e\u987a\u5e8f<\/span>\nmessages.append(response_message)  <span class=\"hljs-comment\" style=\"color: #657b83;\"># 1. \u5148\u8ffd\u52a0\u6a21\u578b\u7684 tool_calls \u8bf7\u6c42<\/span>\nmessages.append({...})       <span class=\"hljs-comment\" style=\"color: #657b83;\"># 2. \u518d\u8ffd\u52a0\u5de5\u5177\u6267\u884c\u7ed3\u679c<\/span>\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u274c \u9519\u8bef\u2014\u2014\u6f0f\u4e86\u7b2c\u4e00\u6b65<\/span>\nmessages.append({...})  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u76f4\u63a5\u8ffd\u52a0 tool \u7ed3\u679c\uff0c\u7f3a assistant \u6d88\u606f<\/span>\n<\/code><\/pre>\n<h3 style=\"font-size: 16px; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid #f8b43f;\"><span style=\"color: #333333; font-weight: bold;\">\u5751\u56db\uff1atool_call_id \u4e0d\u5339\u914d<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6a21\u578b\u540c\u65f6\u8c03\u4e24\u4e2a\u51fd\u6570\u65f6\uff0c\u6bcf\u4e2a tool_call \u6709\u4e0d\u540c\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">id<\/code>\u3002\u4f60\u6267\u884c\u5b8c\u51fd\u6570\uff0c\u8fd4\u56de\u7ed3\u679c\u65f6 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_call_id<\/code> \u5fc5\u987b\u5bf9\u5e94\u2014\u2014&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5982\u679c\u4f60\u628a\u5317\u4eac\u7684\u7ed3\u679c\u6807\u8bb0\u4e86\u6210\u90fd\u7684 id\uff0c\u6a21\u578b\u5c31\u4ee5\u4e3a&#8217;\u5317\u4eac\u7684\u7ed3\u679c\u662f\u6210\u90fd\u7684&#8217;\uff0c\u56de\u7b54\u5c31\u5168\u4e71\u4e86\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\"><strong style=\"color: #333333; font-weight: bold;\">\u89e3\u6cd5<\/strong>\uff1afor \u5faa\u73af\u91cc\u7528\u5f53\u524d <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_call.id<\/code>\uff0c\u522b\u7528\u522b\u7684\uff1a<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\"><span class=\"hljs-keyword\" style=\"color: #6c71c4;\">for<\/span> tool_call <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">in<\/span> tool_calls:\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u6bcf\u4e2a tool_call \u6709\u81ea\u5df1\u7684 id\uff0c\u7528\u5b83<\/span>\n  messages.append({\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"tool\"<\/span>,\n    <span class=\"hljs-string\" style=\"color: #859900;\">\"tool_call_id\"<\/span>: tool_call.<span class=\"hljs-built_in\" style=\"color: #2aa198;\">id<\/span>,  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u2190 \u7528\u5f53\u524d\u7684 id<\/span>\n    ...\n  })\n<\/code><\/pre>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u6d88\u606f\u5217\u8868\u5728 Function Calling \u4e2d\u7684\u53d8\u5316<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u4e0a\u6b21\u8bb2\u591a\u8f6e\u5bf9\u8bdd\u65f6\uff0cmessages \u5217\u8868\u53ea\u6709 system\/user\/assistant \u4e09\u79cd\u89d2\u8272\u3002Function Calling \u5f15\u5165\u4e86\u7b2c\u56db\u79cd\u2014\u2014<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool<\/code>\u3002\u6574\u4e2a\u6d88\u606f\u6d41\u8f6c\u662f\u8fd9\u6837\u7684\uff1a&#8221;<\/p>\n<section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><\/section>\n<pre style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: #002b36;\"><code class=\"hljs\" style=\"tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: #93a1a1; background: #002b36;\">\u521d\u59cb\u72b6\u6001\uff1a\n[system, user]              \u2190 \u4f60\u6784\u9020\u7684\n\n\u7b2c1\u6b21\u8c03\u7528\u540e\uff08\u6a21\u578b\u51b3\u5b9a\u8c03\u51fd\u6570\uff09\uff1a\n[system, user, assistant(tool_calls)]   \u2190 \u8ffd\u52a0\u6a21\u578b\u7684\u8c03\u7528\u8bf7\u6c42\n\n\u6267\u884c\u51fd\u6570\u540e\uff1a\n[system, user, assistant(tool_calls), tool(\u7ed3\u679c)]  \u2190 \u8ffd\u52a0\u5de5\u5177\u7ed3\u679c\n\n\u7b2c2\u6b21\u8c03\u7528\u540e\uff08\u6a21\u578b\u751f\u6210\u6700\u7ec8\u56de\u7b54\uff09\uff1a\n[system, user, assistant(tool_calls), tool(\u7ed3\u679c), assistant(\u6700\u7ec8\u56de\u7b54)]  \u2190 \u8ffd\u52a0\u6700\u7ec8\u56de\u590d\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6ce8\u610f\u7b2c\u4e00\u6b21\u7684 assistant \u6d88\u606f\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">content<\/code> \u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">None<\/code>\uff0c\u4f46\u591a\u4e86 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_calls<\/code> \u5b57\u6bb5\u3002\u7b2c\u4e8c\u6b21\u7684 assistant \u6d88\u606f\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">content<\/code> \u624d\u662f\u771f\u6b63\u7684\u6587\u5b57\u56de\u590d\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5982\u679c\u4f60\u5728\u8fd9\u4e2a\u57fa\u7840\u4e0a\u7ee7\u7eed\u591a\u8f6e\u5bf9\u8bdd\uff0c\u540e\u9762\u7684\u6d88\u606f\u8ffd\u52a0\u903b\u8f91\u8ddf\u4e0a\u6b21\u8bb2\u7684\u4e00\u6a21\u4e00\u6837\u2014\u2014user \u8ffd\u52a0\u95ee\u9898\uff0cassistant \u8ffd\u52a0\u56de\u590d\u3002Function Calling \u53ea\u662f\u5728\u4e2d\u95f4\u63d2\u4e86\u4e00\u7ec4 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">assistant(tool_calls) + tool(\u7ed3\u679c)<\/code> \u6d88\u606f\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u604d\u7136\u5927\u609f\uff1a&#8221;\u6240\u4ee5 Function Calling \u5e76\u6ca1\u6709\u6539\u53d8\u6d88\u606f\u5217\u8868\u7684\u5e95\u5c42\u903b\u8f91\uff0c\u53ea\u662f\u591a\u4e86\u4e00\u79cd\u6d88\u606f\u7c7b\u578b\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5b8c\u5168\u6b63\u786e\u3002<strong style=\"color: #333333; font-weight: bold;\">messages \u5217\u8868\u662f\u6574\u4e2a\u5927\u6a21\u578b\u5f00\u53d1\u7684\u5730\u57fa\uff0cFunction Calling \u53ea\u662f\u5728\u4e0a\u9762\u52a0\u4e86\u4e00\u5c42\u697c\u3002<\/strong>&#8220;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u8fd9\u7bc7\u6587\u7ae0\u7684\u6838\u5fc3<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u6700\u540e\u5728\u767d\u677f\u4e0a\u5199\u4e86\u4e00\u53e5\u8bdd\uff1a<\/p>\n<blockquote style=\"color: #555555; background-color: #fff9eb; background-image: none; padding: 16px 20px; margin: 20px 0px; border-width: 0px 0px 0px 4px; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor #f8b43f; border-radius: 6px; font-style: normal; quotes: none;\">\n<p style=\"margin: 0.55em 0px; color: #555555; text-indent: 0px; padding: 0px; line-height: 1.75; font-style: normal; background: transparent;\"><strong style=\"color: #333333; font-weight: bold;\">Function Calling = \u6a21\u578b\u70b9\u83dc + \u4ee3\u7801\u4e0a\u83dc + \u6a21\u578b\u8f6c\u8ff0\u3002<\/strong><\/p>\n<\/blockquote>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u770b\u7740\u767d\u677f\uff0c\u628a\u5b83\u62cd\u4e86\u4e0b\u6765\u3002<\/p>\n<table style=\"display: inline-block !important; width: auto; max-width: 100%; overflow: auto; border-spacing: 0px; border-collapse: collapse; margin: 1rem 0px;\">\n<thead style=\"background: #fff9eb; color: #333333; text-align: left;\">\n<tr>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u6982\u5ff5<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u4e00\u53e5\u8bdd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u672c\u8d28<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u6a21\u578b\u4e0d\u6267\u884c\u51fd\u6570\uff0c\u53ea\u8f93\u51fa\u7ed3\u6784\u5316\u8c03\u7528\u6307\u4ee4\uff0c\u4f60\u7684\u4ee3\u7801\u771f\u6b63\u6267\u884c<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u4e24\u8f6e\u5bf9\u8bdd<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u7b2c1\u6b21\u51b3\u5b9a\u7528\u4ec0\u4e48\u5de5\u5177\uff0c\u7b2c2\u6b21\u57fa\u4e8e\u5de5\u5177\u7ed3\u679c\u751f\u6210\u56de\u7b54<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">tools \u5b9a\u4e49<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">name + description + parameters\uff08JSON Schema\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">description<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u6700\u5173\u952e\u5b57\u6bb5\uff0c\u51b3\u5b9a\u6a21\u578b\u4f55\u65f6\u8c03\u7528\uff0c\u5199\u6e05\u7528\u9014+\u793a\u4f8b\u503c<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">tool_calls<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u6a21\u578b\u8fd4\u56de\u7684\u8c03\u7528\u8bf7\u6c42\uff0c\u542b\u51fd\u6570\u540d\u548c\u53c2\u6570\uff08JSON \u5b57\u7b26\u4e32\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">tool \u6d88\u606f<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\"><code>role: \"tool\"<\/code> + <code>tool_call_id<\/code> + <code>content<\/code>\uff08\u5b57\u7b26\u4e32\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">tool_call_id<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5173\u8054\u6a21\u578b\u7684\u8c03\u7528\u8bf7\u6c42\u548c\u4f60\u7684\u6267\u884c\u7ed3\u679c\uff0c\u4e0d\u80fd\u641e\u6df7<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">tool_choice<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">auto\uff08\u81ea\u52a8\uff09\/ none\uff08\u7981\u6b62\uff09\/ required\uff08\u5fc5\u987b\uff09\/ \u6307\u5b9a\u51fd\u6570<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">available_functions<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u51fd\u6570\u540d\u2192\u5b9e\u9645\u51fd\u6570\u7684\u6620\u5c04\u8868\uff0c\u6a21\u578b\u7ed9\u5b57\u7b26\u4e32\u4f60\u7ed9\u6267\u884c<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">messages \u53d8\u5316<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u591a\u4e86 assistant(tool_calls) + tool(\u7ed3\u679c) \u4e24\u79cd\u6d88\u606f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5927\u6a21\u578b\u4ece&#8217;\u4f1a\u8bf4&#8217;\u53d8\u6210&#8217;\u4f1a\u5e72&#8217;\uff0c\u9760\u7684\u4e0d\u662f\u81ea\u5df1\u53d8\u806a\u660e\u4e86\uff0c\u800c\u662f\u4f60\u7ed9\u5b83\u914d\u4e86\u4e00\u53cc\u624b\u3002Function Calling \u5c31\u662f\u8fd9\u53cc\u624b\u7684\u63a5\u53e3\u534f\u8bae\u3002&#8221;<\/p>\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u4e0b\u4e00\u6b65<\/span><\/h2>\n<ol style=\"margin: 8px 0px; padding-left: 28px; list-style: outside decimal;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\">\u591a\u4e2a\u5de5\u5177\u7ec4\u5408<\/strong> \u2014 \u8ba9\u6a21\u578b\u5728\u4e00\u4e2a\u5bf9\u8bdd\u91cc\u8c03\u591a\u4e2a\u4e0d\u540c\u51fd\u6570<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\">\u5d4c\u5957\u8c03\u7528<\/strong> \u2014 \u51fd\u6570 A \u7684\u7ed3\u679c\u4f5c\u4e3a\u51fd\u6570 B \u7684\u53c2\u6570\uff0c\u6a21\u578b\u81ea\u5df1\u7f16\u6392<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\">\u5e76\u884c\u8c03\u7528<\/strong> \u2014 \u6a21\u578b\u540c\u65f6\u8c03\u591a\u4e2a\u51fd\u6570\uff0c\u4f60\u7684 for \u5faa\u73af\u5904\u7406<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\">\u9519\u8bef\u5904\u7406<\/strong> \u2014 \u51fd\u6570\u6267\u884c\u5931\u8d25\u65f6\u600e\u4e48\u544a\u8bc9\u6a21\u578b\uff0c\u8ba9\u5b83\u6362\u4e2a\u7b56\u7565<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: #333333; list-style: inherit;\">\n<section><strong style=\"color: #333333; font-weight: bold;\">Agent \u5de5\u4f5c\u6d41<\/strong> \u2014 Function Calling \u662f Agent \u7684\u57fa\u7840\uff0cAgent \u5c31\u662f\u5728\u8fd9\u4e2a\u5faa\u73af\u4e0a\u52a0\u4e0a\u4efb\u52a1\u89c4\u5212\u548c\u81ea\u4e3b\u51b3\u7b56<\/section>\n<\/li>\n<\/ol>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6bcf\u4e00\u6b65\u90fd\u662f\u5728 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tools<\/code> \u5217\u8868\u548c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; background-color: #fff4e6; color: #d9480f; border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">messages<\/code> \u5217\u8868\u4e0a\u505a\u52a0\u6cd5\u3002\u4e24\u8f6e\u8c03\u7528\u7684\u9aa8\u67b6\u4ece\u6765\u6ca1\u53d8\u8fc7\u3002&#8221;<\/p>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: #f0e6d0 currentcolor currentcolor; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: #333333; line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; text-align: left; background: linear-gradient(to top, #f8b43f 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px; border: medium none currentcolor;\"><span style=\"color: #333333; font-weight: bold;\">\u603b\u7ed3<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u4e0a\u7bc7\u4f60\u5b66\u4f1a\u4e86\u8ba9 AI \u8bb0\u4f4f\u5bf9\u8bdd\u5386\u53f2\u3002\u8fd9\u7bc7\u4f60\u5b66\u4f1a\u4e86\u8ba9 AI \u8c03\u7528\u5916\u90e8\u5de5\u5177\u2014\u2014\u6838\u5fc3\u5c31\u662f<strong style=\"color: #333333; font-weight: bold;\">\u4e24\u8f6e API \u8c03\u7528\uff1a\u7b2c\u4e00\u8f6e\u6a21\u578b\u51b3\u5b9a\u7528\u4ec0\u4e48\u5de5\u5177\uff0c\u4f60\u7684\u4ee3\u7801\u6267\u884c\u51fd\u6570\uff0c\u7b2c\u4e8c\u8f6e\u6a21\u578b\u57fa\u4e8e\u771f\u5b9e\u7ed3\u679c\u751f\u6210\u56de\u7b54\u3002<\/strong><\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5927\u6a21\u578b\u672c\u8eab\u4e0d\u4f1a\u67e5\u5929\u6c14\u3001\u4e0d\u4f1a\u67e5\u8ba2\u5355\u3001\u4e0d\u4f1a\u53d1\u90ae\u4ef6\u3002\u4f46\u901a\u8fc7 Function Calling\uff0c\u5b83\u80fd&#8221;\u610f\u8bc6\u5230&#8221;\u81ea\u5df1\u9700\u8981\u8c03\u4e00\u4e2a\u51fd\u6570\uff0c\u544a\u8bc9\u4f60\u8c03\u54ea\u4e2a\u3001\u53c2\u6570\u662f\u4ec0\u4e48\u3002\u4f60\u6267\u884c\u5b8c\u628a\u7ed3\u679c\u5582\u56de\u53bb\uff0c\u5b83\u5c31\u80fd\u57fa\u4e8e\u771f\u5b9e\u6570\u636e\u56de\u7b54\u7528\u6237\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8fd9\u5c31\u662f\u4ece&#8221;\u804a\u5929\u673a\u5668\u4eba&#8221;\u5230&#8221;AI \u52a9\u624b&#8221;\u7684\u5206\u6c34\u5cad\u3002\u804a\u5929\u673a\u5668\u4eba\u53ea\u4f1a\u8bf4\uff0cAI \u52a9\u624b\u4f1a\u5e72\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u628a Function Calling \u8dd1\u901a\u540e\uff0c\u7ed9\u8001\u677f\u6f14\u793a\u4e86 AI \u5ba2\u670d\u67e5\u8ba2\u5355\u3002\u8001\u677f\u95ee\uff1a&#8221;\u5b83\u662f\u600e\u4e48\u77e5\u9053\u8ba2\u5355\u7cfb\u7edf\u7684\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u8bf4\uff1a&#8221;\u5b83\u4e0d\u77e5\u9053\u3002\u5b83\u53ea\u662f\u544a\u8bc9\u6211&#8217;\u8c03 query_order_status \u51fd\u6570\uff0c\u53c2\u6570\u662f\u8ba2\u5355\u53f7&#8217;\uff0c\u771f\u6b63\u67e5\u6570\u636e\u5e93\u7684\u662f\u6211\u7684\u4ee3\u7801\u3002\u5b83\u53ea\u662f\u4e2a\u7ffb\u8bd1\u5b98\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u677f\u6123\u4e86\u4e00\u4e0b\uff0c\u7136\u540e\u7b11\u4e86\uff1a&#8221;\u90a3\u8fd9\u4e2a\u7ffb\u8bd1\u5b98\u8fd8\u633a\u9760\u8c31\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u542c\u8bf4\u540e\u8ddf\u5c0f\u660e\u8bf4\uff1a&#8221;\u8bb0\u4f4f\uff0c<strong style=\"color: #333333; font-weight: bold;\">Function Calling \u7684\u672c\u8d28\u4e0d\u662f\u8ba9 AI \u53d8\u5f3a\u4e86\uff0c\u662f\u8ba9 AI \u53d8\u8bda\u5b9e\u4e86\u2014\u2014\u5b83\u4e0d\u518d\u7f16\u9020\uff0c\u800c\u662f\u627f\u8ba4&#8217;\u6211\u9700\u8981\u67e5\u4e00\u4e0b&#8217;\uff0c\u7136\u540e\u8ba9\u4f60\u53bb\u67e5\u3002<\/strong>&#8220;<\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00 \u5c0f\u660e\u4e0a\u5468\u641e\u5b9a\u4e86\u591a\u8f6e\u5bf9\u8bdd\uff0c\u804a\u5929\u673a\u5668\u4eba\u8dd1\u5f97\u6709\u6a21\u6709\u6837\u3002\u8fd9\u5468\u4e00\u4e0a\u73ed\uff0c\u8001\u677f\u53c8\u4e22\u6765\u4e00\u4e2a\u9700\u6c42\uff1a &#8220;\u54b1\u4eec\u7684  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3615,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[164,163],"tags":[167,168],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/3610"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3610"}],"version-history":[{"count":2,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/3610\/revisions"}],"predecessor-version":[{"id":3616,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/3610\/revisions\/3616"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/media\/3615"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}