{"id":3781,"date":"2026-08-17T15:15:58","date_gmt":"2026-08-17T07:15:58","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=3781"},"modified":"2026-08-17T15:15:58","modified_gmt":"2026-08-17T07:15:58","slug":"agent-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%ef%bc%9a%e5%9b%9b%e6%ad%a5%e8%b7%91%e9%80%9a-create_agent","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=3781","title":{"rendered":"Agent \u5feb\u901f\u5165\u95e8\uff1a\u56db\u6b65\u8dd1\u901a create_agent"},"content":{"rendered":"<section id=\"wenyan\" data-provider=\"WenYan\" style=\"font-family: system-ui, &quot;Apple Color Emoji&quot;, &quot;Segoe UI&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Sans&quot;, Roboto, sans-serif; word-break: break-word; overflow-wrap: break-word; color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75; caret-color: rgb(0, 0, 0);\">\n<blockquote style=\"color: rgb(85, 85, 85); background-color: rgb(255, 249, 235); 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 rgb(248, 180, 63); border-radius: 6px; font-style: normal; quotes: none;\">\n<p style=\"margin: 0.55em 0px; color: rgb(85, 85, 85); text-indent: 0px; padding: 0px; line-height: 1.75; font-style: normal; background: transparent;\">\u4e0a\u7bc7\u4f60\u8ba4\u6e05\u4e86 LangChain \u662f\u7f16\u6392\u5c42\u2014\u2014\u516d\u5927\u6a21\u5757\u3001LCEL\u3001Agent \u4e09\u9636\u6bb5\u3002\u5730\u56fe\u6709\u4e86\uff0c\u8be5\u52a8\u624b\u63d2\u7b2c\u4e00\u5757\u300c\u624b\u811a\u300d\u3002\u8fd9\u7bc7\u8bb2\u6700\u5c0f Agent\uff1a\u52a0\u8f7d\u73af\u5883 \u2192 \u5b9a\u4e49\u5de5\u5177 \u2192 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">create_agent<\/code> \u2192 \u8c03\u7528\u3002<\/p>\n<\/blockquote>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5c0f\u660e\u5361\u5728\u300c\u4e00\u8f6e\u5de5\u5177\u300d<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u4e0a\u7bc7\u4e4b\u540e\uff0c\u5c0f\u660e\u7528LangChain\u6846\u67b6\u8dd1\u901a\u4e86\u300c\u67e5\u4e00\u6b21\u5929\u6c14\u300d\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\">\u95ee\u9898: \u676d\u5dde\u4eca\u5929\u5929\u6c14\u600e\u4e48\u6837\uff1f\ntool_calls: [{'name': 'get_weather', 'args': {'city': '\u676d\u5dde'}, ...}]\n\u6267\u884c\u5de5\u5177 get_weather({'city': '\u676d\u5dde'})\n\u5de5\u5177\u7ed3\u679c: \u5c0f\u96e8\uff0c17\u00b0C\uff0c\u4e1c\u5317\u98ce2\u7ea7\n\u6700\u7ec8\u56de\u7b54: \u676d\u5dde\u4eca\u5929\u5c0f\u96e8\uff0c17\u00b0C\u2026\u2026\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u4ed6\u5f97\u610f\u4e86\u4e00\u4f1a\u513f\uff0c\u53c8\u6254\u4e86\u4e00\u4e2a\u95ee\u9898\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\">\u5148\u67e5\u5317\u4eac\u5929\u6c14\uff0c\u518d\u7b97 10+20\uff0c\u6700\u540e\u7528\u4e00\u53e5\u8bdd\u603b\u7ed3\u3002\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u300c\u53ea\u8dd1\u4e00\u8f6e\u300d\u7684\u903b\u8f91\u7acb\u523b\u9732\u9985\uff1a\u6a21\u578b\u8981\u4e48\u53ea\u67e5\u4e86\u5929\u6c14\uff0c\u8981\u4e48\u7b97\u5b8c\u6570\u5c31\u4e0d\u603b\u7ed3\uff1b\u4ed6\u60f3\u8ba9 Agent <strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u81ea\u5df1\u51b3\u5b9a\u8c03\u51e0\u6b21\u5de5\u5177<\/strong>\uff0c\u96be\u5230\u53c8\u5f97\u628a\u4ee5\u524d\u624b\u5199\u7684 ReAct \u5faa\u73af\u6284\u8fc7\u6765\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u53bb\u627e\u8001\u5f20\uff1a&#8221;\u4e0a\u7bc7\u8bf4 Agent \u662f\u6307\u6325\u5b98\u3002LangChain \u6709\u6ca1\u6709\u73b0\u6210\u7684\u6307\u6325\u5b98\uff0c\u522b\u8ba9\u6211\u6bcf\u6b21\u624b\u5199 for \u5faa\u73af\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u6709\u3002\u56db\u4e2a\u5b57\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">create_agent<\/code>\u3002Models + Tools \u4ea4\u7ed9\u5b83\uff0c\u5faa\u73af\u5b83\u5e2e\u4f60\u8dd1\u3002&#8221;<\/p>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u4ec0\u4e48\u662f create_agent<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u5728\u767d\u677f\u4e0a\u753b\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\">\u4f60\u63d0\u4f9b\uff1a\n  Model\uff08\u5927\u8111\uff09 + Tools\uff08\u624b\u811a\uff09[+ system_prompt]\n    \u2193\n   create_agent(...)\n    \u2193\n\u6846\u67b6\u5185\u90e8\u5faa\u73af\uff1a\n  \u6a21\u578b\u51b3\u7b56 \u2192 \u6709 tool_calls\uff1f\n    \u2502\u662f        \u2502\u5426\n    \u2193        \u2193\n  \u6267\u884c\u5de5\u5177\u5e76\u56de\u586b    \u8f93\u51fa\u6700\u7ec8\u56de\u7b54\n    \u2193\n  \u518d\u95ee\u6a21\u578b\u2026\u2026\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;\u8fd8\u8bb0\u5f97\u624b\u5199 Function Calling \u5417\uff1f\u4f60\u81ea\u5df1\u5199\uff1a<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">if tool_calls \u2192 \u6267\u884c \u2192 \u5582\u56de\u53bb \u2192 \u518d\u8c03\u6a21\u578b<\/code><\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">create_agent<\/code> \u628a\u8fd9\u5957\u5faa\u73af\u6536\u8fdb\u6846\u67b6\u3002\u4f60\u8d1f\u8d23<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u96f6\u4ef6<\/strong>\uff0c\u6846\u67b6\u8d1f\u8d23<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5f15\u64ce<\/strong>\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">create_agent<\/code> \u7ed9\u5b9e\u4e60\u751f\u4e00\u5f20\u5de5\u5177\u6e05\u5355\uff0c\u8ba9\u4ed6\u81ea\u5df1\u51b3\u5b9a\u67e5\u51e0\u6b21\u3001\u7b97\u51e0\u6b21\uff0c\u76f4\u5230\u80fd\u4ea4\u5dee\u3002&#8221;<\/p>\n<table style=\"display: inline-block !important; width: auto; max-width: 100%; overflow: auto; border-spacing: 0px; border-collapse: collapse; margin: 1rem 0px;\">\n<thead style=\"background: rgb(255, 249, 235); color: rgb(51, 51, 51); text-align: left;\">\n<tr>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u7ef4\u5ea6<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u4e00\u8f6e bind_tools<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">create_agent<\/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 rgb(245, 230, 200); min-width: 100px;\">\u8c01\u5199\u5faa\u73af<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u4f60<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u6846\u67b6<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u5de5\u5177\u8c03\u7528\u6b21\u6570<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u6700\u591a\u4e00\u8f6e\uff08\u4ee3\u7801\u5199\u6b7b\uff09<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u591a\u6b65\uff0c\u76f4\u5230\u65e0 tool_calls<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u4f60\u8981\u51c6\u5907\u7684<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">Model + Tools + \u624b\u5199\u56de\u586b<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">Model + Tools\uff08+ system_prompt\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u9002\u5408<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u770b\u6e05\u534f\u8bae\u957f\u4ec0\u4e48\u6837<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u6700\u5c0f\u53ef\u7528 Agent<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u5bf9\u7167\u624b\u5199<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u5355\u6b65 FC<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u6846\u67b6\u7248 ReAct \u5faa\u73af<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\uff1a&#8221;\u4f9d\u8d56\u8981\u88c5\u5565\uff1f&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8221; <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">requirements.txt<\/code> \u91cc\u8fd9\u51e0\u6837\u5c31\u591f\u5165\u95e8\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-text\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\">openai&gt;=1.30.0\nlangchain&gt;=1.3.14\nlangchain-openai&gt;=1.4.0\npydantic&gt;=2.0.0\npython-dotenv&gt;=1.0.0\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u5b89\u88c5\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-bash\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\">pip install -r requirements.txt\n<span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\"># \u6216\u6e05\u534e\u6e90<\/span>\npip install -r requirements.txt -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u7136\u540e\u8bb0\u4f4f\u56db\u6b65\u53e3\u8bc0\uff1a<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u73af\u5883 \u2192 \u5de5\u5177 \u2192 Agent \u2192 \u8c03\u7528<\/strong>\u3002&#8221;<\/p>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u4ee3\u7801\u62c6\u89e3\uff1a\u56db\u6b65\u6700\u5c0f Agent<\/span><\/h2>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u7b2c\u4e00\u6b65\uff1a\u52a0\u8f7d\u73af\u5883\u53d8\u91cf\uff08\u6a21\u578b\u5de5\u5382\uff09<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">llm.py<\/code>\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">import<\/span> os\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">from<\/span> dotenv <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">import<\/span> load_dotenv\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">from<\/span> langchain_openai <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">import<\/span> ChatOpenAI\n\nload_dotenv()\n\n\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">def<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">get_chat_model<\/span>(<span class=\"hljs-params\">*, temperature: <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">float<\/span> = <span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">0<\/span><\/span>) -&gt; ChatOpenAI:\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">return<\/span> ChatOpenAI(\n    model=os.environ.get(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"OPENAI_MODEL\"<\/span>, <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"qwen-plus\"<\/span>),\n    api_key=os.environ[<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"OPENAI_API_KEY\"<\/span>],\n    base_url=os.environ.get(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"OPENAI_BASE_URL\"<\/span>),\n    temperature=temperature,\n  )\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;<code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">.env<\/code> \u91cc\u653e\u597d <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">OPENAI_API_KEY<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">OPENAI_BASE_URL<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">OPENAI_MODEL<\/code>\u3002Agent \u6e29\u5ea6\u5efa\u8bae\u5148 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">0<\/code>\uff0c\u5c11\u80e1\u7f16\u3001\u597d\u590d\u73b0\u3002&#8221;<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u7b2c\u4e8c\u6b65\uff1a\u5b9a\u4e49\u5de5\u5177<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tools.py<\/code>\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">from<\/span> langchain.tools <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">import<\/span> tool\n\n\n<span class=\"hljs-meta\" style=\"color: rgb(211, 54, 130);\">@tool<\/span>\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">def<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">get_weather<\/span>(<span class=\"hljs-params\">city: <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span><\/span>) -&gt; <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span>:\n  <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\"\"\u67e5\u8be2\u57ce\u5e02\u5929\u6c14\uff08\u6a21\u62df\uff09\u3002\"\"\"<\/span>\n  data = {<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u676d\u5dde\"<\/span>: <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u5c0f\u96e8\uff0c17\u00b0C\"<\/span>, <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u5317\u4eac\"<\/span>: <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u6674\uff0c15\u00b0C\"<\/span>, <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u4e0a\u6d77\"<\/span>: <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u591a\u4e91\uff0c18\u00b0C\"<\/span>}\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">return<\/span> data.get(city, <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">f\"<span class=\"hljs-subst\" style=\"color: rgb(147, 161, 161);\">{city}<\/span>\uff1a\u6674\uff0c20\u00b0C\uff08\u6a21\u62df\uff09\"<\/span>)\n\n\n<span class=\"hljs-meta\" style=\"color: rgb(211, 54, 130);\">@tool<\/span>\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">def<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">add<\/span>(<span class=\"hljs-params\">a: <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">float<\/span>, b: <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">float<\/span><\/span>) -&gt; <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span>:\n  <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\"\"\u8ba1\u7b97\u4e24\u6570\u4e4b\u548c\u3002\"\"\"<\/span>\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">return<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span>(a + b)\n\n\nTOOLS = [get_weather, add]\nTOOL_MAP = {t.name: t <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">for<\/span> t <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">in<\/span> TOOLS}\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;<code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">@tool<\/code> \u628a\u51fd\u6570\u540d\u3001\u53c2\u6570\u3001\u6587\u6863\u5b57\u7b26\u4e32\u53d8\u6210\u6a21\u578b\u80fd\u770b\u61c2\u7684 schema\u3002<code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">TOOLS<\/code> \u4ea4\u7ed9 Agent\uff1b<code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">TOOL_MAP<\/code> \u7559\u7ed9\u624b\u5199\u5faa\u73af\u6309\u540d\u5b57\u67e5\u627e\u2014\u2014\u6846\u67b6\u8def\u5f84\u5176\u5b9e\u53ea\u9700\u8981 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">TOOLS<\/code>\u3002\u5148\u7528\u4e0a\uff0c\u5de5\u5177\u4e00\u7ae0\u518d\u8be6\u7ec6\u4ecb\u7ecd&#8221;<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u7b2c\u4e09\u6b65 + \u7b2c\u56db\u6b65\uff1acreate_agent \u5e76\u8c03\u7528<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">agent_loop.py<\/code> \u91cc\u7684\u6846\u67b6\u7248\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">from<\/span> langchain.agents <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">import<\/span> create_agent\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">from<\/span> llm <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">import<\/span> get_chat_model\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">from<\/span> tools <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">import<\/span> TOOLS\n\n\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">def<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">run_create_agent<\/span>(<span class=\"hljs-params\">question: <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span><\/span>) -&gt; <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span>:\n  <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\"\"\u6846\u67b6\u5e2e\u4f60\u5199\u5faa\u73af\u3002\"\"\"<\/span>\n  agent = create_agent(\n    get_chat_model(temperature=<span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">0<\/span>),\n    tools=TOOLS,\n    system_prompt=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u4f60\u662f\u52a9\u624b\u3002\u9700\u8981\u67e5\u5929\u6c14\u6216\u505a\u52a0\u6cd5\u65f6\u5fc5\u987b\u8c03\u7528\u5de5\u5177\uff0c\u4e0d\u8981\u7f16\u9020\u3002\"<\/span>,\n  )\n  result = agent.invoke({<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"messages\"<\/span>: [{<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"role\"<\/span>: <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"user\"<\/span>, <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"content\"<\/span>: question}]})\n  last = result[<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"messages\"<\/span>][-<span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">1<\/span>]\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">return<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">getattr<\/span>(last, <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"content\"<\/span>, <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span>(last)) <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">or<\/span> <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\"<\/span>\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;\u9010\u884c\u770b\uff1a<\/p>\n<ol style=\"margin: 8px 0px; padding-left: 28px; list-style: outside decimal;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">create_agent(model, tools=..., system_prompt=...)<\/code> \u2014\u2014 \u5927\u8111 + \u624b\u811a + \u4eba\u8bbe  <\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">invoke({\\\"messages\\\": [...]})<\/code> \u2014\u2014 \u8f93\u5165\u662f\u6d88\u606f\u5217\u8868\uff0c\u4e0d\u662f\u88f8\u5b57\u7b26\u4e32  <\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section>\u8fd4\u56de\u503c\u91cc\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">messages<\/code> \u662f\u6574\u6bb5\u8f68\u8ff9\uff1b\u53d6\u6700\u540e\u4e00\u6761\u5f53\u6700\u7ec8\u56de\u7b54<\/section>\n<\/li>\n<\/ol>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u5de5\u4f5c\u539f\u7406\u5fc3\u667a\u6a21\u578b\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\">\u7528\u6237\u95ee\u9898\n   \u2193\n\u6a21\u578b\uff1a\u8981\u4e0d\u8981\u7528\u5de5\u5177\uff1f\n   \u251c\u2500 \u8981 \u2192 tool_calls \u2192 \u6846\u67b6\u6267\u884c TOOLS \u2192 ToolMessage \u56de\u586b \u2192 \u518d\u95ee\u6a21\u578b\n   \u2514\u2500 \u4e0d\u8981 \u2192 \u76f4\u63a5\u81ea\u7136\u8bed\u8a00\u7ed3\u675f\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u8fd9\u548c\u4f60\u624b\u5199 ReAct \u662f\u540c\u4e00\u4ef6\u4e8b\uff0c\u53ea\u662f\u5faa\u73af\u5728\u6846\u67b6\u91cc\u3002&#8221;<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5bf9\u7167\uff1a\u624b\u5199\u5faa\u73af\u957f\u4ec0\u4e48\u6837<\/span><\/h3>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">def<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">run_handwritten_loop<\/span>(<span class=\"hljs-params\">question: <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span>, max_steps: <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">int<\/span> = <span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">5<\/span><\/span>) -&gt; <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span>:\n  model = get_chat_model(temperature=<span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">0<\/span>)\n  model_with_tools = model.bind_tools(TOOLS)\n  messages = [HumanMessage(content=question)]\n\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">for<\/span> step <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">in<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">range<\/span>(<span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">1<\/span>, max_steps + <span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">1<\/span>):\n    <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">print<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">f\"[\u624b\u5199\u5faa\u73af \u6b65\u9aa4 <span class=\"hljs-subst\" style=\"color: rgb(147, 161, 161);\">{step}<\/span>\/<span class=\"hljs-subst\" style=\"color: rgb(147, 161, 161);\">{max_steps}<\/span>]\"<\/span>)\n    ai = model_with_tools.invoke(messages)\n    messages.append(ai)\n\n    <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">if<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">not<\/span> ai.tool_calls:\n      <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">return<\/span> ai.content <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">or<\/span> <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\"<\/span>\n\n    <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">for<\/span> tc <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">in<\/span> ai.tool_calls:\n      <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">print<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">f\"  \u2192 <span class=\"hljs-subst\" style=\"color: rgb(147, 161, 161);\">{tc[<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">'name'<\/span>]}<\/span>(<span class=\"hljs-subst\" style=\"color: rgb(147, 161, 161);\">{tc[<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">'args'<\/span>]}<\/span>)\"<\/span>)\n      result = TOOL_MAP[tc[<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"name\"<\/span>]].invoke(tc[<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"args\"<\/span>])\n      <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">print<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">f\"  \u2190 <span class=\"hljs-subst\" style=\"color: rgb(147, 161, 161);\">{result}<\/span>\"<\/span>)\n      messages.append(ToolMessage(content=<span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">str<\/span>(result), tool_call_id=tc[<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"id\"<\/span>]))\n\n  <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">print<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"[\u624b\u5199\u5faa\u73af] \u8fbe\u5230 max_steps\uff0c\u5f3a\u5236\u6536\u5c3e\"<\/span>)\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">return<\/span> get_chat_model(temperature=<span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">0<\/span>).invoke(messages).content <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">or<\/span> <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\"<\/span>\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;\u8bfe\u4ef6\u6545\u610f\u628a\u4e24\u6761\u8def\u653e\u4e00\u8d77\uff1a<\/p>\n<ul style=\"margin: 8px 0px; padding-left: 28px; list-style: outside disc;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u624b\u5199<\/strong>\uff1a\u770b\u6e05\u505c\u6b62\u6761\u4ef6\u2014\u2014\u65e0 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">tool_calls<\/code> \u7ed3\u675f\uff1b\u6b65\u6570\u7528\u5c3d\u5f3a\u5236\u6536\u5c3e  <\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">create_agent<\/strong>\uff1a\u540c\u4e00\u5957\u8bed\u4e49\uff0c\u5c11\u5199\u51e0\u5341\u884c\u80f6\u6c34<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u5165\u95e8\u5148\u8dd1\u901a\u6846\u67b6\u7248\uff1b\u8c03\u8bd5\u534f\u8bae\u65f6\u518d\u770b\u624b\u5199\u7248\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u5c0f\u660e\u590d\u8ff0\uff1a&#8221;\u56db\u6b65\u662f\u73af\u5883\u3001\u5de5\u5177\u3001create_agent\u3001invoke\uff1b\u6846\u67b6\u5185\u90e8\u8fd8\u662f\u51b3\u7b56\u2192\u6267\u884c\u2192\u56de\u586b\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;\u5bf9\u3002\u5165\u53e3 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">main.py<\/code> \u5c31\u4e24\u884c\u6f14\u793a\uff1a&#8221;<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-python\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">def<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">demo_create_agent<\/span>() -&gt; <span class=\"hljs-literal\" style=\"color: rgb(203, 75, 22);\">None<\/span>:\n  <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">print<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"=== B. create_agent\uff08\u6846\u67b6\u5faa\u73af\uff09===\"<\/span>)\n  q2 = <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u5317\u4eac\u5929\u6c14\u600e\u4e48\u6837\uff1f\u518d\u7b97 10+20\u3002\"<\/span>\n  <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">print<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u95ee\u9898:\"<\/span>, q2)\n  <span class=\"hljs-built_in\" style=\"color: rgb(42, 161, 152);\">print<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u56de\u7b54:\"<\/span>, run_create_agent(q2))\n<\/code><\/pre>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u603b\u7ed3<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u8001\u5f20\u8bf4\uff1a&#8221;\u7b2c\u4e8c\u7bc7\u53ea\u529e\u4e00\u4ef6\u4e8b\u2014\u2014\u56db\u6b65\u8dd1\u901a\u6700\u5c0f Agent\u3002&#8221;<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;\u4e09\u4e2a\u6838\u5fc3\u7406\u89e3\uff1a<\/p>\n<ol style=\"margin: 8px 0px; padding-left: 28px; list-style: outside decimal;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">create_agent = \u6846\u67b6\u7248\u5de5\u5177\u5faa\u73af<\/strong> \u2014\u2014 \u4f60\u4ea4 Models + Tools\uff0c\u5b83\u8d1f\u8d23\u51b3\u7b56\u2192\u6267\u884c\u2192\u56de\u586b  <\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u56db\u6b65\u53e3\u8bc0<\/strong> \u2014\u2014 \u73af\u5883\u53d8\u91cf \u2192 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">@tool<\/code> \u2192 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">create_agent<\/code> \u2192 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">invoke({messages})<\/code>  <\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u624b\u5199\u5faa\u73af \/ create_agent \u662f\u4e00\u5c42\u7a97\u6237\u7eb8<\/strong> \u2014\u2014 \u534f\u8bae\u76f8\u540c\uff0c\u5c01\u88c5\u6df1\u5ea6\u4e0d\u540c&#8221;<\/section>\n<\/li>\n<\/ol>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">LangChain \u652f\u7ebf\u8fdb\u5ea6\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, 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: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, 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: rgb(147, 161, 161); background: rgb(0, 43, 54);\">\u8ba4\u8bc6 LangChain\uff08\u7f16\u6392\u5c42\u5730\u56fe\uff09\n    \u2193\nAgent \u5feb\u901f\u5165\u95e8\uff08\u672c\u7bc7\uff1acreate_agent\uff09\n    \u2193\nModels \u2192 Messages \u2192 Prompts\/LCEL \u2192 Tools \u6df1\u6316 \u2192 Memory \u2192 \u2026\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;\u4e0b\u4e00\u7bc7\u628a <strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">Models<\/strong> \u5355\u72ec\u62c6\u5f00\u2014\u2014<code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">init_chat_model<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">invoke<\/code> \u4e0e <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">stream<\/code>\uff0c\u628a\u5927\u8111\u63a5\u53e3\u5403\u900f\u3002&#8221;<\/p>\n<blockquote style=\"color: rgb(85, 85, 85); background-color: rgb(255, 249, 235); 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 rgb(248, 180, 63); border-radius: 6px; font-style: normal; quotes: none;\">\n<p style=\"margin: 0.55em 0px; color: rgb(85, 85, 85); text-indent: 0px; padding: 0px; line-height: 1.75; font-style: normal; background: transparent;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u6700\u5c0f Agent \u4e0d\u662f\u795e\u79d8\u67b6\u6784\uff0c\u5c31\u662f\uff1a\u6a21\u578b\u4f1a\u9009\u5de5\u5177\uff0c\u6846\u67b6\u4f1a\u8dd1\u5faa\u73af\u3002create_agent \u8ba9\u4f60\u5148\u8dd1\u8d77\u6765\uff0c\u518d\u56de\u5934\u770b\u61c2\u624b\u5199\u5faa\u73af\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u7bc7\u4f60\u8ba4\u6e05\u4e86 LangChain \u662f\u7f16\u6392\u5c42\u2014\u2014\u516d\u5927\u6a21\u5757\u3001LCEL\u3001Agent \u4e09\u9636\u6bb5\u3002\u5730\u56fe\u6709\u4e86\uff0c\u8be5\u52a8\u624b\u63d2\u7b2c\u4e00\u5757 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3782,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[163,165],"tags":[167,168,170],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/3781"}],"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=3781"}],"version-history":[{"count":1,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/3781\/revisions"}],"predecessor-version":[{"id":3783,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/3781\/revisions\/3783"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/media\/3782"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}