{"id":101254,"date":"2026-09-06T13:57:10","date_gmt":"2026-09-06T05:57:10","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/101254.html"},"modified":"2026-09-06T13:57:10","modified_gmt":"2026-09-06T05:57:10","slug":"langchain-agent-01-%e5%a4%a7%e6%a8%a1%e5%9e%8b%e4%b8%ba%e4%bb%80%e4%b9%88%e9%9c%80%e8%a6%81-agent%ef%bc%9acreate_agent-%e4%b8%8e%e4%b8%80%e6%ac%a1%e5%a4%a9%e6%b0%94%e9%97%ae%e7%ad%94","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/101254.html","title":{"rendered":"[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54"},"content":{"rendered":"<h3 style=\"background-color:transparent\">\u4e00\u3001\u672c\u7bc7\u8981\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898<\/h3>\n<p>\u4e0a\u4e00\u5957\u4e13\u680f\u628a RAG \u8d70\u901a\u4e86&#xff1a;\u79c1\u6709\u6587\u6863\u5207\u5757\u3001\u5411\u91cf\u5316\u3001\u68c0\u7d22&#xff0c;\u518d\u585e\u8fdb\u63d0\u793a\u8bcd\u8ba9\u5927\u6a21\u578b\u56de\u7b54\u3002\u68c0\u7d22\u89e3\u51b3\u7684\u662f\u300c\u6a21\u578b\u6ca1\u770b\u8fc7\u4f60\u7684\u8d44\u6599\u300d\u3002<\/p>\n<p>\u771f\u6b63\u4e0a\u7ebf\u4e4b\u540e&#xff0c;\u8fd8\u4f1a\u649e\u4e0a\u53e6\u4e00\u7c7b\u9700\u6c42&#xff1a;\u7528\u6237\u4e0d\u662f\u53ea\u8981\u4e00\u6bb5\u6587\u5b57&#xff0c;\u800c\u662f\u8981\u67e5\u4e00\u4e0b\u73b0\u5728\u7684\u5929\u6c14\u3001\u8bfb\u4e00\u4e0b\u80a1\u4ef7\u3001\u7b97\u4e00\u4e2a BMI\u3002\u8fd9\u4e9b\u4fe1\u606f\u4e0d\u5728\u77e5\u8bc6\u5e93\u91cc&#xff0c;\u4e5f\u4e0d\u8be5\u5199\u6b7b\u5728 Prompt \u91cc&#xff0c;\u5b83\u4eec\u6765\u81ea\u51fd\u6570\u3001\u63a5\u53e3\u3001\u6570\u636e\u5e93\u3002<\/p>\n<p>\u672c\u7bc7\u53ea\u628a\u7b2c\u4e00\u5757\u5730\u57fa\u6253\u5b9e&#xff1a;<\/p>\n<p>Agent&#xff08;\u667a\u80fd\u4f53&#xff09;\u662f\u4ec0\u4e48\u3001\u4e3a\u4ec0\u4e48 RAG \u4e0d\u591f\u3001create_agent \u600e\u4e48\u7528\u4e09\u4e2a\u53c2\u6570\u8dd1\u901a\u4e00\u6b21\u5929\u6c14\u95ee\u7b54\u3002<\/p>\n<\/p>\n<h4>1.1 \u5b66\u4e60\u76ee\u6807<\/h4>\n<li>\n<p>\u80fd\u7528\u4e00\u53e5\u8bdd\u8bf4\u6e05 Agent \u548c RAG\u3001Chain \u7684\u5dee\u522b<\/p>\n<\/li>\n<li>\n<p>\u7406\u89e3 create_agent \u7684\u4e09\u4ef6\u5957&#xff1a;\u6a21\u578b\u3001\u5de5\u5177\u3001\u7cfb\u7edf\u63d0\u793a<\/p>\n<\/li>\n<li>\n<p>\u4f1a\u7528 &#064;tool \u628a\u666e\u901a Python \u51fd\u6570\u4ea4\u7ed9\u667a\u80fd\u4f53<\/p>\n<\/li>\n<li>\n<p>\u80fd\u8bfb\u61c2 invoke \u8fd4\u56de\u503c\u91cc\u90a3\u4e32 messages <\/p>\n<\/li>\n<h4><\/h4>\n<h4>1.2 \u4e00\u53e5\u516c\u5f0f<\/h4>\n<p>Agent &#061; LLM&#xff08;\u5927\u8111&#xff09;&#043; Tools&#xff08;\u624b&#xff09;&#043; \u5faa\u73af&#xff08;\u5148\u60f3\u518d\u505a\u518d\u770b&#xff09;<\/p>\n<p>RAG \u662f\u300c\u5148\u627e\u8d44\u6599\u518d\u751f\u6210\u300d\u3002Agent \u662f\u300c\u5148\u5224\u65ad\u8981\u4e0d\u8981\u52a8\u624b&#xff0c;\u52a8\u624b\u540e\u518d\u6839\u636e\u7ed3\u679c\u8bf4\u8bdd\u300d\u3002<\/p>\n<\/p>\n<h3>\u4e8c\u3001\u4ece RAG \u5230 Agent<\/h3>\n<h4><\/h4>\n<h4>2.1 RAG \u5df2\u7ecf\u89e3\u51b3\u4e86\u4ec0\u4e48<\/h4>\n<table>\n<tr>\u95ee\u9898RAG \u7684\u505a\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>\u77e5\u8bc6\u8fc7\u65f6<\/td>\n<td>\u79bb\u7ebf\u628a\u65b0\u6587\u6863\u5199\u5165\u5411\u91cf\u5e93<\/td>\n<\/tr>\n<tr>\n<td>\u4e0d\u61c2\u884c\u4e1a\u9ed1\u8bdd<\/td>\n<td>\u68c0\u7d22\u4f01\u4e1a\u5185\u90e8\u624b\u518c\u518d\u751f\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u5bb9\u6613\u5e7b\u89c9<\/td>\n<td>\u7b54\u6848\u5fc5\u987b\u57fa\u4e8e\u68c0\u7d22\u7247\u6bb5<\/td>\n<\/tr>\n<tr>\n<td>\u79c1\u6709\u6570\u636e\u4e0d\u80fd\u62ff\u53bb\u5fae\u8c03<\/td>\n<td>\u8d44\u6599\u653e\u672c\u5730&#xff0c;\u53ea\u5728\u63d0\u95ee\u65f6\u53d6\u51fa\u51e0\u6bb5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e9b\u80fd\u529b\u4ecd\u7136\u6709\u7528\u3002\u540e\u9762\u505a Agent \u65f6&#xff0c;\u68c0\u7d22\u672c\u8eab\u4e5f\u53ef\u4ee5\u53d8\u6210\u5176\u4e2d\u4e00\u628a\u5de5\u5177&#xff0c;\u800c\u4e0d\u662f\u552f\u4e00\u901a\u8def\u3002<\/p>\n<h4><\/h4>\n<h4>2.2 RAG \u8fd8\u505a\u4e0d\u5230\u4ec0\u4e48<\/h4>\n<p>\u7528\u6237\u95ee\u300c\u660e\u5929\u6df1\u5733\u7684\u5929\u6c14\u5982\u4f55\u300d&#xff0c;\u5411\u91cf\u5e93\u91cc\u901a\u5e38\u6ca1\u6709\u660e\u5929\u7684\u9884\u62a5\u3002\u4f60\u5c31\u7b97\u628a\u53bb\u5e74\u7684\u6c14\u8c61\u8bf4\u660e\u68c0\u7d22\u51fa\u6765&#xff0c;\u6a21\u578b\u4e5f\u53ea\u80fd\u590d\u8ff0\u65e7\u6587\u672c&#xff0c;\u4e0d\u80fd\u53bb\u8c03\u5929\u6c14\u63a5\u53e3\u3002<\/p>\n<p>\u518d\u6781\u7aef\u4e00\u70b9&#xff1a;\u7528\u6237\u8bf4\u300c\u5e2e\u6211\u7b97 BMI\u300d\u3002\u68c0\u7d22\u80fd\u7ffb\u5230\u516c\u5f0f&#xff0c;\u4f46\u5f53\u524d\u8eab\u9ad8\u4f53\u91cd\u4e0d\u5728\u6587\u6863\u91cc&#xff0c;\u5fc5\u987b\u8c03\u7528\u4e1a\u52a1\u51fd\u6570\u3002<\/p>\n<p>\u6240\u4ee5&#xff1a;<\/p>\n<ul>\n<li>\n<p>RAG&#xff1a;\u7ed9\u6a21\u578b\u770b\u8d44\u6599<\/p>\n<\/li>\n<li>\n<p>Agent&#xff1a;\u7ed9\u6a21\u578b\u4e00\u53cc\u624b&#xff0c;\u8ba9\u5b83\u81ea\u5df1\u51b3\u5b9a\u4f55\u65f6\u4f38\u624b<\/p>\n<\/li>\n<\/ul>\n<h4><\/h4>\n<h4>2.3 \u4e09\u79cd\u5f62\u6001\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u666e\u901a LLMRAGAgent<\/tr>\n<tbody>\n<tr>\n<td>\u8f93\u5165<\/td>\n<td>\u7528\u6237\u4e00\u53e5\u8bdd<\/td>\n<td>\u7528\u6237\u95ee\u9898 &#043; \u68c0\u7d22\u7247\u6bb5<\/td>\n<td>\u7528\u6237\u95ee\u9898 &#043; \u53ef\u7528\u5de5\u5177\u5217\u8868<\/td>\n<\/tr>\n<tr>\n<td>\u8fc7\u7a0b<\/td>\n<td>\u4e00\u6b21\u751f\u6210<\/td>\n<td>\u68c0\u7d22\u4e00\u6b21&#xff0c;\u751f\u6210\u4e00\u6b21<\/td>\n<td>\u53ef\u80fd\u591a\u8f6e&#xff1a;\u601d\u8003 \u2192 \u8c03\u5de5\u5177 \u2192 \u518d\u601d\u8003<\/td>\n<\/tr>\n<tr>\n<td>\u8f93\u51fa<\/td>\n<td>\u6587\u672c<\/td>\n<td>\u57fa\u4e8e\u8d44\u6599\u7684\u6587\u672c<\/td>\n<td>\u6587\u672c&#xff0c;\u4ee5\u53ca\u4e2d\u95f4\u4ea7\u751f\u7684\u5de5\u5177\u8c03\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u5178\u578b\u5931\u8d25<\/td>\n<td>\u4e0d\u61c2\u79c1\u6709\u77e5\u8bc6<\/td>\n<td>\u8d44\u6599\u91cc\u6ca1\u6709\u300c\u73b0\u5728\u300d\u300c\u6211\u7684\u300d<\/td>\n<td>\u5de5\u5177\u63cf\u8ff0\u542b\u7cca&#xff0c;\u8c03\u9519\u6216\u6f0f\u8c03<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8bfe\u4ef6\u4ee3\u7801\u628a Agent \u7684\u7b2c\u4e00\u8bfe\u538b\u5230 20 \u591a\u884c&#xff1a;\u4e0d\u95ee\u6846\u67b6\u53f2&#xff0c;\u5148\u8ba9\u6a21\u578b\u771f\u7684\u53bb\u8c03\u4e00\u4e2a\u51fd\u6570\u3002<\/p>\n<\/p>\n<h3>\u4e09\u3001Agent \u6807\u51c6\u5de5\u4f5c\u6d41<\/h3>\n<p>\u4e00\u6b21\u5e26\u5de5\u5177\u7684\u95ee\u7b54&#xff0c;\u5e95\u5c42\u4e0d\u662f\u300c\u6a21\u578b\u76f4\u63a5\u628a\u5929\u6c14\u8bf4\u51fa\u6765\u300d&#xff0c;\u800c\u662f\u4e00\u5f20\u5f88\u77ed\u7684\u5faa\u73af&#xff1a;<\/p>\n<p>\u7528\u6237\u6d88\u606f<br \/>\n   \u2502<br \/>\n   \u25bc<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502  LLM \u601d\u8003    \u2502  \u8981\u4e0d\u8981\u7528\u5de5\u5177&#xff1f;\u7528\u54ea\u4e00\u4e2a&#xff1f;\u53c2\u6570\u662f\u4ec0\u4e48&#xff1f;<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n       \u2502 \u9700\u8981\u5de5\u5177<br \/>\n       \u25bc<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502  \u6267\u884c Tool   \u2502  \u8dd1\u4f60\u5199\u7684 Python \u51fd\u6570<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n       \u2502 \u89c2\u5bdf\u7ed3\u679c<br \/>\n       \u25bc<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502  LLM \u518d\u601d\u8003  \u2502  \u62ff\u5de5\u5177\u8fd4\u56de\u503c\u7ec4\u7ec7\u6700\u7ec8\u56de\u7b54<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>LangChain 1.x \u628a\u8fd9\u5f20\u5faa\u73af\u6536\u8fdb\u4e00\u4e2a\u5165\u53e3&#xff1a;create_agent\u3002\u4f60\u4e0d\u518d\u624b\u5199\u300c\u5148 bind_tools\u3001\u518d\u89e3\u6790 tool_calls\u3001\u518d\u62fc ToolMessage\u300d\u90a3\u4e00\u957f\u4e32\u6837\u677f&#xff0c;\u53ea\u8981\u4ea4\u51fa\u5927\u8111\u3001\u5de5\u5177\u6e05\u5355\u3001\u4eba\u8bbe\u3002<\/p>\n<\/p>\n<h4>3.1 \u4e09\u4ef6\u5957<\/h4>\n<table>\n<tr>\u53c2\u6570\u4ee3\u7801\u91cc\u7684\u89d2\u8272\u672c\u8bfe\u53d6\u503c<\/tr>\n<tbody>\n<tr>\n<td>model<\/td>\n<td>\u667a\u80fd\u4f53\u7684\u5927\u8111<\/td>\n<td>ChatTongyi(model&#061;&#034;qwen3-max&#034;)<\/td>\n<\/tr>\n<tr>\n<td>tools<\/td>\n<td>\u80fd\u8c03\u7528\u7684\u51fd\u6570\u5217\u8868<\/td>\n<td>[get_weather]<\/td>\n<\/tr>\n<tr>\n<td>system_prompt<\/td>\n<td>\u4eba\u8bbe\u4e0e\u7eaa\u5f8b<\/td>\n<td>\u300c\u4f60\u662f\u4e00\u4e2a\u804a\u5929\u52a9\u624b&#xff0c;\u53ef\u4ee5\u56de\u7b54\u7528\u6237\u95ee\u9898\u3002\u300d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5c11\u4efb\u4f55\u4e00\u4ef6\u90fd\u4f1a\u53d8\u5473&#xff1a;\u6ca1\u6709\u5de5\u5177&#xff0c;\u5b83\u53ea\u662f\u804a\u5929\u6a21\u578b&#xff1b;\u6ca1\u6709\u7cfb\u7edf\u63d0\u793a&#xff0c;\u5b83\u4ecd\u80fd\u8dd1&#xff0c;\u4f46\u98ce\u683c\u548c\u7ea6\u675f\u5168\u9760\u9ed8\u8ba4&#xff1b;\u6ca1\u6709\u8db3\u591f\u5f3a\u7684\u6a21\u578b&#xff0c;\u5b83\u751a\u81f3\u4e0d\u4f1a\u53d1\u51fa\u5408\u6cd5\u7684\u5de5\u5177\u8c03\u7528\u3002<\/p>\n<h4><\/h4>\n<h4>3.2 \u5faa\u73af\u4ec0\u4e48\u65f6\u5019\u505c<\/h4>\n<p>\u6a21\u578b\u67d0\u4e00\u8f6e\u51b3\u5b9a\u4e0d\u518d\u8c03\u7528\u5de5\u5177&#xff0c;\u53ea\u4ea7\u51fa\u5bf9\u7528\u6237\u7684\u81ea\u7136\u8bed\u8a00&#xff0c;\u5faa\u73af\u5c31\u7ed3\u675f\u3002invoke \u4f1a\u628a\u6574\u6bb5\u8f68\u8ff9\u88c5\u8fdb res[&#034;messages&#034;]&#xff0c;\u4ece\u5934\u5230\u5c3e\u90fd\u80fd\u56de\u653e\u3002<\/p>\n<\/p>\n<h3>\u56db\u3001create_agent \u521d\u4f53\u9a8c<\/h3>\n<p>\u5bf9\u7167\u6587\u4ef6&#xff1a;P5_Agent\u667a\u80fd\u4f53\/01Agent\u667a\u80fd\u4f53\u521d\u4f53\u9a8c.py\u3002<\/p>\n<h4><\/h4>\n<h4>4.1 \u5bfc\u5165\u4e0e\u6a21\u578b<\/h4>\n<p>from langchain.agents import create_agent<br \/>\nfrom langchain_community.chat_models.tongyi import ChatTongyi<br \/>\nfrom langchain_core.tools import tool<\/p>\n<p>\u4e09\u884c\u5404\u7ba1\u4e00\u5c42&#xff1a;<\/p>\n<ul>\n<li>\n<p>create_agent&#xff1a;\u7ec4\u88c5\u667a\u80fd\u4f53&#xff08;LangChain 1.x \u7684\u6807\u51c6\u5165\u53e3&#xff09;<\/p>\n<\/li>\n<li>\n<p>ChatTongyi&#xff1a;\u901a\u4e49\u5343\u95ee\u804a\u5929\u6a21\u578b&#xff0c;\u548c RAG \u4e13\u680f\u7528\u7684\u662f\u540c\u4e00\u5957\u793e\u533a\u96c6\u6210<\/p>\n<\/li>\n<li>\n<p>tool&#xff1a;\u628a\u666e\u901a\u51fd\u6570\u767b\u8bb0\u6210\u6a21\u578b\u80fd\u300c\u770b\u89c1\u300d\u7684\u5de5\u5177<\/p>\n<\/li>\n<\/ul>\n<p>\u5927\u8111\u8fd9\u4e00\u884c&#xff0c;\u6ce8\u91ca\u5199\u5f97\u5f88\u76f4\u767d&#xff1a;<\/p>\n<p>model&#061;ChatTongyi(model&#061;&#034;qwen3-max&#034;),        # \u667a\u80fd\u4f53\u7684\u5927\u8111LLM<\/p>\n<p>qwen3-max \u8981\u80fd\u7a33\u5b9a\u4ea7\u51fa tool call\u3002\u6559\u5b66\u73af\u5883\u6cbf\u7528\u963f\u91cc\u4e91\u5bc6\u94a5\u5373\u53ef&#xff0c;\u548c\u524d\u9762\u8c03\u7528\u901a\u4e49\u5343\u95ee\u7684\u65b9\u5f0f\u4e00\u81f4\u3002<\/p>\n<h4><\/h4>\n<h4>4.2 \u7528 &#064;tool \u58f0\u660e\u5de5\u5177<\/h4>\n<p>&#064;tool(description&#061;&#034;\u67e5\u8be2\u5929\u6c14&#034;)<br \/>\ndef get_weather() -&gt; str:<br \/>\n    return &#034;\u6674\u5929&#034;<\/p>\n<p>\u8fd9\u91cc\u6709\u4e09\u4e2a\u503c\u5f97\u76ef\u4f4f\u7684\u7ec6\u8282\u3002<\/p>\n<h5 style=\"background-color:transparent\">4.2.1 description \u662f\u7ed9\u6a21\u578b\u770b\u7684\u8bf4\u660e\u4e66<\/h5>\n<p>\u6a21\u578b\u770b\u4e0d\u89c1\u51fd\u6570\u4f53&#xff0c;\u53ea\u770b\u89c1\u540d\u5b57\u548c\u63cf\u8ff0\u3002description&#061;&#034;\u67e5\u8be2\u5929\u6c14&#034; \u51b3\u5b9a\u4e86\u5b83\u4f1a\u4e0d\u4f1a\u5728\u300c\u660e\u5929\u6df1\u5733\u7684\u5929\u6c14\u5982\u4f55\u300d\u8fd9\u79cd\u95ee\u9898\u4e0a\u4f38\u624b\u3002\u63cf\u8ff0\u5199\u7cca\u4e86&#xff0c;\u6a21\u578b\u53ef\u80fd\u76f4\u63a5\u778e\u7f16\u5929\u6c14&#xff0c;\u5de5\u5177\u5c31\u6210\u4e86\u6446\u8bbe\u3002<\/p>\n<h5>4.2.2 \u8fd4\u56de\u503c\u4f1a\u88ab\u5f53\u6210\u300c\u89c2\u5bdf\u300d<\/h5>\n<p>\u51fd\u6570\u8fd4\u56de &#034;\u6674\u5929&#034;&#xff0c;\u4e0b\u4e00\u8f6e\u6a21\u578b\u770b\u5230\u7684\u4e0d\u662f\u4f60\u7684 Python \u53d8\u91cf&#xff0c;\u800c\u662f\u4e00\u6761\u5de5\u5177\u6d88\u606f&#xff1a;\u5929\u6c14\u5de5\u5177\u8bf4&#xff0c;\u7ed3\u679c\u662f\u6674\u5929\u3002\u6700\u7ec8\u56de\u7b54\u662f\u6a21\u578b\u6839\u636e\u8fd9\u6761\u89c2\u5bdf\u7ec4\u7ec7\u51fa\u6765\u7684&#xff0c;\u4e0d\u662f return \u76f4\u63a5\u6253\u5370\u7ed9\u7528\u6237\u3002<\/p>\n<h5>4.2.3 \u672c\u8bfe\u5de5\u5177\u6545\u610f\u6ca1\u6709\u57ce\u5e02\u53c2\u6570<\/h5>\n<p>get_weather() \u4e0d\u63a5\u6536\u57ce\u5e02&#xff0c;\u4e5f\u4e0d\u67e5\u771f\u5b9e\u63a5\u53e3&#xff0c;\u6c38\u8fdc\u8fd4\u56de\u300c\u6674\u5929\u300d\u3002\u8fd9\u662f\u6559\u5b66\u6869&#xff0c;\u7528\u6765\u8bc1\u660e&#xff1a;\u6a21\u578b\u4f1a\u4e0d\u4f1a\u8c03\u7528\u5de5\u5177&#xff0c;\u800c\u4e0d\u662f\u8bc1\u660e\u6c14\u8c61 API \u600e\u4e48\u7b7e\u3002<\/p>\n<\/p>\n<h4>4.3 \u7ec4\u88c5\u667a\u80fd\u4f53<\/h4>\n<p>agent &#061; create_agent(<br \/>\n    model&#061;ChatTongyi(model&#061;&#034;qwen3-max&#034;),        # \u667a\u80fd\u4f53\u7684\u5927\u8111LLM<br \/>\n    tools&#061;[get_weather],            # \u5411\u667a\u80fd\u4f53\u63d0\u4f9b\u5de5\u5177\u5217\u8868<br \/>\n    system_prompt&#061;&#034;\u4f60\u662f\u4e00\u4e2a\u804a\u5929\u52a9\u624b&#xff0c;\u53ef\u4ee5\u56de\u7b54\u7528\u6237\u95ee\u9898\u3002&#034;,<br \/>\n)<\/p>\n<p>tools \u5fc5\u987b\u662f\u5217\u8868\u3002\u54ea\u6015\u53ea\u6709\u4e00\u628a\u5de5\u5177&#xff0c;\u4e5f\u8981\u5199\u6210 [get_weather]\u3002\u540e\u9762\u80a1\u4ef7\u3001BMI \u90fd\u662f\u5f80\u8fd9\u4e2a\u5217\u8868\u91cc\u52a0\u51fd\u6570&#xff0c;\u7ec4\u88c5\u65b9\u5f0f\u4e0d\u53d8\u3002<\/p>\n<p>system_prompt \u672c\u8bfe\u5199\u5f97\u5f88\u677e\u3002\u7b2c 02\u300103 \u7bc7\u4f1a\u628a\u5b83\u6536\u7d27&#xff1a;\u5148\u8981\u6c42\u300c\u544a\u77e5\u601d\u8003\u8fc7\u7a0b\u300d&#xff0c;\u518d\u8981\u6c42\u300c\u4e25\u683c ReAct\u3001\u6bcf\u8f6e\u53ea\u8c03\u4e00\u4e2a\u5de5\u5177\u300d\u3002\u540c\u4e00\u5957 create_agent&#xff0c;\u7eaa\u5f8b\u5168\u5199\u5728\u8fd9\u53e5\u8bdd\u91cc\u3002<\/p>\n<h4><\/h4>\n<h4>4.4 invoke \u4e00\u6b21\u5929\u6c14\u95ee\u7b54<\/h4>\n<p>res &#061; agent.invoke(<br \/>\n    {<br \/>\n        &#034;messages&#034;: [<br \/>\n            {&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: &#034;\u660e\u5929\u6df1\u5733\u7684\u5929\u6c14\u5982\u4f55&#xff1f;&#034;},<br \/>\n        ]<br \/>\n    }<br \/>\n)<\/p>\n<p>\u8c03\u7528\u7ea6\u5b9a&#xff1a;<\/p>\n<li>\n<p>\u5165\u53c2\u662f\u72b6\u6001\u5b57\u5178&#xff0c;\u4e0d\u662f\u88f8\u5b57\u7b26\u4e32<\/p>\n<\/li>\n<li>\n<p>\u7528\u6237\u95ee\u9898\u653e\u5728 messages \u91cc&#xff0c;\u7528 OpenAI \u98ce\u683c\u7684 role \/ content \u5373\u53ef<\/p>\n<\/li>\n<li>\n<p>invoke \u963b\u585e\u5230\u6574\u8f6e\u5faa\u73af\u7ed3\u675f&#xff0c;\u4e00\u6b21\u6027\u8fd4\u56de\u6700\u7ec8\u72b6\u6001<\/p>\n<\/li>\n<p>\u548c RAG \u4e13\u680f\u91cc model.invoke(&#034;\u4f60\u597d&#034;) \u4e0d\u540c&#xff1a;Agent \u7684\u8f93\u5165\u8f93\u51fa\u90fd\u4ee5 messages \u4e3a\u4e2d\u5fc3\u3002\u540e\u9762 stream\u3001\u4e2d\u95f4\u4ef6\u8bfb\u7684\u90fd\u662f\u8fd9\u4efd\u72b6\u6001\u3002<\/p>\n<\/p>\n<h3>\u4e94\u3001\u8fd4\u56de\u503c\u91cc\u7684\u6d88\u606f\u94fe\u8def<\/h3>\n<h4><\/h4>\n<h4>5.1 \u4e3a\u4ec0\u4e48\u8981\u904d\u5386 messages<\/h4>\n<p>for msg in res[&#034;messages&#034;]:<br \/>\n    print(type(msg).__name__, msg.content)<\/p>\n<p>res \u4e0d\u662f\u4e00\u53e5\u6700\u7ec8\u7b54\u6848&#xff0c;\u800c\u662f\u6574\u6bb5\u5bf9\u8bdd\u8f68\u8ff9\u3002\u53ea\u6253\u5370\u6700\u540e\u4e00\u4e2a content&#xff0c;\u4f60\u53ea\u80fd\u770b\u5230\u300c\u660e\u5929\u6df1\u5733\u6674\u5929&#xff0c;\u9002\u5408\u2026\u2026\u300d&#xff0c;\u770b\u4e0d\u5230\u4e2d\u95f4\u5230\u5e95\u8c03\u6ca1\u8c03\u5de5\u5177\u3002<\/p>\n<p>\u8bfe\u7a0b\u9009\u62e9\u6253\u5370 type(msg).__name__ \u548c msg.content&#xff0c;\u5c31\u662f\u4e3a\u4e86\u628a\u7c7b\u578b\u548c\u6b63\u6587\u5e76\u6392\u51fa\u6765&#xff1a;\u54ea\u4e00\u6761\u662f\u4eba\u8bf4\u7684&#xff0c;\u54ea\u4e00\u6761\u662f\u6a21\u578b\u8bf4\u7684&#xff0c;\u54ea\u4e00\u6761\u662f\u5de5\u5177\u56de\u7684\u3002<\/p>\n<h4><\/h4>\n<h4>5.2 \u4e00\u6b21\u5178\u578b\u8f68\u8ff9<\/h4>\n<p>\u7528\u6237\u95ee\u5929\u6c14\u4e14\u6a21\u578b\u9009\u62e9\u7528\u5de5\u5177\u65f6&#xff0c;messages \u901a\u5e38\u957f\u8fd9\u6837&#xff1a;<\/p>\n<table>\n<tr>\u987a\u5e8f\u7c7b\u578bcontent \u91cc\u5e38\u89c1\u5185\u5bb9\u989d\u5916\u5b57\u6bb5<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>HumanMessage<\/td>\n<td>\u660e\u5929\u6df1\u5733\u7684\u5929\u6c14\u5982\u4f55&#xff1f;<\/td>\n<td>\u65e0<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>AIMessage<\/td>\n<td>\u53ef\u80fd\u4e3a\u7a7a&#xff0c;\u6216\u5f88\u77ed\u7684\u8fc7\u6e21\u8bed<\/td>\n<td>tool_calls&#xff1a;\u8981\u8c03 get_weather<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>ToolMessage<\/td>\n<td>\u6674\u5929<\/td>\n<td>\u5bf9\u5e94\u4e0a\u4e00\u6b21 tool call \u7684 id<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>AIMessage<\/td>\n<td>\u7efc\u5408\u540e\u7684\u81ea\u7136\u8bed\u8a00\u56de\u7b54<\/td>\n<td>\u4e0d\u518d\u5e26 tool_calls<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8bfb\u4ee3\u7801\u65f6\u53ef\u4ee5\u6309\u8fd9\u53e5\u8bdd\u8bb0&#xff1a;<\/p>\n<p>\u4eba\u63d0\u95ee \u2192 \u6a21\u578b\u7533\u8bf7\u5de5\u5177 \u2192 \u5de5\u5177\u56de\u89c2\u5bdf \u2192 \u6a21\u578b\u7ed9\u7ed3\u8bba\u3002<\/p>\n<p>\u7b2c 2 \u6761 AIMessage \u7684 content \u7ecf\u5e38\u662f\u7a7a\u7684&#xff0c;\u4fe1\u606f\u5728 tool_calls \u91cc\u3002\u6240\u4ee5\u7b2c 02 \u7bc7\u4f1a\u4e13\u95e8\u5224\u65ad latest_message.tool_calls&#xff0c;\u5426\u5219\u4f60\u4f1a\u8bef\u4ee5\u4e3a\u300c\u6a21\u578b\u6ca1\u8bf4\u8bdd\u300d\u3002<\/p>\n<h4><\/h4>\n<h4>5.3 \u548c\u76f4\u63a5 chat \u7684\u5dee\u522b<\/h4>\n<p>\u5982\u679c\u628a\u540c\u4e00\u53e5\u300c\u660e\u5929\u6df1\u5733\u7684\u5929\u6c14\u5982\u4f55\u300d\u4e22\u7ed9\u88f8\u7684 ChatTongyi.invoke&#xff0c;\u6a21\u578b\u4f1a\u6839\u636e\u8bad\u7ec3\u6570\u636e\u7f16\u4e00\u6bb5\u9884\u62a5&#xff0c;\u4e0d\u4f1a\u6267\u884c\u4f60\u7684 return &#034;\u6674\u5929&#034;\u3002<\/p>\n<p>\u52a0\u4e0a Agent \u4e4b\u540e&#xff0c;\u300c\u6674\u5929\u300d\u8fd9\u4e24\u4e2a\u5b57\u6765\u81ea\u4f60\u7684\u51fd\u6570\u3002\u6a21\u578b\u8d1f\u8d23\u7684\u662f&#xff1a;\u8bc6\u522b\u8fd9\u662f\u5929\u6c14\u95ee\u9898\u3001\u9009\u51fa get_weather\u3001\u628a\u5de5\u5177\u7ed3\u679c\u8bf4\u6210\u4eba\u8bdd\u3002\u8d23\u4efb\u5207\u5f00\u4e86&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5de5\u5177&#xff1a;\u63d0\u4f9b\u4e8b\u5b9e&#xff08;\u672c\u8bfe\u662f\u6869\u6570\u636e&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u6a21\u578b&#xff1a;\u51b3\u5b9a\u4f55\u65f6\u8c03\u7528\u3001\u5982\u4f55\u63aa\u8f9e<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u5c31\u662f\u667a\u80fd\u4f53\u76f8\u5bf9\u300c\u4f1a\u804a\u5929\u7684\u6a21\u578b\u300d\u771f\u6b63\u591a\u51fa\u6765\u7684\u90a3\u4e00\u5c42\u3002<\/p>\n<\/p>\n<h3 style=\"background-color:transparent\">\u516d\u3001\u672c\u7bc7\u5c0f\u7ed3<\/h3>\n<li>\n<p>RAG \u89e3\u51b3\u300c\u770b\u8d44\u6599\u300d&#xff0c;Agent \u89e3\u51b3\u300c\u52a8\u624b\u300d<\/p>\n<\/li>\n<li>\n<p>create_agent \u53ea\u8981\u6a21\u578b\u3001\u5de5\u5177\u3001\u7cfb\u7edf\u63d0\u793a\u4e09\u4ef6\u5957<\/p>\n<\/li>\n<li>\n<p>&#064;tool(description&#061;&#8230;) \u7684\u63cf\u8ff0\u662f\u6a21\u578b\u9009\u5de5\u5177\u7684\u552f\u4e00\u8bf4\u660e\u4e66<\/p>\n<\/li>\n<li>\n<p>invoke \u8fd4\u56de\u7684\u662f\u5b8c\u6574 messages&#xff0c;\u8bf7\u6309\u7c7b\u578b\u628a\u8f68\u8ff9\u8bfb\u5b8c&#xff0c;\u4e0d\u8981\u53ea\u770b\u6700\u540e\u4e00\u53e5<\/p>\n<\/li>\n<\/p>\n<\/p>\n<\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u672c\u7bc7\u8981\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898\u4e0a\u4e00\u5957\u4e13\u680f\u628a RAG \u8d70\u901a\u4e86&#xff1a;\u79c1\u6709\u6587\u6863\u5207\u5757\u3001\u5411\u91cf\u5316\u3001\u68c0\u7d22&#xff0c;\u518d\u585e\u8fdb\u63d0\u793a\u8bcd\u8ba9\u5927\u6a21\u578b\u56de\u7b54\u3002\u68c0\u7d22\u89e3\u51b3\u7684\u662f\u300c\u6a21\u578b\u6ca1\u770b\u8fc7\u4f60\u7684\u8d44\u6599\u300d\u3002\u771f\u6b63\u4e0a\u7ebf\u4e4b\u540e&#xff0c;\u8fd8\u4f1a\u649e\u4e0a\u53e6\u4e00\u7c7b\u9700\u6c42&#xff1a;\u7528\u6237\u4e0d\u662f\u53ea\u8981\u4e00\u6bb5\u6587\u5b57&#xff0c;\u800c\u662f\u8981\u67e5\u4e00\u4e0b\u73b0\u5728\u7684\u5929\u6c14\u3001\u8bfb\u4e00\u4e0b\u80a1\u4ef7\u3001\u7b97\u4e00\u4e2a BMI\u3002\u8fd9\u4e9b\u4fe1\u606f\u4e0d\u5728\u77e5\u8bc6\u5e93\u91cc&#xff0c;\u4e5f\u4e0d\u8be5\u5199\u6b7b\u5728 Prompt \u91cc&#xff0c;\u5b83\u4eec\u6765\u81ea\u51fd\u6570\u3001\u63a5\u53e3\u3001\u6570\u636e\u5e93\u3002\u672c\u7bc7\u53ea\u628a\u7b2c\u4e00\u5757\u5730\u57fa\u6253\u5b9e&#xff1a;Agent&amp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[997],"topic":[],"class_list":["post-101254","post","type-post","status-publish","format-standard","hentry","category-server","tag-langchain"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/101254.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u672c\u7bc7\u8981\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898\u4e0a\u4e00\u5957\u4e13\u680f\u628a RAG \u8d70\u901a\u4e86&#xff1a;\u79c1\u6709\u6587\u6863\u5207\u5757\u3001\u5411\u91cf\u5316\u3001\u68c0\u7d22&#xff0c;\u518d\u585e\u8fdb\u63d0\u793a\u8bcd\u8ba9\u5927\u6a21\u578b\u56de\u7b54\u3002\u68c0\u7d22\u89e3\u51b3\u7684\u662f\u300c\u6a21\u578b\u6ca1\u770b\u8fc7\u4f60\u7684\u8d44\u6599\u300d\u3002\u771f\u6b63\u4e0a\u7ebf\u4e4b\u540e&#xff0c;\u8fd8\u4f1a\u649e\u4e0a\u53e6\u4e00\u7c7b\u9700\u6c42&#xff1a;\u7528\u6237\u4e0d\u662f\u53ea\u8981\u4e00\u6bb5\u6587\u5b57&#xff0c;\u800c\u662f\u8981\u67e5\u4e00\u4e0b\u73b0\u5728\u7684\u5929\u6c14\u3001\u8bfb\u4e00\u4e0b\u80a1\u4ef7\u3001\u7b97\u4e00\u4e2a BMI\u3002\u8fd9\u4e9b\u4fe1\u606f\u4e0d\u5728\u77e5\u8bc6\u5e93\u91cc&#xff0c;\u4e5f\u4e0d\u8be5\u5199\u6b7b\u5728 Prompt \u91cc&#xff0c;\u5b83\u4eec\u6765\u81ea\u51fd\u6570\u3001\u63a5\u53e3\u3001\u6570\u636e\u5e93\u3002\u672c\u7bc7\u53ea\u628a\u7b2c\u4e00\u5757\u5730\u57fa\u6253\u5b9e&#xff1a;Agent&amp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/101254.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-06T05:57:10+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101254.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/101254.html\",\"name\":\"[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-06T05:57:10+00:00\",\"dateModified\":\"2026-09-06T05:57:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/101254.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/101254.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101254.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/101254.html","og_locale":"zh_CN","og_type":"article","og_title":"[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u672c\u7bc7\u8981\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898\u4e0a\u4e00\u5957\u4e13\u680f\u628a RAG \u8d70\u901a\u4e86&#xff1a;\u79c1\u6709\u6587\u6863\u5207\u5757\u3001\u5411\u91cf\u5316\u3001\u68c0\u7d22&#xff0c;\u518d\u585e\u8fdb\u63d0\u793a\u8bcd\u8ba9\u5927\u6a21\u578b\u56de\u7b54\u3002\u68c0\u7d22\u89e3\u51b3\u7684\u662f\u300c\u6a21\u578b\u6ca1\u770b\u8fc7\u4f60\u7684\u8d44\u6599\u300d\u3002\u771f\u6b63\u4e0a\u7ebf\u4e4b\u540e&#xff0c;\u8fd8\u4f1a\u649e\u4e0a\u53e6\u4e00\u7c7b\u9700\u6c42&#xff1a;\u7528\u6237\u4e0d\u662f\u53ea\u8981\u4e00\u6bb5\u6587\u5b57&#xff0c;\u800c\u662f\u8981\u67e5\u4e00\u4e0b\u73b0\u5728\u7684\u5929\u6c14\u3001\u8bfb\u4e00\u4e0b\u80a1\u4ef7\u3001\u7b97\u4e00\u4e2a BMI\u3002\u8fd9\u4e9b\u4fe1\u606f\u4e0d\u5728\u77e5\u8bc6\u5e93\u91cc&#xff0c;\u4e5f\u4e0d\u8be5\u5199\u6b7b\u5728 Prompt \u91cc&#xff0c;\u5b83\u4eec\u6765\u81ea\u51fd\u6570\u3001\u63a5\u53e3\u3001\u6570\u636e\u5e93\u3002\u672c\u7bc7\u53ea\u628a\u7b2c\u4e00\u5757\u5730\u57fa\u6253\u5b9e&#xff1a;Agent&amp;","og_url":"https:\/\/www.wsisp.com\/helps\/101254.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-06T05:57:10+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/101254.html","url":"https:\/\/www.wsisp.com\/helps\/101254.html","name":"[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-06T05:57:10+00:00","dateModified":"2026-09-06T05:57:10+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/101254.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/101254.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/101254.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"[LangChain Agent] 01 \u5927\u6a21\u578b\u4e3a\u4ec0\u4e48\u9700\u8981 Agent\uff1acreate_agent \u4e0e\u4e00\u6b21\u5929\u6c14\u95ee\u7b54"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=101254"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101254\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=101254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=101254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=101254"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=101254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}