{"id":7938,"date":"2026-06-09T13:39:59","date_gmt":"2026-06-09T05:39:59","guid":{"rendered":"https:\/\/ab123.xyz\/?p=7938"},"modified":"2026-06-09T13:39:59","modified_gmt":"2026-06-09T05:39:59","slug":"langchain-agentexecutor-with-tool-calling%ef%bc%9a%e6%99%ba%e8%83%bd%e4%bb%a3%e7%90%86%e4%b8%8e%e5%b7%a5%e5%85%b7%e8%b0%83%e7%94%a8%e7%9a%84%e6%9d%83%e5%a8%81%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/ab123.xyz\/?p=7938","title":{"rendered":"LangChain AgentExecutor with Tool Calling\uff1a\u667a\u80fd\u4ee3\u7406\u4e0e\u5de5\u5177\u8c03\u7528\u7684\u6743\u5a01\u6307\u5357"},"content":{"rendered":"<p>LangChain \u7684 AgentExecutor \u662f\u6784\u5efa\u667a\u80fd\u4ee3\u7406\uff08Agent\uff09\u7684\u6838\u5fc3\u5f15\u64ce\uff0c\u914d\u5408 Tool Calling \u673a\u5236\uff0c\u8ba9\u5927\u8bed\u8a00\u6a21\u578b\u80fd\u591f\u52a8\u6001\u8c03\u7528\u5916\u90e8\u5de5\u5177\u5b8c\u6210\u590d\u6742\u4efb\u52a1\u3002\u672c\u6587\u5c06\u6df1\u5165\u89e3\u6790\u8be5\u5de5\u5177\u7684\u529f\u80fd\u3001\u4f18\u52bf\u3001\u5e94\u7528\u573a\u666f\u53ca\u4f7f\u7528\u65b9\u5f0f\uff0c\u5e76\u63d0\u4f9b\u5b98\u65b9\u8d44\u6e90\u3002<\/p>\n<h2>\u4ec0\u4e48\u662f AgentExecutor \u4e0e Tool Calling<\/h2>\n<p>AgentExecutor \u662f LangChain \u6846\u67b6\u4e2d\u8d1f\u8d23\u6267\u884c\u4ee3\u7406\u903b\u8f91\u7684\u8fd0\u884c\u5668\u3002\u5b83\u63a5\u6536\u7528\u6237\u7684\u8f93\u5165\uff0c\u4ea4\u7531\u5927\u6a21\u578b\u51b3\u5b9a\u4e0b\u4e00\u6b65\u52a8\u4f5c\u2014\u2014\u662f\u76f4\u63a5\u56de\u7b54\uff0c\u8fd8\u662f\u8c03\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5de5\u5177\u3002Tool Calling \u5219\u5141\u8bb8\u4ee3\u7406\u901a\u8fc7\u51fd\u6570\u8c03\u7528\u89c4\u8303\uff08\u5982 OpenAI \u7684 function calling\uff09\u89e6\u53d1\u9884\u8bbe\u5de5\u5177\uff0c\u6bd4\u5982\u641c\u7d22\u767e\u79d1\u3001\u67e5\u8be2\u5929\u6c14\u3001\u6267\u884c\u4ee3\u7801\u7b49\u3002\u8fd9\u79cd\u8bbe\u8ba1\u5c06\u8bed\u8a00\u6a21\u578b\u7684\u63a8\u7406\u80fd\u529b\u4e0e\u5916\u90e8\u4e16\u754c\u7684\u4ea4\u4e92\u80fd\u529b\u65e0\u7f1d\u7ed3\u5408\u3002<\/p>\n<h3>\u6838\u5fc3\u7ec4\u4ef6<\/h3>\n<ul>\n<li>Agent\uff1a\u5305\u542b\u63d0\u793a\u6a21\u677f\u3001\u5927\u6a21\u578b\u548c\u8f93\u51fa\u89e3\u6790\u5668\uff0c\u8d1f\u8d23\u751f\u6210\u884c\u52a8\u6307\u4ee4\u3002<\/li>\n<li>Tools\uff1a\u53ef\u88ab\u8c03\u7528\u7684\u51fd\u6570\u6216 API\uff0c\u9700\u5b9a\u4e49\u540d\u79f0\u3001\u63cf\u8ff0\u548c\u53c2\u6570\u7ed3\u6784\u3002<\/li>\n<li>AgentExecutor\uff1a\u5faa\u73af\u8fd0\u884c\u4ee3\u7406\uff0c\u76f4\u5230\u83b7\u5f97\u6700\u7ec8\u7b54\u6848\u6216\u8fbe\u5230\u6700\u5927\u8fed\u4ee3\u6b21\u6570\u3002<\/li>\n<\/ul>\n<h2>\u6838\u5fc3\u4f18\u52bf\u4e0e\u80fd\u529b<\/h2>\n<p>AgentExecutor with Tool Calling \u5177\u5907\u4e09\u5927\u663e\u8457\u4f18\u52bf\uff1a<\/p>\n<ul>\n<li><strong>\u52a8\u6001\u51b3\u7b56<\/strong>\uff1a\u4ee3\u7406\u6839\u636e\u4e0a\u4e0b\u6587\u81ea\u4e3b\u9009\u62e9\u5de5\u5177\uff0c\u65e0\u9700\u9884\u8bbe\u56fa\u5b9a\u6d41\u7a0b\u3002<\/li>\n<li><strong>\u591a\u5de5\u5177\u534f\u540c<\/strong>\uff1a\u53ef\u540c\u65f6\u8c03\u7528\u591a\u4e2a\u5de5\u5177\uff08\u4f8b\u5982\u5148\u641c\u7d22\u518d\u8ba1\u7b97\uff09\uff0c\u5e76\u5c06\u7ed3\u679c\u6574\u5408\u3002<\/li>\n<li><strong>\u9519\u8bef\u6062\u590d<\/strong>\uff1a\u5f53\u5de5\u5177\u8c03\u7528\u5931\u8d25\u65f6\uff0c\u652f\u6301\u91cd\u8bd5\u6216\u56de\u9000\uff0c\u63d0\u5347\u9c81\u68d2\u6027\u3002<\/li>\n<\/ul>\n<h3>\u6027\u80fd\u4e0e\u5b89\u5168<\/h3>\n<p>LangChain \u5185\u7f6e\u4e86\u8bf7\u6c42\u9891\u7387\u9650\u5236\u3001\u8d85\u65f6\u63a7\u5236\u3001Token \u76d1\u63a7\u7b49\u673a\u5236\uff0c\u786e\u4fdd\u751f\u4ea7\u73af\u5883\u7a33\u5b9a\u3002\u5f00\u53d1\u8005\u8fd8\u53ef\u901a\u8fc7\u56de\u8c03\u7cfb\u7edf\u5b9e\u65f6\u8ffd\u8e2a\u6bcf\u4e00\u6b65\u7684\u63a8\u7406\u8fc7\u7a0b\u3002<\/p>\n<h2>\u5178\u578b\u5e94\u7528\u573a\u666f<\/h2>\n<p>\u8be5\u5de5\u5177\u5728\u4ee5\u4e0b\u9886\u57df\u5c55\u73b0\u5de8\u5927\u4ef7\u503c\uff1a<\/p>\n<ul>\n<li><strong>\u667a\u80fd\u5ba2\u670d<\/strong>\uff1a\u67e5\u8be2\u8ba2\u5355\u72b6\u6001\uff08\u8c03\u7528\u6570\u636e\u5e93\u5de5\u5177\uff09\u3001\u751f\u6210\u56de\u590d\u3002<\/li>\n<li><strong>\u6570\u636e\u5206\u6790\u52a9\u624b<\/strong>\uff1a\u7528\u6237\u7528\u81ea\u7136\u8bed\u8a00\u63d0\u95ee\uff0c\u4ee3\u7406\u81ea\u52a8\u6267\u884c SQL \u67e5\u8be2\u5e76\u8fd4\u56de\u56fe\u8868\u3002<\/li>\n<li><strong>\u81ea\u52a8\u5316\u5de5\u4f5c\u6d41<\/strong>\uff1a\u5982\u53d1\u9001\u90ae\u4ef6\u3001\u66f4\u65b0 CRM \u8bb0\u5f55\u3001\u8c03\u5ea6\u65e5\u7a0b\u7b49\u3002<\/li>\n<li><strong>\u7814\u7a76\u8f85\u52a9<\/strong>\uff1a\u540c\u65f6\u68c0\u7d22\u591a\u4e2a\u5b66\u672f\u6e90\u5e76\u5bf9\u6bd4\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<h2>\u5feb\u901f\u4e0a\u624b\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684 Python \u4ee3\u7801\u903b\u8f91\uff1a\u5b9a\u4e49\u641c\u7d22\u5de5\u5177\uff0c\u521b\u5efa OpenAI \u51fd\u6570\u8c03\u7528\u4ee3\u7406\uff0c\u7136\u540e\u901a\u8fc7 AgentExecutor \u8fd0\u884c\u3002\u5173\u952e\u6b65\u9aa4\u5305\u62ec\uff1a\u5b9e\u4f8b\u5316\u5de5\u5177\u5217\u8868\u3001\u751f\u6210 agent\u3001\u4f20\u5165 AgentExecutor \u5e76\u8c03\u7528 invoke \u65b9\u6cd5\u3002LangChain \u5b98\u65b9\u6587\u6863\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684 Notebook \u793a\u4f8b\uff0c\u5efa\u8bae\u5f00\u53d1\u8005\u76f4\u63a5\u53c2\u8003\u3002<\/p>\n<p>\u5b98\u65b9\u6587\u6863\u4e0e\u4ee3\u7801\u4ed3\u5e93\uff1a<a href=\"https:\/\/python.langchain.com\/docs\/modules\/agents\/agent_types\/openai_functions_agent\" target=\"_blank\">\u5b98\u65b9\u7f51\u7ad9<\/a><\/p>\n<h3>\u6700\u4f73\u5b9e\u8df5<\/h3>\n<ul>\n<li>\u4e3a\u6bcf\u4e2a\u5de5\u5177\u63d0\u4f9b\u6e05\u6670\u7684\u4e2d\u6587\u63cf\u8ff0\uff0c\u5e2e\u52a9\u6a21\u578b\u6b63\u786e\u9009\u62e9\u3002<\/li>\n<li>\u4f7f\u7528 verbose=True \u5f00\u542f\u8c03\u8bd5\u65e5\u5fd7\uff0c\u4fbf\u4e8e\u6392\u67e5\u8c03\u7528\u94fe\u3002<\/li>\n<li>\u5bf9\u654f\u611f\u5de5\u5177\uff08\u5982\u5220\u9664\u64cd\u4f5c\uff09\u6dfb\u52a0\u786e\u8ba4\u673a\u5236\uff0c\u907f\u514d\u8bef\u8c03\u7528\u3002<\/li>\n<\/ul>\n<h2>\u603b\u7ed3<\/h2>\n<p>LangChain AgentExecutor with Tool Calling \u5df2\u6210\u4e3a\u6784\u5efa\u81ea\u4e3b AI \u4ee3\u7406\u7684\u884c\u4e1a\u6807\u51c6\u65b9\u6848\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u95ee\u7b54\u589e\u5f3a\uff0c\u8fd8\u662f\u590d\u6742\u7684\u591a\u6b65\u9aa4\u81ea\u52a8\u5316\uff0c\u5b83\u90fd\u80fd\u63d0\u4f9b\u7075\u6d3b\u4e14\u53ef\u9760\u7684\u6267\u884c\u5f15\u64ce\u3002\u5f00\u53d1\u8005\u5e94\u6df1\u5165\u7406\u89e3\u5176\u8fd0\u884c\u539f\u7406\uff0c\u5e76\u7ed3\u5408\u5b9e\u9645\u573a\u666f\u4e0d\u65ad\u4f18\u5316\u63d0\u793a\u8bcd\u4e0e\u5de5\u5177\u8bbe\u8ba1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LangChain \u7684 AgentExecutor \u662f\u6784\u5efa\u667a\u80fd\u4ee3\u7406\uff08Agent\uff09\u7684\u6838\u5fc3\u5f15\u64ce\uff0c\u914d\u5408 Tool C [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[9885,9887,9884,9886,9889],"class_list":["post-7938","post","type-post","status-publish","format-standard","hentry","category-4","tag-agentexecutor","tag-ai","tag-langchain","tag-tool-calling","tag-9889"],"_links":{"self":[{"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/posts\/7938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ab123.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7938"}],"version-history":[{"count":1,"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/posts\/7938\/revisions"}],"predecessor-version":[{"id":7941,"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/posts\/7938\/revisions\/7941"}],"wp:attachment":[{"href":"https:\/\/ab123.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ab123.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ab123.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}