{"id":3605,"date":"2026-08-16T12:35:55","date_gmt":"2026-08-16T04:35:55","guid":{"rendered":"http:\/\/ai.zhousir.top\/?p=3605"},"modified":"2026-08-16T16:04:20","modified_gmt":"2026-08-16T08:04:20","slug":"chatgpt-%e6%a0%b9%e6%9c%ac%e6%b2%a1%e9%ad%94%e6%b3%95%ef%bc%81%e4%b8%80%e4%b8%aa-while-%e5%be%aa%e7%8e%af-%e4%b8%80%e4%b8%aa%e5%88%97%e8%a1%a8%ef%bc%8c%e6%88%91%e5%81%9a%e5%87%ba%e4%ba%86%e8%81%8a","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=3605","title":{"rendered":"ChatGPT \u6839\u672c\u6ca1\u9b54\u6cd5\uff01\u4e00\u4e2a while \u5faa\u73af + \u4e00\u4e2a\u5217\u8868\uff0c\u6211\u505a\u51fa\u4e86\u804a\u5929\u673a\u5668\u4eba"},"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\u8f6c\u901a\u4e86\u7b2c\u4e00\u6b21 API \u8c03\u7528\uff0c\u5174\u594b\u4e86\u6ca1\u4e24\u5929\u5c31\u53d1\u73b0\u4e00\u4e2a\u95ee\u9898\u2014\u2014<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u4ed6\u95ee AI\uff1a&#8221;\u6211\u6709\u5341\u4e2a\u82f9\u679c\uff1f\u5403\u6389\u4e00\u4e2a\u8fd8\u6709\u51e0\u4e2a\uff1f&#8221;AI \u56de\u7b54\u4e86\u3002\u4ed6\u63a5\u7740\u95ee\uff1a&#8221;\u6211\u539f\u6765\u6709\u51e0\u4e2a\u82f9\u679c&#8221;AI \u56de\uff1a&#8221;\u4e0d\u77e5\u9053\u539f\u6765\u82f9\u679c\u6570\uff1f\u8bf7\u8865\u5145\u4f60\u7684\u9700\u6c42\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\u8fd9\u4e0d\u662f\u63a5\u7740\u4e0a\u4e00\u53e5\u95ee\u7684\u5417\uff1f<\/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;\u8fd9 AI \u662f\u4e0d\u662f\u6709\u5065\u5fd8\u75c7\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u7b11\u4e86\uff1a&#8221;\u4e0d\u662f\u5065\u5fd8\u75c7\uff0c\u662f<strong style=\"color: #333333; font-weight: bold;\">\u6839\u672c\u6ca1\u6709\u8bb0\u5fc6<\/strong>\u3002\u4f60\u6bcf\u6b21\u8c03 API\uff0c\u5bf9\u5b83\u6765\u8bf4\u90fd\u662f\u5168\u65b0\u7684\u4e00\u6b21\u5bf9\u8bdd\u3002\u5b83\u4e0d\u77e5\u9053\u4f60\u4e0a\u4e00\u53e5\u95ee\u4e86\u4ec0\u4e48\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u90a3 ChatGPT \u600e\u4e48\u80fd\u8fde\u7eed\u804a\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u56e0\u4e3a ChatGPT \u6bcf\u6b21\u90fd\u628a\u4e4b\u524d\u804a\u8fc7\u7684\u6240\u6709\u6d88\u606f\u6253\u5305\u4f20\u7ed9\u5927\u6a21\u578b\u3002\u4f60\u4ee5\u4e3a\u5b83\u5728&#8217;\u8bb0\u4f4f&#8217;\uff0c\u5176\u5b9e\u662f\u5b83\u5728&#8217;\u590d\u8bfb&#8217;\u2014\u2014\u628a\u5386\u53f2\u6d88\u606f\u5168\u90e8\u91cd\u65b0\u5582\u4e00\u904d\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\u3002\u8001\u5f20\u8bf4\uff1a&#8221;\u4eca\u5929\u6211\u5c31\u5e26\u4f60\u5b9e\u73b0\u4e00\u4e2a\u80fd\u8fde\u7eed\u5bf9\u8bdd\u7684\u547d\u4ee4\u884c\u804a\u5929\u673a\u5668\u4eba\u3002\u6838\u5fc3\u5c31\u4e00\u53e5\u8bdd\u2014\u2014<strong style=\"color: #333333; font-weight: bold;\">\u7ef4\u62a4\u4e00\u4e2a messages \u5217\u8868\uff0c\u6bcf\u8f6e\u628a\u5386\u53f2\u6d88\u606f\u5168\u90e8\u4f20\u8fc7\u53bb\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;\">\u5927\u6a21\u578b\u7684&#8221;\u8bb0\u5fc6&#8221;\u4ece\u54ea\u6765<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u5148\u5728\u767d\u677f\u4e0a\u753b\u4e86\u5f20\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;\">\u7b2c1\u8f6e\u8bf7\u6c42\uff1a\n\u4f60\u53d1 \u2192 [system, user1]\nAI\u56de \u2190 assistant1\n\n\u7b2c2\u8f6e\u8bf7\u6c42\uff1a\n\u4f60\u53d1 \u2192 [system, user1, assistant1, user2]\nAI\u56de \u2190 assistant2\n\n\u7b2c3\u8f6e\u8bf7\u6c42\uff1a\n\u4f60\u53d1 \u2192 [system, user1, assistant1, user2, assistant2, user3]\nAI\u56de \u2190 assistant3\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;\u6bcf\u4e00\u8f6e\u5bf9\u8bdd\uff0c\u4f60\u53d1\u7ed9 API \u7684 messages \u5217\u8868\u8d8a\u6765\u8d8a\u957f\u3002\u5927\u6a21\u578b\u770b\u5230\u5b8c\u6574\u7684\u5386\u53f2\uff0c\u5c31\u80fd\u63a5\u4e0a\u4e0b\u6587\u3002\u8fd9\u4e2a\u5217\u8868\u5c31\u662f\u4f60\u8fd9\u4e2a\u804a\u5929\u673a\u5668\u4eba\u7684&#8217;\u8bb0\u5fc6&#8217;\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\u8fd9\u4e2a\u5217\u8868\u4e00\u76f4\u6da8\uff0c\u4e0d\u4f1a\u7206\u5417\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4f1a\u3002&#8221;\u8001\u5f20\u8bf4\uff0c&#8221;\u8fd9\u662f\u591a\u8f6e\u5bf9\u8bdd\u6700\u6838\u5fc3\u7684\u95ee\u9898\uff0c\u5f85\u4f1a\u513f\u8bb2\u3002\u5148\u628a\u57fa\u7840\u7248\u8dd1\u901a\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;\">\u591a\u8f6e\u5bf9\u8bdd\u6838\u5fc3\u4ee3\u7801<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u914d\u7f6e\u548c\u4e0a\u6b21\u4e00\u6837\uff0c\u770b\u6838\u5fc3\u6587\u4ef6\u3002\u8fd9\u6b21\u5c31\u4e00\u4e2a\u6587\u4ef6\uff0c\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-string\" style=\"color: #859900;\">\"\"\"\n\u7b2c4\u8bfe\uff1a\u591a\u8f6e\u5bf9\u8bdd CLI\uff08messages \u5386\u53f2\u7d2f\u79ef\uff09\u3002\n\n\u8fd0\u884c\uff1apython main.py\n\u8f93\u5165 quit \u9000\u51fa\u3002\n\"\"\"<\/span>\n\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\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">def<\/span> <span class=\"hljs-title function_\" style=\"color: #268bd2;\">main<\/span>() -&gt; <span class=\"hljs-literal\" style=\"color: #cb4b16;\">None<\/span>:\n  client = get_client()\n  history = [{<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u4e00\u4f4d\u7b80\u6d01\u7684\u52a9\u7406\u3002\"<\/span>}]\n\n  <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u6570\u5b57\u5458\u5de5\u5df2\u5c31\u7eea\u3002\u8f93\u5165 quit \u9000\u51fa\u3002\\n\"<\/span>)\n\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">while<\/span> <span class=\"hljs-literal\" style=\"color: #cb4b16;\">True<\/span>:\n    user_input = <span class=\"hljs-built_in\" style=\"color: #2aa198;\">input<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\uff1a\"<\/span>).strip()\n    <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">not<\/span> user_input <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">or<\/span> user_input.lower() <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">in<\/span> (<span class=\"hljs-string\" style=\"color: #859900;\">\"quit\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"exit\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"\/quit\"<\/span>):\n      <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u518d\u89c1\uff01\"<\/span>)\n      <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">break<\/span>\n\n    history.append({<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_input})\n    response = client.chat.completions.create(\n      model=MODEL,\n      messages=history,\n      temperature=<span class=\"hljs-number\" style=\"color: #cb4b16;\">0.7<\/span>,\n    )\n    assistant = response.choices[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>].message.content <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">or<\/span> <span class=\"hljs-string\" style=\"color: #859900;\">\"\"<\/span>\n    history.append({<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: assistant})\n    <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">f\"AI\uff1a<span class=\"hljs-subst\" style=\"color: #93a1a1;\">{assistant}<\/span>\\n\"<\/span>)\n\n\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> __name__ == <span class=\"hljs-string\" style=\"color: #859900;\">\"__main__\"<\/span>:\n  main()\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;\u522b\u770b\u4ee3\u7801\u77ed\uff0c\u6bcf\u4e00\u884c\u90fd\u6709\u8bb2\u7a76\u3002\u6211\u9010\u6bb5\u7ed9\u4f60\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\u521d\u59cb\u5316\u5386\u53f2\u5217\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;\">history = [{<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u4e00\u4f4d\u7b80\u6d01\u7684\u52a9\u7406\u3002\"<\/span>}]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\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;\">history<\/code> \u5217\u8868\u5c31\u662f\u6574\u4e2a\u5bf9\u8bdd\u7684&#8217;\u8bb0\u5fc6\u5bb9\u5668&#8217;\u3002\u7a0b\u5e8f\u542f\u52a8\u65f6\u53ea\u6709\u4e00\u6761 system \u6d88\u606f\u2014\u2014\u7ed9 AI \u5b9a\u4eba\u8bbe\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u91cc\u5199\u7684\u662f&#8217;\u4f60\u662f\u4e00\u4f4d\u7b80\u6d01\u7684\u52a9\u7406&#8217;\uff0c\u610f\u601d\u662f\u8ba9 AI \u56de\u7b54\u7b80\u77ed\u70b9\uff0c\u522b\u957f\u7bc7\u5927\u8bba\u3002\u4f60\u53ef\u4ee5\u6539\u6210\u4efb\u4f55\u4f60\u60f3\u8981\u7684\u89d2\u8272\u2014\u2014&#8217;\u4f60\u662f\u4e00\u4e2a Python \u7f16\u7a0b\u4e13\u5bb6&#8221;\u4f60\u662f\u4e00\u4e2a\u6e29\u67d4\u7684\u5fc3\u7406\u54a8\u8be2\u5e08&#8217;\uff0c\u90fd\u884c\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;\u8fd9\u4e2a system \u6d88\u606f\u6bcf\u8f6e\u90fd\u8981\u4f20\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5bf9\u3002\u5b83\u653e\u5728 history[0]\uff0c\u6bcf\u8f6e\u8bf7\u6c42\u90fd\u4f1a\u8ddf\u7740\u4e00\u8d77\u53d1\u8fc7\u53bb\u3002\u76f8\u5f53\u4e8e\u6bcf\u6b21\u90fd\u63d0\u9192 AI &#8216;\u4f60\u662f\u8c01&#8217;\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\u5faa\u73af\u63a5\u6536\u8f93\u5165<\/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;\">while<\/span> <span class=\"hljs-literal\" style=\"color: #cb4b16;\">True<\/span>:\n  user_input = <span class=\"hljs-built_in\" style=\"color: #2aa198;\">input<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\uff1a\"<\/span>).strip()\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">not<\/span> user_input <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">or<\/span> user_input.lower() <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">in<\/span> (<span class=\"hljs-string\" style=\"color: #859900;\">\"quit\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"exit\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"\/quit\"<\/span>):\n    <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">\"\u518d\u89c1\uff01\"<\/span>)\n    <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">break<\/span>\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;\">while True<\/code> \u6b7b\u5faa\u73af\uff0c\u4e0d\u65ad\u7b49\u7528\u6237\u8f93\u5165\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;\">input(\"\u4f60\uff1a\")<\/code> \u5728\u7ec8\u7aef\u663e\u793a <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;\">\u4f60\uff1a<\/code> \u63d0\u793a\u7b26\uff0c\u7b49\u7528\u6237\u6572\u56de\u8f66\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u9000\u51fa\u903b\u8f91\u4e09\u9053\u9632\u7ebf\u2014\u2014\u8f93\u5165 <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;\">quit<\/code>\u3001<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;\">exit<\/code>\u3001<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;\">\/quit<\/code> \u90fd\u80fd\u9000\u51fa\uff0c\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002\u8f93\u5165\u7a7a\u884c\u4e5f\u76f4\u63a5\u8df3\u8fc7\uff0c\u4e0d\u4f1a\u53d1\u7a7a\u6d88\u606f\u7ed9 API \u6d6a\u8d39 token\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\u7d2f\u79ef\u6d88\u606f\uff0c\u53d1\u8d77\u8bf7\u6c42<\/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;\">history.append({<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_input})\nresponse = client.chat.completions.create(\n  model=MODEL,\n  messages=history,\n  temperature=<span class=\"hljs-number\" style=\"color: #cb4b16;\">0.7<\/span>,\n)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u662f\u6838\u5fc3\u4e2d\u7684\u6838\u5fc3\u3002&#8221;\u8001\u5f20\u52a0\u91cd\u4e86\u8bed\u6c14\uff0c&#8221;\u5148\u628a\u7528\u6237\u7684\u8bdd\u8ffd\u52a0\u5230 <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;\">history<\/code>\uff0c\u7136\u540e\u628a<strong style=\"color: #333333; font-weight: bold;\">\u6574\u4e2a history<\/strong> \u4f20\u7ed9 API\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6ce8\u610f\uff0c\u4f20\u7684\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;\">messages=history<\/code>\uff0c\u4e0d\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;\">messages=[{\"role\": \"user\", \"content\": user_input}]<\/code>\u3002\u8fd9\u5c31\u662f\u591a\u8f6e\u5bf9\u8bdd\u548c\u5355\u8f6e\u5bf9\u8bdd\u552f\u4e00\u7684\u533a\u522b\u2014\u2014<strong style=\"color: #333333; font-weight: bold;\">\u4f60\u4f20\u7ed9 API \u7684\u6d88\u606f\u5217\u8868\u5305\u542b\u4e86\u6240\u6709\u5386\u53f2\u3002<\/strong>&#8220;<\/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\u4fdd\u5b58 AI \u56de\u590d\uff0c\u5f62\u6210\u95ed\u73af<\/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;\">assistant = response.choices[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>].message.content <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">or<\/span> <span class=\"hljs-string\" style=\"color: #859900;\">\"\"<\/span>\nhistory.append({<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: assistant})\n<span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">f\"AI\uff1a<span class=\"hljs-subst\" style=\"color: #93a1a1;\">{assistant}<\/span>\\n\"<\/span>)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u62ff\u5230 AI \u7684\u56de\u590d\u540e\uff0c<strong style=\"color: #333333; font-weight: bold;\">\u5fc5\u987b\u8ffd\u52a0\u5230 history<\/strong>\u3002\u8fd9\u4e00\u6b65\u5f88\u591a\u4eba\u4f1a\u5fd8\u2014\u2014\u53ea\u6253\u5370\u4e86\u56de\u590d\uff0c\u6ca1\u5b58\u8fdb\u5386\u53f2\u3002\u7ed3\u679c\u4e0b\u4e00\u8f6e\u8bf7\u6c42\u65f6\uff0cAI \u4e0d\u77e5\u9053\u81ea\u5df1\u4e0a\u4e00\u8f6e\u8bf4\u4e86\u4ec0\u4e48\uff0c\u4e0a\u4e0b\u6587\u5c31\u65ad\u4e86\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;\">or \"\"<\/code> \u662f\u9632\u5fa1\u6027\u5199\u6cd5\u2014\u2014\u4e07\u4e00 API \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;\">None<\/code>\uff08\u6781\u7aef\u60c5\u51b5\uff09\uff0c\u4e0d\u4f1a\u62a5\u9519\u3002&#8221;<\/p>\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\u95ed\u73af\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\u8f93\u5165 \u2192 \u8ffd\u52a0\u5230 history \u2192 \u8c03 API \u2192 AI \u56de\u590d \u2192 \u8ffd\u52a0\u5230 history \u2192 \u6253\u5370 \u2192 \u4e0b\u4e00\u8f6e\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u56db\u6b65\u5faa\u73af\uff0c\u5c31\u662f\u8fd9\u4e2a while \u5faa\u73af\u7684\u5168\u90e8\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;\">\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;\">\u6570\u5b57\u5458\u5de5\u5df2\u5c31\u7eea\u3002\u8f93\u5165 quit \u9000\u51fa\u3002\n\n\u4f60\uff1a\u6211\u53eb\u5c0f\u660e\uff0c\u4eca\u5e7425\u5c81\nAI\uff1a\u4f60\u597d\uff0c\u5c0f\u660e\uff0125\u5c81\u6b63\u662f\u9ec4\u91d1\u5e74\u9f84\u3002\n\n\u4f60\uff1a\u6211\u521a\u624d\u8bf4\u6211\u53eb\u4ec0\u4e48\uff1f\nAI\uff1a\u4f60\u53eb\u5c0f\u660e\u3002\n\n\u4f60\uff1a\u6211\u591a\u5927\u4e86\uff1f\nAI\uff1a\u4f60\u4eca\u5e7425\u5c81\u3002\n\n\u4f60\uff1aquit\n\u518d\u89c1\uff01\n<\/code><\/pre>\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;\u5b83\u8bb0\u4f4f\u4e86\uff01\u7b2c\u4e8c\u4e09\u8f6e\u95ee\u5b83\u90fd\u77e5\u9053\uff01&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4e0d\u662f\u5b83\u8bb0\u4f4f\u4e86\uff0c\u662f\u4f60\u6bcf\u6b21\u90fd\u544a\u8bc9\u5b83\u4e86\u3002&#8221;\u8001\u5f20\u8bf4\uff0c&#8221;\u4f60\u5728\u7b2c\u4e09\u8f6e\u95ee&#8217;\u6211\u591a\u5927\u4e86&#8217;\u7684\u65f6\u5019\uff0c\u4f60\u53d1\u7ed9 API \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;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u4e00\u4f4d\u7b80\u6d01\u7684\u52a9\u7406\u3002\"<\/span>},\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;\">\"\u6211\u53eb\u5c0f\u660e\uff0c\u4eca\u5e7425\u5c81\"<\/span>},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u597d\uff0c\u5c0f\u660e\uff0125\u5c81\u6b63\u662f\u9ec4\u91d1\u5e74\u9f84\u3002\"<\/span>},\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;\">\"\u6211\u521a\u624d\u8bf4\u6211\u53eb\u4ec0\u4e48\uff1f\"<\/span>},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u53eb\u5c0f\u660e\u3002\"<\/span>},\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;\">\"\u6211\u591a\u5927\u4e86\uff1f\"<\/span>},   <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u2190 \u5f53\u524d\u95ee\u9898<\/span>\n]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5b83\u770b\u5230\u7b2c\u4e00\u8f6e\u4f60\u5c31\u8bf4\u4e86&#8217;\u4eca\u5e74 25 \u5c81&#8217;\uff0c\u5f53\u7136\u77e5\u9053\u4f60\u591a\u5927\u3002<strong style=\"color: #333333; font-weight: bold;\">\u8bb0\u5fc6\u4e0d\u662f\u5927\u6a21\u578b\u7684\u80fd\u529b\uff0c\u662f\u4f60\u628a\u5386\u53f2\u5582\u7ed9\u5b83\u7684\u7ed3\u679c\u3002<\/strong>&#8220;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u82e5\u6709\u6240\u601d\uff1a&#8221;\u90a3\u5982\u679c\u804a\u4e86\u4e00\u767e\u8f6e\uff0c\u8fd9\u4e2a\u5217\u8868\u5c82\u4e0d\u662f\u6709\u4e00\u767e\u591a\u6761\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5bf9\uff0c\u800c\u4e14\u6bcf\u6761\u8d8a\u6765\u8d8a\u957f\u3002\u8fd9\u5c31\u662f\u63a5\u4e0b\u6765\u8981\u8bf4\u7684\u95ee\u9898\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;\">\u6df1\u5165\u7406\u89e3\u6d88\u606f\u5217\u8868<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u559d\u4e86\u53e3\u6c34\uff0c\u8bf4\uff1a&#8221;\u57fa\u7840\u7528\u6cd5\u4f60\u6e05\u695a\u4e86\uff0c\u4f46 messages \u5217\u8868\u8fdc\u4e0d\u6b62&#8217;\u6512\u4e00\u5806\u6d88\u606f\u4f20\u8fc7\u53bb&#8217;\u8fd9\u4e48\u7b80\u5355\u3002\u8fd9\u91cc\u9762\u7684\u7ec6\u8282\uff0c\u51b3\u5b9a\u4e86\u4f60\u7684\u804a\u5929\u673a\u5668\u4eba\u5230\u5e95\u662f&#8217;\u80fd\u804a&#8217;\u8fd8\u662f&#8217;\u597d\u804a&#8217;\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;\">\u6d88\u606f\u7684\u89e3\u5256\u7ed3\u6784<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5148\u770b\u4e00\u6761\u6d88\u606f\u957f\u4ec0\u4e48\u6837\u3002\u4f60\u5e73\u65f6\u5199\u7684\u662f\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;\">{<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;\">\"\u4f60\u597d\"<\/span>}\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4f46\u5b8c\u6574\u7684\u4e00\u6761\u6d88\u606f\uff0c\u5176\u5b9e\u53ef\u4ee5\u5305\u542b\u66f4\u591a\u5b57\u6bb5\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-comment\" style=\"color: #657b83;\"># \u5fc5\u987b\uff1a\u8c01\u8bf4\u7684<\/span>\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u597d\"<\/span>,     <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u5fc5\u987b\uff1a\u8bf4\u4e86\u4ec0\u4e48<\/span>\n  <span class=\"hljs-string\" style=\"color: #859900;\">\"name\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u5c0f\u660e\"<\/span>       <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u53ef\u9009\uff1a\u8bf4\u8bdd\u4eba\u7684\u540d\u5b57<\/span>\n}\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;<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;\">role<\/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;\">content<\/code> \u662f\u5fc5\u586b\u7684\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;\">name<\/code> \u662f\u53ef\u9009\u7684\u2014\u2014\u7528\u5728\u591a\u7528\u6237\u573a\u666f\u91cc\uff0c\u544a\u8bc9 AI \u8fd9\u6761\u8bdd\u662f\u8c01\u8bf4\u7684\u3002\u6bd4\u5982\u591a\u4eba\u804a\u5929\u5ba4\uff0c\u4f60\u53ef\u4ee5\u6807\u8bb0\u4e0d\u540c\u7528\u6237\u7684\u53d1\u8a00\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4f46\u65e5\u5e38\u5f00\u53d1 90% \u7684\u60c5\u51b5\uff0c\u53ea\u9700\u8981 <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;\">role<\/code> + <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> \u4e24\u4e2a\u5b57\u6bb5\u5c31\u591f\u4e86\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;\">\u56db\u79cd\u89d2\u8272\uff0c\u4e0d\u662f\u4e09\u79cd<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u8bf4\uff1a&#8221;\u6211\u4e0a\u6b21\u5b66\u7684\u662f system\u3001user\u3001assistant \u4e09\u79cd\u89d2\u8272\uff0c\u8fd8\u6709\u522b\u7684\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd8\u6709\u4e00\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>\u3002&#8221;\u8001\u5f20\u5728\u767d\u677f\u4e0a\u753b\u4e86\u5f20\u5b8c\u6574\u8868\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\">role<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u8c01\u8bf4\u7684<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u600e\u4e48\u7528<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u80fd\u4e0d\u80fd\u7701<\/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>system<\/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\">\u4f60\u7ed9 AI \u7684\u6307\u4ee4<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5217\u8868\u7b2c\u4e00\u6761\uff0c\u5b9a\u4eba\u8bbe\u3001\u5b9a\u89c4\u5219<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u53ef\u7701\uff0c\u4f46\u4e0d\u5efa\u8bae<\/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>user<\/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\">\u7528\u6237\u8bf4\u7684\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\">\u6bcf\u8f6e\u8ffd\u52a0\uff0c\u7528\u6237\u5b9e\u9645\u8f93\u5165<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5fc5\u987b\u6709<\/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>assistant<\/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\">AI \u7684\u56de\u590d<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u6bcf\u8f6e\u8ffd\u52a0\uff0c\u4fdd\u5b58\u5386\u53f2\u56de\u590d<\/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\u8f6e\u5bf9\u8bdd\u5fc5\u987b\u6709<\/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>tool<\/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\">\u5de5\u5177\u51fd\u6570\u7684\u8fd4\u56de\u7ed3\u679c<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">Function Calling \u65f6\u7528<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u8c03\u51fd\u6570\u65f6\u624d\u6709<\/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;\u524d\u4e09\u79cd\u4f60\u5df2\u7ecf\u5728\u7528\u4e86\u3002\u7b2c\u56db\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> \u662f Function Calling \u4e13\u5c5e\u2014\u2014\u5f53\u4f60\u8ba9 AI \u8c03\u7528\u4e00\u4e2a\u51fd\u6570\uff08\u6bd4\u5982\u67e5\u5929\u6c14\uff09\uff0c\u51fd\u6570\u8fd4\u56de\u7684\u7ed3\u679c\u8981\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;\">{\"role\": \"tool\", \"content\": \"\u6210\u90fd\u4eca\u592935\u2103\"}<\/code> \u585e\u56de messages \u5217\u8868\u3002AI \u770b\u5230\u8fd9\u4e2a\u7ed3\u679c\u540e\u624d\u4f1a\u7ed9\u4f60\u6700\u7ec8\u56de\u590d\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u4e2a\u5f85\u4f1a\u513f Function Calling \u90a3\u8282\u8bfe\u4f1a\u7ec6\u8bb2\uff0c\u73b0\u5728\u77e5\u9053\u6709\u8fd9\u56db\u79cd\u5c31\u884c\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;\">\u6d88\u606f\u987a\u5e8f\u7684\u786c\u89c4\u5219<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;messages \u5217\u8868\u4e0d\u662f\u968f\u4fbf\u6392\u7684\uff0c\u6709\u987a\u5e8f\u89c4\u5219\u3002\u8fdd\u53cd\u4e86\uff0c\u8981\u4e48\u62a5\u9519\uff0c\u8981\u4e48 AI \u56de\u7b54\u4e71\u4e03\u516b\u7cdf\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;\">\u89c4\u5219\u4e00\uff1asystem \u5fc5\u987b\u5728\u7b2c\u4e00\u6761\u3002<\/strong><\/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<\/span>\n[\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u52a9\u7406\"<\/span>},\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;\">\"\u4f60\u597d\"<\/span>},\n]\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u274c \u9519\u8bef\u2014\u2014system \u653e\u540e\u9762<\/span>\n[\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;\">\"\u4f60\u597d\"<\/span>},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u52a9\u7406\"<\/span>},\n]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6709\u7684\u5e73\u53f0\u4f1a\u76f4\u63a5\u62a5\u9519\uff0c\u6709\u7684\u4e0d\u62a5\u9519\u4f46 AI \u884c\u4e3a\u5f02\u5e38\u3002system \u5c31\u662f&#8217;\u5f00\u573a\u767d&#8217;\uff0c\u5fc5\u987b\u5728\u6700\u524d\u9762\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;\">\u89c4\u5219\u4e8c\uff1auser \u548c assistant \u5fc5\u987b\u4ea4\u66ff\u51fa\u73b0\u3002<\/strong><\/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\u2014\u2014\u4ea4\u66ff\u6392\u5217<\/span>\n[\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u52a9\u7406\"<\/span>},\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;\">\"\u95ee\u98981\"<\/span>},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u56de\u7b541\"<\/span>},\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;\">\"\u95ee\u98982\"<\/span>},\n]\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u274c \u9519\u8bef\u2014\u2014\u4e24\u4e2a user \u8fde\u7740<\/span>\n[\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u52a9\u7406\"<\/span>},\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;\">\"\u95ee\u98981\"<\/span>},\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;\">\"\u95ee\u98982\"<\/span>},\n]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4e3a\u4ec0\u4e48\uff1f&#8221;\u5c0f\u660e\u95ee\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u56e0\u4e3a\u5927\u6a21\u578b\u662f\u6309\u987a\u5e8f&#8217;\u8bfb&#8217;\u8fd9\u4e2a\u5217\u8868\u7684\u3002\u5b83\u770b\u5230\u4e00\u4e2a user \u6d88\u606f\uff0c\u5c31\u7406\u89e3\u4e3a&#8217;\u7528\u6237\u8bf4\u4e86\u8fd9\u53e5\u8bdd&#8217;\uff0c\u7136\u540e\u671f\u671b\u4e0b\u4e00\u6761\u662f\u81ea\u5df1\u7684\u56de\u590d\u3002\u5982\u679c\u4e24\u4e2a user \u8fde\u7740\uff0c\u5b83\u4f1a\u89c9\u5f97\u7528\u6237\u4e00\u53e3\u6c14\u8bf4\u4e86\u4e24\u53e5\u6ca1\u7ed9\u5b83\u63d2\u8bdd\u7684\u673a\u4f1a\uff0c\u4e0a\u4e0b\u6587\u5c31\u4e71\u4e86\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u90a3\u5982\u679c\u7528\u6237\u8fde\u53d1\u4e86\u4e24\u6761\u6d88\u606f\u600e\u4e48\u529e\uff1f&#8221;\u5c0f\u660e\u8ffd\u95ee\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5408\u5e76\u6210\u4e00\u6761\u3002\u6216\u8005\u5728\u4e2d\u95f4\u8865\u4e00\u4e2a assistant \u6d88\u606f\u2014\u2014\u6bd4\u5982 <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;\">'\u597d\u7684\uff0c\u8bf7\u7ee7\u7eed\u3002'<\/code> \u4f5c\u4e3a\u8fc7\u6e21\u3002\u4f46\u6700\u5e72\u51c0\u7684\u505a\u6cd5\u8fd8\u662f\u5408\u5e76\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;\"># \u7528\u6237\u8fde\u53d1\u4e24\u6761 \u2192 \u5408\u5e76<\/span>\nuser_input = <span class=\"hljs-string\" style=\"color: #859900;\">\"\u95ee\u98981 \u95ee\u98982\"<\/span>\nhistory.append({<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_input})\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;\">\u89c4\u5219\u4e09\uff1a\u6700\u540e\u4e00\u6761\u5fc5\u987b\u662f user\u3002<\/strong><\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4f60\u53d1\u7ed9 API \u7684 messages \u5217\u8868\uff0c\u6700\u540e\u4e00\u6761\u5fc5\u987b\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;\">user<\/code> \u6d88\u606f\u3002\u56e0\u4e3a\u4f60\u662f\u8ba9 AI \u56de\u590d\u4f60\u2014\u2014\u5b83\u9700\u8981\u4e00\u4e2a&#8217;\u95ee\u9898&#8217;\u6765\u56de\u7b54\u3002\u5982\u679c\u4f60\u6700\u540e\u4e00\u6761\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;\">assistant<\/code>\uff0cAI \u4f1a\u89c9\u5f97&#8217;\u6211\u5df2\u7ecf\u56de\u7b54\u8fc7\u4e86\uff0c\u4f60\u8fd8\u60f3\u5e72\u561b\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;\"><span class=\"hljs-comment\" style=\"color: #657b83;\"># \u2705 \u6700\u540e\u4e00\u6761\u662f user\u2014\u2014AI \u77e5\u9053\u8be5\u56de\u7b54\u4e86<\/span>\n[\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u52a9\u7406\"<\/span>},\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;\">\"\u4f60\u597d\"<\/span>},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u597d\uff01\"<\/span>},\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\u5929\u6c14\u600e\u4e48\u6837\uff1f\"<\/span>},  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u2190 \u6700\u540e\u4e00\u6761<\/span>\n]\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u274c \u6700\u540e\u4e00\u6761\u662f assistant\u2014\u2014AI \u56f0\u60d1<\/span>\n[\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u52a9\u7406\"<\/span>},\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;\">\"\u4f60\u597d\"<\/span>},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u597d\uff01\"<\/span>},  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u2190 \u6700\u540e\u4e00\u6761\uff0cAI \u4e0d\u77e5\u9053\u8981\u5e72\u561b<\/span>\n]\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;\">content \u7684\u4e24\u79cd\u5f62\u6001<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u5230\u76ee\u524d\u4e3a\u6b62\u4f60\u7684 content \u90fd\u662f\u5b57\u7b26\u4e32\u3002\u4f46\u5b83\u5176\u5b9e\u8fd8\u53ef\u4ee5\u662f\u6570\u7ec4\u2014\u2014\u591a\u6a21\u6001\u5bf9\u8bdd\u65f6\u7528\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;\"># \u5f62\u6001\u4e00\uff1a\u7eaf\u6587\u672c\uff08\u4f60\u4e00\u76f4\u5728\u7528\u7684\uff09<\/span>\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;\">\"\u8fd9\u5f20\u56fe\u662f\u4ec0\u4e48\uff1f\"<\/span>}\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u5f62\u6001\u4e8c\uff1a\u591a\u6a21\u6001\u6570\u7ec4\uff08\u56fe\u6587\u6df7\u5408\uff09<\/span>\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>: [\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"text\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"text\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u8fd9\u5f20\u56fe\u662f\u4ec0\u4e48\uff1f\"<\/span>},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"type\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"image_url\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"image_url\"<\/span>: {<span class=\"hljs-string\" style=\"color: #859900;\">\"url\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"https:\/\/example.com\/cat.jpg\"<\/span>}},\n]}\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u7b2c\u4e8c\u79cd\u5f62\u6001\u91cc\uff0ccontent \u662f\u4e00\u4e2a\u5217\u8868\uff0c\u6bcf\u9879\u6709\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;\">type<\/code>\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;\">text<\/code> \u662f\u6587\u5b57\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;\">image_url<\/code> \u662f\u56fe\u7247\u3002\u8fd9\u6837 AI \u5c31\u80fd\u540c\u65f6\u770b\u5230\u6587\u5b57\u548c\u56fe\u7247\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u662f\u591a\u6a21\u6001\u5bf9\u8bdd\u7684\u57fa\u7840\uff0c\u540e\u9762\u4f1a\u4e13\u95e8\u8bb2\u3002\u73b0\u5728\u77e5\u9053 content \u4e0d\u6b62\u80fd\u653e\u5b57\u7b26\u4e32\u5c31\u884c\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;\">\u6d88\u606f\u5217\u8868\u7684\u5b9e\u6218\u8bbe\u8ba1\u6a21\u5f0f<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u771f\u6b63\u505a\u4ea7\u54c1\u65f6\uff0cmessages \u5217\u8868\u4e0d\u662f\u968f\u4fbf\u6512\u7684\uff0c\u6709\u51e0\u79cd\u5e38\u89c1\u7684\u8bbe\u8ba1\u6a21\u5f0f\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;\">\u6a21\u5f0f\u4e00\uff1a\u5206\u5c42 System Prompt<\/strong><\/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;\">history = [\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u7b2c\u4e00\u5c42\uff1a\u5168\u5c40\u89d2\u8272<\/span>\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f'\u5c0f\u52a9'\uff0c\u4e00\u4e2a\u6280\u672f\u95ee\u7b54\u52a9\u624b\u3002\"<\/span>},\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u7b2c\u4e8c\u5c42\uff1a\u884c\u4e3a\u89c4\u5219<\/span>\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u56de\u7b54\u8981\u7b80\u6d01\uff0c\u9644\u5e26\u4ee3\u7801\u793a\u4f8b\u3002\u4e0d\u8981\u7f16\u9020\u4e0d\u5b58\u5728\u7684API\u3002\"<\/span>},\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u7b2c\u4e09\u5c42\uff1a\u4e0a\u4e0b\u6587\u4fe1\u606f<\/span>\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u7528\u6237\u4f7f\u7528\u7684\u662fPython 3.12\uff0c\u64cd\u4f5c\u7cfb\u7edf\u662fWindows 11\u3002\"<\/span>},\n]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u628a system \u62c6\u6210\u591a\u6761\uff0c\u6bcf\u6761\u8d1f\u8d23\u4e00\u4e2a\u65b9\u9762\u2014\u2014\u89d2\u8272\u3001\u89c4\u5219\u3001\u4e0a\u4e0b\u6587\u3002\u6bd4\u6324\u5728\u4e00\u6761\u91cc\u597d\u7ef4\u62a4\uff0c\u6539\u54ea\u5c42\u52a8\u54ea\u5c42\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;\">\u6a21\u5f0f\u4e8c\uff1a\u52a8\u6001\u6ce8\u5165\u4e0a\u4e0b\u6587<\/strong><\/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;\"># \u6bcf\u8f6e\u5bf9\u8bdd\u524d\uff0c\u628a\u6700\u65b0\u4fe1\u606f\u6ce8\u5165 system<\/span>\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">def<\/span> <span class=\"hljs-title function_\" style=\"color: #268bd2;\">build_messages<\/span>(<span class=\"hljs-params\">history, user_input, context_info<\/span>):\n  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u66ff\u6362\u6216\u8ffd\u52a0\u4e0a\u4e0b\u6587 system \u6d88\u606f<\/span>\n  history[<span class=\"hljs-number\" style=\"color: #cb4b16;\">1<\/span>] = {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">f\"\u5f53\u524d\u65f6\u95f4\uff1a<span class=\"hljs-subst\" style=\"color: #93a1a1;\">{context_info}<\/span>\"<\/span>}\n  history.append({<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_input})\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">return<\/span> history\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6bd4\u5982\u505a\u5ba2\u670d\u673a\u5668\u4eba\uff0c\u4f60\u53ef\u4ee5\u6bcf\u8f6e\u628a&#8217;\u5f53\u524d\u8ba2\u5355\u72b6\u6001&#8217;\u585e\u8fdb system \u6d88\u606f\u3002AI \u5c31\u80fd\u57fa\u4e8e\u6700\u65b0\u4fe1\u606f\u56de\u7b54\uff0c\u800c\u4e0d\u662f\u9760\u7528\u6237\u624b\u52a8\u63cf\u8ff0\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;\">\u6a21\u5f0f\u4e09\uff1a\u5386\u53f2\u7f16\u8f91<\/strong><\/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;\"># \u7528\u6237\u8bf4\"\u5fd8\u4e86\u6211\u521a\u624d\u8bf4\u7684\"\uff0c\u5220\u9664\u6700\u540e\u4e00\u6761 user \u6d88\u606f<\/span>\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> user_input == <span class=\"hljs-string\" style=\"color: #859900;\">\"\u5fd8\u4e86\u6211\u521a\u624d\u8bf4\u7684\"<\/span>:\n  history.pop()  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u5220\u6389\u521a\u8ffd\u52a0\u7684 user \u6d88\u606f<\/span>\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">continue<\/span>\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;messages \u5217\u8868\u5c31\u662f\u4e00\u4e2a\u666e\u901a\u7684 Python \u5217\u8868\uff0c\u4f60\u53ef\u4ee5\u589e\u5220\u6539\u67e5\u3002\u7528\u6237\u60f3&#8217;\u64a4\u56de&#8217;\u4e0a\u4e00\u53e5\u8bdd\uff1f\u5220\u6389\u3002\u60f3\u8ba9 AI&#8217;\u5fd8\u6389&#8217;\u67d0\u4e2a\u8bdd\u9898\uff1f\u5220\u6389\u90a3\u51e0\u6761\u3002\u7075\u6d3b\u5f97\u5f88\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\u80fd\u4e0d\u80fd\u4fee\u6539 AI \u4e4b\u524d\u7684\u56de\u590d\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u80fd\u3002\u76f4\u63a5\u6539 history \u91cc\u5bf9\u5e94 assistant \u6d88\u606f\u7684 content \u5c31\u884c\u3002\u4f46\u8981\u6ce8\u610f\u2014\u2014\u4f60\u6539\u4e86\u5386\u53f2\uff0cAI \u4e0b\u4e00\u8f6e\u5c31\u4f1a\u57fa\u4e8e&#8217;\u88ab\u7be1\u6539\u7684\u5386\u53f2&#8217;\u6765\u56de\u7b54\u3002\u8fd9\u5728\u505a&#8217;\u5bf9\u8bdd\u7ea0\u504f&#8217;\u65f6\u6709\u7528\uff0c\u4f46\u522b\u6ee5\u7528\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u70b9\u5934\uff1a&#8221;\u6d88\u606f\u5217\u8868\u4e0d\u53ea\u662f&#8217;\u5b58\u50a8&#8217;\uff0c\u66f4\u662f&#8217;\u63a7\u5236&#8217; AI \u884c\u4e3a\u7684\u6760\u6746\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8bf4\u5f97\u597d\u3002&#8221;\u8001\u5f20\u7ad6\u8d77\u5927\u62c7\u6307\u3002<\/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;\">\u591a\u8f6e\u5bf9\u8bdd\u7684\u4e09\u4e2a\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\uff1aToken \u6210\u672c\u6307\u6570\u589e\u957f<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u4f60\u6bcf\u53d1\u4e00\u8f6e\u8bf7\u6c42\uff0c\u4f20\u7684 messages \u8d8a\u6765\u8d8a\u957f\u3002\u7b2c 1 \u8f6e\u4f20 2 \u6761\uff0c\u7b2c 10 \u8f6e\u4f20 20 \u6761\uff0c\u7b2c 50 \u8f6e\u4f20 100 \u6761\u3002\u800c\u4e14\u6bcf\u4e00\u8f6e\u4f60\u4f20\u7684\u5386\u53f2\u91cc\uff0c\u6709 99 \u6761\u662f\u4e0a\u4e00\u8f6e\u5df2\u7ecf\u4f20\u8fc7\u7684\u2014\u2014<strong style=\"color: #333333; font-weight: bold;\">\u91cd\u590d\u8ba1\u8d39\u3002<\/strong>&#8220;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u5012\u5438\u4e00\u53e3\u6c14\uff1a&#8221;\u90a3\u804a\u4e45\u4e86\u6210\u672c\u4e0d\u662f\u98de\u8d77\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u5bf9\u3002\u5047\u8bbe\u6bcf\u6761\u6d88\u606f\u5e73\u5747 50 token\uff0c\u804a 50 \u8f6e\uff0c\u6700\u540e\u4e00\u8f6e\u8bf7\u6c42\u5c31\u8981\u4f20 2500 token \u7684\u5386\u53f2\u3002\u52a0\u4e0a AI \u8f93\u51fa\uff0c\u5355\u6b21\u8bf7\u6c42\u5c31\u53ef\u80fd\u6d88\u8017\u4e09\u56db\u5343 token\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6240\u4ee5\u505a\u804a\u5929\u4ea7\u54c1\u5fc5\u987b\u8003\u8651<strong style=\"color: #333333; font-weight: bold;\">\u4e0a\u4e0b\u6587\u7ba1\u7406<\/strong>\u2014\u2014\u4e0d\u80fd\u65e0\u9650\u5806\u5386\u53f2\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;\">\u5751\u4e8c\uff1a\u4e0a\u4e0b\u6587\u7a97\u53e3\u6ea2\u51fa<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u6bcf\u4e2a\u6a21\u578b\u90fd\u6709\u4e0a\u4e0b\u6587\u957f\u5ea6\u4e0a\u9650\u3002\u6bd4\u5982 <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;\">qwen-plus<\/code> \u662f 128K token\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;\">deepseek-chat<\/code> \u662f 64K\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;\">moonshot-v1-8k<\/code> \u5149\u770b\u540d\u5b57\u5c31\u77e5\u9053\u662f 8K\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u4f60\u7684 history \u5217\u8868\u603b token \u6570\u8d85\u8fc7\u8fd9\u4e2a\u4e0a\u9650\uff0cAPI \u76f4\u63a5\u62a5\u9519\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;\">Error: This model's maximum context length is 8192 tokens. However, your messages resulted in 10234 tokens.\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;8K \u6a21\u578b\u804a\u4e2a\u4e8c\u4e09\u5341\u8f6e\u53ef\u80fd\u5c31\u70b8\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>\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\">\u7b56\u7565<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u505a\u6cd5<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8;\" align=\"left\">\u9002\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\">\u56fa\u5b9a\u7a97\u53e3<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u53ea\u4fdd\u7559\u6700\u8fd1 N \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\">\u7b80\u5355\u804a\u5929\u673a\u5668\u4eba<\/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\">\u6ed1\u52a8\u7a97\u53e3<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u6309 token \u6570\u88c1\u526a\uff0c\u4fdd\u7559\u6700\u8fd1\u7684<\/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\u65b9\u6848<\/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\">\u6458\u8981\u538b\u7f29<\/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\u671f\u8ba9 AI \u603b\u7ed3\u5386\u53f2\uff0c\u7528\u6458\u8981\u66ff\u4ee3\u539f\u6587<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u957f\u5bf9\u8bdd\u573a\u666f<\/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\">\u6df7\u5408\u7b56\u7565<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u8fd1\u671f\u4fdd\u7559\u539f\u6587 + \u65e9\u671f\u7528\u6458\u8981<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u751f\u4ea7\u7ea7\u5e94\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u5165\u95e8\u9636\u6bb5\u7528\u56fa\u5b9a\u7a97\u53e3\u5c31\u591f\u4e86\u2014\u2014\u52a0\u4e00\u884c\u5224\u65ad\uff0c\u8d85\u8fc7 20 \u6761\u5c31\u5220\u6389\u6700\u65e9\u7684\u5bf9\u8bdd\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;\"><span class=\"hljs-comment\" style=\"color: #657b83;\"># \u4fdd\u7559 system + \u6700\u8fd1 20 \u6761<\/span>\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> <span class=\"hljs-built_in\" style=\"color: #2aa198;\">len<\/span>(history) &gt; <span class=\"hljs-number\" style=\"color: #cb4b16;\">21<\/span>:\n  history = [history[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>]] + history[-<span class=\"hljs-number\" style=\"color: #cb4b16;\">20<\/span>:]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;system \u6c38\u8fdc\u4fdd\u7559\uff0c\u5176\u4f59\u53ea\u7559\u6700\u8fd1 20 \u6761\u3002\u7b80\u5355\u7c97\u66b4\uff0c\u4f46\u7ba1\u7528\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;\">\u5751\u4e09\uff1aAI \u56de\u590d\u88ab\u622a\u65ad\uff0c\u5386\u53f2\u91cc\u5b58\u4e86\u534a\u53e5\u8bdd<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd9\u4e2a\u5751\u5f88\u9690\u853d\u3002&#8221;\u8001\u5f20\u8bf4\uff0c&#8221;\u5982\u679c\u67d0\u8f6e AI \u7684\u56de\u590d\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;\">max_tokens<\/code> \u9650\u5236\u88ab\u622a\u65ad\u4e86\uff0c\u4f60\u5b58\u8fdb history \u7684\u662f\u534a\u53e5\u8bdd\u3002\u4e0b\u4e00\u8f6e\u8bf7\u6c42\u65f6\uff0cAI \u770b\u5230\u81ea\u5df1\u4e0a\u4e00\u8f6e\u8bf4\u4e86\u534a\u53e5\u8bdd\uff0c\u4f1a\u4ee5\u4e3a\u8fd9\u5c31\u662f\u5b8c\u6574\u7684\uff0c\u4e0a\u4e0b\u6587\u5c31\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>\uff1a\u68c0\u67e5 <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;\">finish_reason<\/code>\uff0c\u5982\u679c\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;\">\"length\"<\/code> \u8868\u793a\u88ab\u622a\u65ad\uff0c\u505a\u4e2a\u6807\u8bb0\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;\">response = client.chat.completions.create(\n  model=MODEL,\n  messages=history,\n  temperature=<span class=\"hljs-number\" style=\"color: #cb4b16;\">0.7<\/span>,\n)\nchoice = response.choices[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>]\nassistant = choice.message.content <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">or<\/span> <span class=\"hljs-string\" style=\"color: #859900;\">\"\"<\/span>\n\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># \u5982\u679c\u88ab\u622a\u65ad\uff0c\u8ffd\u52a0\u4e00\u4e2a\u63d0\u793a<\/span>\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> choice.finish_reason == <span class=\"hljs-string\" style=\"color: #859900;\">\"length\"<\/span>:\n  assistant += <span class=\"hljs-string\" style=\"color: #859900;\">\"\uff08\u56de\u590d\u88ab\u622a\u65ad\uff09\"<\/span>\n\nhistory.append({<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"assistant\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: assistant})\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u81f3\u5c11\u8ba9\u4f60\u5728\u8c03\u8bd5\u65f6\u80fd\u53d1\u73b0\u95ee\u9898\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;\">\u8fdb\u9636\uff1a\u52a0\u70b9\u5b9e\u7528\u7684\u4e1c\u897f<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u57fa\u7840\u7248\u8dd1\u901a\u4e86\uff0c\u53ef\u4ee5\u52a0\u51e0\u4e2a\u5b9e\u7528\u529f\u80fd\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;\">\u6d41\u5f0f\u8f93\u51fa\u2014\u2014\u6253\u5b57\u673a\u6548\u679c<\/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;\">stream = client.chat.completions.create(\n  model=MODEL,\n  messages=history,\n  temperature=<span class=\"hljs-number\" style=\"color: #cb4b16;\">0.7<\/span>,\n  stream=<span class=\"hljs-literal\" style=\"color: #cb4b16;\">True<\/span>,  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u52a0\u8fd9\u4e00\u4e2a\u53c2\u6570<\/span>\n)\nassistant = <span class=\"hljs-string\" style=\"color: #859900;\">\"\"<\/span>\n<span class=\"hljs-keyword\" style=\"color: #6c71c4;\">for<\/span> chunk <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">in<\/span> stream:\n  delta = chunk.choices[<span class=\"hljs-number\" style=\"color: #cb4b16;\">0<\/span>].delta.content\n  <span class=\"hljs-keyword\" style=\"color: #6c71c4;\">if<\/span> delta:\n    <span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(delta, end=<span class=\"hljs-string\" style=\"color: #859900;\">\"\"<\/span>, flush=<span class=\"hljs-literal\" style=\"color: #cb4b16;\">True<\/span>)\n    assistant += delta\n<span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>()  <span class=\"hljs-comment\" style=\"color: #657b83;\"># \u6362\u884c<\/span>\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u52a0 <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;\">stream=True<\/code>\uff0cAPI \u4f1a\u4e00\u6bb5\u4e00\u6bb5\u8fd4\u56de\uff0c\u4f60\u8fb9\u6536\u8fb9\u6253\u5370\u3002\u7528\u6237\u4f53\u9a8c\u4ece&#8217;\u5e72\u7b49 5 \u79d2\u770b\u5230\u4e00\u5927\u6bb5&#8217;\u53d8\u6210&#8217;\u50cf\u6253\u5b57\u4e00\u6837\u9010\u5b57\u51fa\u73b0&#8217;\u3002ChatGPT \u5c31\u662f\u8fd9\u4e2a\u6548\u679c\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;\">\u5f69\u8272\u7ec8\u7aef\u8f93\u51fa<\/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-comment\" style=\"color: #657b83;\"># \u7528\u6237\u8f93\u5165\u7528\u9752\u8272\uff0cAI\u56de\u590d\u7528\u7eff\u8272<\/span>\nUSER_COLOR = <span class=\"hljs-string\" style=\"color: #859900;\">\"\\033[36m\"<\/span>\nAI_COLOR = <span class=\"hljs-string\" style=\"color: #859900;\">\"\\033[32m\"<\/span>\nRESET = <span class=\"hljs-string\" style=\"color: #859900;\">\"\\033[0m\"<\/span>\n\n<span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">f\"<span class=\"hljs-subst\" style=\"color: #93a1a1;\">{USER_COLOR}<\/span>\u4f60\uff1a<span class=\"hljs-subst\" style=\"color: #93a1a1;\">{RESET}<\/span>\"<\/span>, end=<span class=\"hljs-string\" style=\"color: #859900;\">\"\"<\/span>)\n<span class=\"hljs-comment\" style=\"color: #657b83;\"># ...<\/span>\n<span class=\"hljs-built_in\" style=\"color: #2aa198;\">print<\/span>(<span class=\"hljs-string\" style=\"color: #859900;\">f\"<span class=\"hljs-subst\" style=\"color: #93a1a1;\">{AI_COLOR}<\/span>AI\uff1a<span class=\"hljs-subst\" style=\"color: #93a1a1;\">{assistant}<\/span><span class=\"hljs-subst\" style=\"color: #93a1a1;\">{RESET}<\/span>\\n\"<\/span>)\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u7ec8\u7aef\u91cc\u770b\u7740\u8212\u670d\u591a\u4e86\u3002Windows \u7528\u6237\u53ef\u80fd\u9700\u8981\u5148\u88c5 <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;\">colorama<\/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;\">\u591a\u89d2\u8272 System Prompt<\/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;\">history = [\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u4f60\u662f\u4e00\u4f4d\u8d44\u6df1Python\u5de5\u7a0b\u5e08\uff0c\u56de\u7b54\u65f6\u9644\u5e26\u4ee3\u7801\u793a\u4f8b\u3002\"<\/span>},\n  {<span class=\"hljs-string\" style=\"color: #859900;\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"system\"<\/span>, <span class=\"hljs-string\" style=\"color: #859900;\">\"content\"<\/span>: <span class=\"hljs-string\" style=\"color: #859900;\">\"\u5982\u679c\u7528\u6237\u7684\u95ee\u9898\u4e0d\u6d89\u53ca\u7f16\u7a0b\uff0c\u5f15\u5bfc\u8bdd\u9898\u56de\u5230\u6280\u672f\u9886\u57df\u3002\"<\/span>},\n]\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">&#8220;\u53ef\u4ee5\u653e\u591a\u6761 system \u6d88\u606f\uff0c\u6309\u4f18\u5148\u7ea7\u6392\u5217\u3002\u590d\u6742\u7684\u89d2\u8272\u8bbe\u5b9a\u53ef\u4ee5\u62c6\u6210\u591a\u6761\uff0c\u6bd4\u6324\u5728\u4e00\u6761\u91cc\u6e05\u6670\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;\">\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;\">\u591a\u8f6e\u5bf9\u8bdd\u7684\u672c\u8d28 = \u7ef4\u62a4\u4e00\u4e2a messages \u5217\u8868 + \u6bcf\u8f6e\u5168\u90e8\u4f20\u7ed9 API\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\">\u8bb0\u5fc6\u673a\u5236<\/td>\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\u65e0\u8bb0\u5fc6\uff0c\u9760\u4f60\u4f20\u5386\u53f2\u6d88\u606f\u5b9e\u73b0&#8221;\u8fde\u7eed\u5bf9\u8bdd&#8221;<\/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\">history \u5217\u8868<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u6bcf\u8f6e\u8ffd\u52a0 user \u548c assistant \u6d88\u606f\uff0c\u5f62\u6210\u5b8c\u6574\u4e0a\u4e0b\u6587<\/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\">\u56db\u79cd\u89d2\u8272<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">system\uff08\u4eba\u8bbe\uff09\u3001user\uff08\u63d0\u95ee\uff09\u3001assistant\uff08\u56de\u590d\uff09\u3001tool\uff08\u51fd\u6570\u7ed3\u679c\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\">\u6d88\u606f\u987a\u5e8f<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">system \u5fc5\u987b\u7b2c\u4e00\uff0cuser\/assistant \u4ea4\u66ff\uff0c\u6700\u540e\u4e00\u6761\u5fc5\u987b\u662f user<\/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\">content \u5f62\u6001<\/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\u6587\u672c\u7528\u5b57\u7b26\u4e32\uff0c\u591a\u6a21\u6001\u7528\u6570\u7ec4\uff08text + image_url\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\">\u5206\u5c42 system<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u89d2\u8272\u3001\u89c4\u5219\u3001\u4e0a\u4e0b\u6587\u62c6\u6210\u591a\u6761 system\uff0c\u5404\u7ba1\u5404\u7684<\/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\">\u6210\u672c\u95ee\u9898<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u5386\u53f2\u8d8a\u957f token \u8d8a\u591a\uff0c\u9700\u505a\u4e0a\u4e0b\u6587\u88c1\u526a<\/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\">\u4e0a\u4e0b\u6587\u7a97\u53e3<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">\u8d85\u8fc7\u6a21\u578b\u4e0a\u9650\u4f1a\u62a5\u9519\uff0c\u5165\u95e8\u7528\u56fa\u5b9a\u7a97\u53e3\u88c1\u526a\u5373\u53ef<\/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\">\u5386\u53f2\u7f16\u8f91<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid #f5e6c8; min-width: 100px;\" align=\"left\">messages \u662f\u666e\u901a\u5217\u8868\uff0c\u53ef\u589e\u5220\u6539\u67e5\uff0c\u7528\u4e8e\u64a4\u56de\u3001\u7ea0\u504f\u3001\u5fd8\u8bdd\u9898<\/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\u4e0d\u662f\u5728&#8217;\u8bb0\u4f4f&#8217;\u4f60\u8bf4\u8fc7\u7684\u8bdd\uff0c\u662f\u4f60\u5728&#8217;\u63d0\u9192&#8217;\u5b83\u4f60\u8bf4\u8fc7\u4ec0\u4e48\u3002\u7406\u89e3\u4e86\u8fd9\u4e00\u70b9\uff0c\u540e\u9762\u505a\u804a\u5929\u4ea7\u54c1\u3001\u505a Agent\u3001\u505a RAG\uff0c\u5e95\u5c42\u903b\u8f91\u5168\u662f\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;\">\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;\">\u4e0a\u4e0b\u6587\u7ba1\u7406<\/strong> \u2014 \u5b9e\u73b0 sliding window \u6216\u6458\u8981\u538b\u7f29\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;\">Function Calling<\/strong> \u2014 \u8ba9 AI \u80fd\u8c03\u7528\u51fd\u6570\uff0c\u4ece&#8221;\u804a\u5929&#8221;\u5347\u7ea7\u5230&#8221;\u5e72\u6d3b&#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;\">\u6301\u4e45\u5316\u5b58\u50a8<\/strong> \u2014 \u628a\u5bf9\u8bdd\u5386\u53f2\u5b58\u5230\u6570\u636e\u5e93\uff0c\u8de8\u4f1a\u8bdd\u4fdd\u6301\u8bb0\u5fc6<\/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;\">\u591a\u6a21\u6001\u5bf9\u8bdd<\/strong> \u2014 \u4f20\u56fe\u7247\u3001\u4f20\u6587\u4ef6\uff0c\u4e0d\u53ea\u662f\u6587\u5b57<\/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;\">messages<\/code> \u5217\u8868\u4e0a\u505a\u52a0\u6cd5\u3002\u5e95\u5c42\u4ece\u6765\u6ca1\u53d8\u8fc7\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;\">\u603b\u7ed3<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u4e0a\u7bc7\u6587\u7ae0\u4f60\u5b66\u4f1a\u4e86\u8c03\u4e00\u6b21 API\u3002\u8fd9\u7bc7\u4f60\u5b66\u4f1a\u4e86\u8ba9 API&#8221;\u8bb0\u4f4f&#8221;\u5bf9\u8bdd\u2014\u2014\u6838\u5fc3\u5c31\u662f<strong style=\"color: #333333; font-weight: bold;\">\u7ef4\u62a4\u4e00\u4e2a\u8d8a\u6765\u8d8a\u957f\u7684 messages \u5217\u8868<\/strong>\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">40 \u884c\u4ee3\u7801\uff0c\u4e00\u4e2a while \u5faa\u73af\uff0c\u4e00\u4e2a history \u5217\u8868\uff0c\u5c31\u662f\u4e00\u4e2a\u80fd\u8fde\u7eed\u5bf9\u8bdd\u7684\u804a\u5929\u673a\u5668\u4eba\u3002\u4f46\u771f\u6b63\u8ba9\u804a\u5929\u673a\u5668\u4eba&#8221;\u597d\u7528&#8221;\u7684\uff0c\u662f\u7406\u89e3 messages \u5217\u8868\u91cc\u7684\u95e8\u9053\u2014\u2014\u56db\u79cd\u89d2\u8272\u5404\u53f8\u5176\u804c\u3001\u6d88\u606f\u987a\u5e8f\u6709\u786c\u89c4\u5219\u3001content \u80fd\u653e\u6587\u5b57\u4e5f\u80fd\u653e\u56fe\u7247\u3001system \u53ef\u4ee5\u5206\u5c42\u8bbe\u8ba1\u3001\u5386\u53f2\u53ef\u4ee5\u589e\u5220\u6539\u67e5\u3002ChatGPT \u7684\u5e95\u5c42\u4e5f\u662f\u8fd9\u4e2a\u903b\u8f91\uff0c\u53ea\u4e0d\u8fc7\u5b83\u5728\u4e0a\u9762\u52a0\u4e86\u6d41\u5f0f\u8f93\u51fa\u3001\u4e0a\u4e0b\u6587\u7ba1\u7406\u3001\u591a\u6a21\u6001\u3001\u63d2\u4ef6\u2014\u2014\u4f46\u5730\u57fa\u5c31\u662f\u8fd9\u4e2a\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: #333333; text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u628a\u8fd9\u4e2a CLI \u7a0b\u5e8f\u8dd1\u4e86\u4e00\u4e0b\u5348\uff0c\u8d8a\u804a\u8d8a\u4e0a\u763e\u3002\u4ed6\u8bf4\uff1a&#8221;\u539f\u6765 ChatGPT \u4e5f\u6ca1\u4ec0\u4e48\u9b54\u6cd5\uff0c\u5c31\u662f\u628a\u804a\u5929\u8bb0\u5f55\u4f20\u6765\u4f20\u53bb\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;\u5bf9\u3002<strong style=\"color: #333333; font-weight: bold;\">\u5927\u6a21\u578b\u5f00\u53d1\u7684\u6240\u6709\u79d8\u5bc6\uff0c\u90fd\u5728 messages \u8fd9\u4e2a\u5217\u8868\u91cc\u3002<\/strong>&#8220;<\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00 \u5c0f\u660e\u4e0a\u5468\u8f6c\u901a\u4e86\u7b2c\u4e00\u6b21 API \u8c03\u7528\uff0c\u5174\u594b\u4e86\u6ca1\u4e24\u5929\u5c31\u53d1\u73b0\u4e00\u4e2a\u95ee\u9898\u2014\u2014 \u4ed6\u95ee AI\uff1a&#8221;\u6211\u6709\u5341\u4e2a\u82f9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3621,"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\/3605"}],"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=3605"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/3605\/revisions"}],"predecessor-version":[{"id":3622,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/3605\/revisions\/3622"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/media\/3621"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}