{"id":102314,"date":"2026-09-08T13:01:16","date_gmt":"2026-09-08T05:01:16","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/102314.html"},"modified":"2026-09-08T13:01:16","modified_gmt":"2026-09-08T05:01:16","slug":"%e4%bb%8e%e9%9b%b6%e6%89%8b%e5%86%99%e4%b8%80%e4%b8%aa-react-agent%ef%bc%9apython-%e5%ae%9e%e6%88%98%ef%bc%88%e9%99%84%e5%ae%8c%e6%95%b4%e4%bb%a3%e7%a0%81%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/102314.html","title":{"rendered":"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09"},"content":{"rendered":"<h2>\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent&#xff1a;Python \u5b9e\u6218&#xff08;\u9644\u5b8c\u6574\u4ee3\u7801&#xff09;<\/h2>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1152\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260908050114-6a9f969a5e6da.jpg\" width=\"2048\" \/><\/p>\n<h3>\u524d\u8a00<\/h3>\n<p>\u524d\u4e09\u7bc7\u6211\u4eec\u8bb2\u5b8c\u4e86\u6982\u5ff5\u3001\u67b6\u6784\u548c\u6846\u67b6\u3002\u8fd9\u7bc7\u6587\u7ae0\u56de\u5230\u672c\u8d28&#xff1a;\u4e0d\u4f9d\u8d56\u4efb\u4f55 Agent \u6846\u67b6&#xff0c;\u7528\u7eaf Python \u624b\u5199\u4e00\u4e2a\u53ef\u8fd0\u884c\u7684 ReAct Agent\u3002<\/p>\n<p>\u8bfb\u5b8c\u4f60\u4f1a\u7406\u89e3&#xff1a;<\/p>\n<ul>\n<li>\n<p>ReAct \u5faa\u73af\u5728\u4ee3\u7801\u5c42\u9762\u5230\u5e95\u957f\u4ec0\u4e48\u6837<\/p>\n<\/li>\n<li>\n<p>Function Calling \u7684&#034;\u58f0\u660e-\u9009\u62e9-\u6267\u884c-\u56de\u586b&#034;\u5982\u4f55\u843d\u5730<\/p>\n<\/li>\n<li>\n<p>\u5982\u4f55\u5bf9\u63a5\u4efb\u610f OpenAI \u517c\u5bb9 API&#xff08;DeepSeek \/ \u8c46\u5305 \/ \u901a\u4e49 \/ OpenAI \u90fd\u884c&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e00\u3001\u73af\u5883\u51c6\u5907<\/h3>\n<p>\u53ea\u9700\u8981 Python 3.9&#043; \u548c requests&#xff1a;<\/p>\n<p>pip install requests<\/p>\n<p>\u914d\u7f6e\u73af\u5883\u53d8\u91cf&#xff08;\u4ee5 DeepSeek \u4e3a\u4f8b&#xff0c;\u53ef\u6362\u6210\u4efb\u610f OpenAI \u517c\u5bb9\u63a5\u53e3&#xff09;&#xff1a;<\/p>\n<p>export LLM_API_KEY&#061;sk-\u4f60\u7684\u5bc6\u94a5<br \/>\nexport LLM_BASE_URL&#061;https:\/\/api.deepseek.com\/v1<br \/>\nexport LLM_MODEL&#061;deepseek-chat<\/p>\n<p>Windows PowerShell \u4e0b\u7528 $env:LLM_API_KEY&#061;&#034;sk-&#8230;&#034; \u8bbe\u7f6e\u3002<\/p>\n<h3>\u4e8c\u3001\u6574\u4f53\u8bbe\u8ba1<\/h3>\n<p>\u6574\u4e2a Agent \u5c31\u662f\u4e00\u4e2a&#034;\u5faa\u73af&#034;&#xff1a;<\/p>\n<p>Action<\/p>\n<p>Final Answer<\/p>\n<p>\u7528\u6237\u95ee\u9898<\/p>\n<p>\u7ec4\u88c5\u6d88\u606f<\/p>\n<p>\u8c03\u7528 LLM<\/p>\n<p>\u8f93\u51fa\u7c7b\u578b?<\/p>\n<p>\u6267\u884c\u5de5\u5177<\/p>\n<p>Observation \u56de\u586b<\/p>\n<p>\u8f93\u51fa\u7ed3\u679c<\/p>\n<h3>\u4e09\u3001Step 1&#xff1a;\u5b9a\u4e49\u5de5\u5177<\/h3>\n<p>Agent \u7684&#034;\u624b\u811a&#034;\u5c31\u662f\u666e\u901a Python \u51fd\u6570&#xff0c;\u6ce8\u518c\u5230 TOOLS \u5b57\u5178\u5373\u53ef&#xff1a;<\/p>\n<p>import re<br \/>\n\u200b<br \/>\ndef get_weather(city: str) -&gt; str:<br \/>\n \u00a0 \u00a0&#034;&#034;&#034;\u67e5\u8be2\u57ce\u5e02\u5929\u6c14&#xff08;\u6f14\u793a\u7528&#xff0c;\u771f\u5b9e\u573a\u666f\u66ff\u6362\u4e3a\u5929\u6c14 API&#xff09;&#034;&#034;&#034;<br \/>\n \u00a0 \u00a0table &#061; {&#034;\u6df1\u5733&#034;: &#034;\u5c0f\u96e8 22~26\u2103&#034;, &#034;\u5317\u4eac&#034;: &#034;\u6674 15~28\u2103&#034;, &#034;\u4e0a\u6d77&#034;: &#034;\u591a\u4e91 20~27\u2103&#034;}<br \/>\n \u00a0 \u00a0return table.get(city, f&#034;{city}&#xff1a;\u6682\u65e0\u5929\u6c14\u6570\u636e&#034;)<br \/>\n\u200b<br \/>\ndef calculator(expr: str) -&gt; str:<br \/>\n \u00a0 \u00a0&#034;&#034;&#034;\u5b89\u5168\u8ba1\u7b97\u5668&#xff1a;\u53ea\u5141\u8bb8\u6570\u5b57\u548c\u57fa\u672c\u8fd0\u7b97\u7b26&#034;&#034;&#034;<br \/>\n \u00a0 \u00a0expr &#061; expr.replace(&#034; &#034;, &#034;&#034;)<br \/>\n \u00a0 \u00a0if not re.fullmatch(r&#034;[\\\\d&#043;\\\\-*\/().%]&#043;&#034;, expr):<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0return &#034;Error: \u8868\u8fbe\u5f0f\u5305\u542b\u975e\u6cd5\u5b57\u7b26&#034;<br \/>\n \u00a0 \u00a0try:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0return str(eval(expr, {&#034;__builtins__&#034;: {}}, {}))<br \/>\n \u00a0 \u00a0except Exception as e:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0return f&#034;Error: {e}&#034;<br \/>\n\u200b<br \/>\nTOOLS &#061; {<br \/>\n \u00a0 \u00a0&#034;get_weather&#034;: {&#034;desc&#034;: &#034;\u67e5\u8be2\u57ce\u5e02\u5929\u6c14&#xff0c;\u53c2\u6570 city(\u57ce\u5e02\u540d)&#034;, &#034;func&#034;: get_weather},<br \/>\n \u00a0 \u00a0&#034;calculator&#034;: {&#034;desc&#034;: &#034;\u8ba1\u7b97\u6570\u5b66\u8868\u8fbe\u5f0f&#xff0c;\u53c2\u6570 expr(\u5982 12*8&#043;6)&#034;, &#034;func&#034;: calculator},<br \/>\n}<\/p>\n<p>\u6ce8\u610f eval \u91cc\u7981\u7528\u4e86\u5185\u7f6e\u51fd\u6570&#xff08;__builtins__ \u7f6e\u7a7a&#xff09;&#xff0c;\u907f\u514d\u4ee3\u7801\u6ce8\u5165\u2014\u2014\u8fd9\u662f\u5de5\u5177\u5b9e\u73b0\u91cc\u5fc5\u987b\u5b88\u4f4f\u7684\u5e95\u7ebf\u3002<\/p>\n<h3>\u56db\u3001Step 2&#xff1a;\u6784\u9020 ReAct Prompt<\/h3>\n<p>\u901a\u8fc7\u63d0\u793a\u8bcd\u8ba9\u6a21\u578b\u5b66\u4f1a&#034;\u601d\u8003-\u884c\u52a8-\u89c2\u5bdf&#034;\u7684\u5faa\u73af\u683c\u5f0f&#xff1a;<\/p>\n<p>SYSTEM_PROMPT &#061; &#034;&#034;&#034;\u4f60\u662f\u4e00\u4e2a\u4f7f\u7528 ReAct \u8303\u5f0f\u7684 AI Agent\u3002\u8bf7\u4e25\u683c\u6309\u4e0b\u9762\u7684\u683c\u5f0f\u5faa\u73af\u8f93\u51fa&#xff1a;<br \/>\n\u200b<br \/>\nThought: \u4f60\u5f53\u524d\u7684\u5206\u6790\u548c\u601d\u8003<br \/>\nAction: \u5de5\u5177\u540d<br \/>\nAction Input: {{&#034;\u53c2\u6570\u540d&#034;: &#034;\u53c2\u6570\u503c&#034;}}<br \/>\n\u200b<br \/>\n\u5f53\u4fe1\u606f\u8db3\u591f\u65f6\u8f93\u51fa&#xff1a;<br \/>\n\u200b<br \/>\nThought: \u6211\u5df2\u7ecf\u5f97\u5230\u8db3\u591f\u4fe1\u606f<br \/>\nFinal Answer: \u6700\u7ec8\u7b54\u6848<br \/>\n\u200b<br \/>\n\u53ef\u7528\u5de5\u5177&#xff1a;<br \/>\n{tools}<br \/>\n\u200b<br \/>\n\u6ce8\u610f&#xff1a;\u9700\u8981\u67e5\u8be2\u6216\u8ba1\u7b97\u65f6\u5fc5\u987b\u8c03\u7528\u5de5\u5177&#xff0c;\u7981\u6b62\u51ed\u7a7a\u7f16\u9020\u7ed3\u679c\u3002&#034;&#034;&#034;<\/p>\n<h3>\u4e94\u3001Step 3&#xff1a;\u89e3\u6790\u6a21\u578b\u8f93\u51fa<\/h3>\n<p>\u6a21\u578b\u8fd4\u56de\u7684\u662f\u6587\u672c&#xff0c;\u6211\u4eec\u8981\u628a\u5b83\u89e3\u6790\u6210\u7ed3\u6784\u5316\u6307\u4ee4&#xff1a;<\/p>\n<p>import json<br \/>\n\u200b<br \/>\ndef parse_response(text: str):<br \/>\n \u00a0 \u00a0&#034;&#034;&#034;\u89e3\u6790\u6a21\u578b\u8f93\u51fa&#xff0c;\u8fd4\u56de final \u6216 action \u4e24\u79cd\u7ed3\u6784&#034;&#034;&#034;<br \/>\n \u00a0 \u00a0if &#034;Final Answer:&#034; in text:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0return {&#034;type&#034;: &#034;final&#034;, &#034;value&#034;: text.split(&#034;Final Answer:&#034;, 1)[1].strip()}<br \/>\n\u200b<br \/>\n \u00a0 \u00a0action &#061; re.search(r&#034;Action:\\\\s*(\\\\w&#043;)&#034;, text)<br \/>\n \u00a0 \u00a0action_input &#061; re.search(r&#034;Action Input:\\\\s*(\\\\{.*?\\\\})&#034;, text, re.S)<br \/>\n \u00a0 \u00a0if action:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0params &#061; {}<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0if action_input:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0try:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0params &#061; json.loads(action_input.group(1))<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0except json.JSONDecodeError:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0params &#061; {}<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0return {&#034;type&#034;: &#034;action&#034;, &#034;name&#034;: action.group(1), &#034;params&#034;: params}<br \/>\n\u200b<br \/>\n \u00a0 \u00a0return {&#034;type&#034;: &#034;final&#034;, &#034;value&#034;: text}<\/p>\n<h3>\u516d\u3001Step 4&#xff1a;\u4e3b\u5faa\u73af&#xff08;\u6838\u5fc3&#xff09;<\/h3>\n<p>import os<br \/>\nimport requests<br \/>\n\u200b<br \/>\nAPI_KEY &#061; os.environ.get(&#034;LLM_API_KEY&#034;, &#034;sk-xxx&#034;)<br \/>\nBASE_URL &#061; os.environ.get(&#034;LLM_BASE_URL&#034;, &#034;https:\/\/api.deepseek.com\/v1&#034;)<br \/>\nMODEL &#061; os.environ.get(&#034;LLM_MODEL&#034;, &#034;deepseek-chat&#034;)<br \/>\n\u200b<br \/>\ndef chat(messages, temperature&#061;0.0):<br \/>\n \u00a0 \u00a0resp &#061; requests.post(<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0f&#034;{BASE_URL}\/chat\/completions&#034;,<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0headers&#061;{&#034;Authorization&#034;: f&#034;Bearer {API_KEY}&#034;, &#034;Content-Type&#034;: &#034;application\/json&#034;},<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0json&#061;{&#034;model&#034;: MODEL, &#034;messages&#034;: messages, &#034;temperature&#034;: temperature},<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0timeout&#061;60,<br \/>\n \u00a0  )<br \/>\n \u00a0 \u00a0resp.raise_for_status()<br \/>\n \u00a0 \u00a0return resp.json()[&#034;choices&#034;][0][&#034;message&#034;][&#034;content&#034;]<br \/>\n\u200b<br \/>\ndef run_agent(question: str, max_steps: int &#061; 8) -&gt; str:<br \/>\n \u00a0 \u00a0tool_desc &#061; &#034;\\\\n&#034;.join(f&#034;- {name}: {info[&#039;desc&#039;]}&#034; for name, info in TOOLS.items())<br \/>\n \u00a0 \u00a0messages &#061; [<br \/>\n \u00a0 \u00a0 \u00a0  {&#034;role&#034;: &#034;system&#034;, &#034;content&#034;: SYSTEM_PROMPT.format(tools&#061;tool_desc)},<br \/>\n \u00a0 \u00a0 \u00a0  {&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: question},<br \/>\n \u00a0  ]<br \/>\n\u200b<br \/>\n \u00a0 \u00a0for step in range(1, max_steps &#043; 1):<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0print(f&#034;\\\\n[Step {step}] \u8c03\u7528 LLM &#8230;&#034;)<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0reply &#061; chat(messages)<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0print(reply)<br \/>\n\u200b<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0parsed &#061; parse_response(reply)<br \/>\n\u200b<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0# 1. \u6a21\u578b\u7ed9\u51fa\u6700\u7ec8\u7b54\u6848&#xff0c;\u5faa\u73af\u7ed3\u675f<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0if parsed[&#034;type&#034;] &#061;&#061; &#034;final&#034;:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0return parsed[&#034;value&#034;]<br \/>\n\u200b<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0# 2. \u6a21\u578b\u8981\u8c03\u7528\u5de5\u5177<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0tool &#061; TOOLS.get(parsed[&#034;name&#034;])<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0if tool is None:<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0messages.append({&#034;role&#034;: &#034;assistant&#034;, &#034;content&#034;: reply})<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0messages.append({&#034;role&#034;: &#034;user&#034;,<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#034;content&#034;: f&#034;Observation: \u5de5\u5177 {parsed[&#039;name&#039;]} \u4e0d\u5b58\u5728&#xff0c;\u8bf7\u6539\u7528\u53ef\u7528\u5de5\u5177&#034;})<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0continue<br \/>\n\u200b<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0result &#061; tool[&#034;func&#034;](**parsed[&#034;params&#034;])<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0print(f&#034; \u00a0  \u5de5\u5177\u8fd4\u56de: {result}&#034;)<br \/>\n\u200b<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0# 3. \u5173\u952e\u4e00\u6b65&#xff1a;\u628a\u5de5\u5177\u7ed3\u679c\u4f5c\u4e3a Observation \u56de\u586b\u7ed9 LLM<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0messages.append({&#034;role&#034;: &#034;assistant&#034;, &#034;content&#034;: reply})<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0messages.append({&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: f&#034;Observation: {result}&#034;})<br \/>\n\u200b<br \/>\n \u00a0 \u00a0return &#034;\u5df2\u8fbe\u5230\u6700\u5927\u6b65\u6570&#xff0c;\u4efb\u52a1\u672a\u5b8c\u6210\u3002&#034;<br \/>\n\u200b<br \/>\nif __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n \u00a0 \u00a0print(&#034;\u7ed3\u679c:&#034;, run_agent(&#034;\u6df1\u5733\u4eca\u5929\u4f1a\u4e0b\u96e8\u5417&#xff1f;\u6c14\u6e29\u591a\u5c11\u5ea6&#xff1f;&#034;))<br \/>\n \u00a0 \u00a0print(&#034;\u7ed3\u679c:&#034;, run_agent(&#034;\u5e2e\u6211\u8ba1\u7b97 (23*7&#043;15)\/4 \u7b49\u4e8e\u591a\u5c11&#034;))<\/p>\n<h3>\u4e03\u3001\u8fd0\u884c\u6548\u679c<\/h3>\n<p>\u914d\u597d API Key \u540e\u76f4\u63a5\u8fd0\u884c&#xff1a;<\/p>\n<p>[Step 1] \u8c03\u7528 LLM &#8230;<br \/>\nThought: \u7528\u6237\u60f3\u77e5\u9053\u6df1\u5733\u7684\u5929\u6c14&#xff0c;\u6211\u9700\u8981\u8c03\u7528 get_weather \u5de5\u5177<br \/>\nAction: get_weather<br \/>\nAction Input: {&#034;city&#034;: &#034;\u6df1\u5733&#034;}<br \/>\n \u00a0  \u5de5\u5177\u8fd4\u56de: \u5c0f\u96e8 22~26\u2103<br \/>\n[Step 2] \u8c03\u7528 LLM &#8230;<br \/>\nThought: \u6df1\u5733\u4eca\u5929\u6709\u96e8&#xff0c;\u6211\u5e94\u8be5\u63d0\u9192\u7528\u6237\u5e26\u4f1e<br \/>\nFinal Answer: \u6df1\u5733\u4eca\u5929\u5c0f\u96e8&#xff0c;\u6c14\u6e29 22~26\u2103&#xff0c;\u8bb0\u5f97\u5e26\u4f1e\u54e6\u3002<br \/>\n\u7ed3\u679c: \u6df1\u5733\u4eca\u5929\u5c0f\u96e8&#xff0c;\u6c14\u6e29 22~26\u2103&#xff0c;\u8bb0\u5f97\u5e26\u4f1e\u54e6\u3002<br \/>\n\u200b<br \/>\n[Step 1] \u8c03\u7528 LLM &#8230;<br \/>\nThought: \u8fd9\u662f\u4e00\u4e2a\u6570\u5b66\u8ba1\u7b97\u9898&#xff0c;\u6211\u9700\u8981\u7528 calculator \u5de5\u5177<br \/>\nAction: calculator<br \/>\nAction Input: {&#034;expr&#034;: &#034;(23*7&#043;15)\/4&#034;}<br \/>\n \u00a0  \u5de5\u5177\u8fd4\u56de: 44.0<br \/>\n[Step 2] \u8c03\u7528 LLM &#8230;<br \/>\nThought: \u8ba1\u7b97\u5b8c\u6210<br \/>\nFinal Answer: (23*7&#043;15)\/4 &#061; 44.0<br \/>\n\u7ed3\u679c: (23*7&#043;15)\/4 &#061; 44.0<\/p>\n<p>\u5b8c\u6574\u7684 ReAct \u5faa\u73af\u2014\u2014\u601d\u8003\u3001\u884c\u52a8\u3001\u89c2\u5bdf\u3001\u518d\u601d\u8003\u2014\u2014\u5c31\u8fd9\u6837\u5728\u4ee3\u7801\u91cc\u8dd1\u901a\u4e86\u3002<\/p>\n<h3>\u516b\u3001\u53ef\u4f18\u5316\u65b9\u5411<\/h3>\n<table>\n<tr>\u65b9\u5411\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u8bb0\u5fc6<\/td>\n<td>\u63a5\u5165\u5411\u91cf\u5e93&#xff08;\u5982 Chroma \/ Milvus&#xff09;&#043; RAG&#xff0c;\u652f\u6301\u957f\u671f\u8bb0\u5fc6<\/td>\n<\/tr>\n<tr>\n<td>\u591a\u5de5\u5177\u4e0e\u91cd\u8bd5<\/td>\n<td>\u5de5\u5177\u8c03\u7528\u5931\u8d25\u65f6\u81ea\u52a8\u91cd\u8bd5\u3001\u7ea0\u9519<\/td>\n<\/tr>\n<tr>\n<td>\u6d41\u5f0f\u8f93\u51fa<\/td>\n<td>\u7528 SSE \u6d41\u5f0f\u8fd4\u56de&#xff0c;\u63d0\u5347\u4f53\u9a8c<\/td>\n<\/tr>\n<tr>\n<td>\u7ed3\u6784\u5316\u89e3\u6790<\/td>\n<td>\u7528 JSON Mode \u6216 Function Calling \u539f\u751f\u63a5\u53e3\u66ff\u4ee3\u6b63\u5219\u89e3\u6790<\/td>\n<\/tr>\n<tr>\n<td>\u5b89\u5168\u62a4\u680f<\/td>\n<td>\u5de5\u5177\u767d\u540d\u5355\u3001\u654f\u611f\u64cd\u4f5c\u4eba\u5de5\u786e\u8ba4&#xff08;Human-in-the-Loop&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e5d\u3001\u603b\u7ed3<\/h3>\n<ul>\n<li>\n<p>ReAct Agent \u7684\u6838\u5fc3\u5c31\u662f\u5faa\u73af&#xff1a;Thought \u2192 Action \u2192 Observation \u2192 \u518d\u601d\u8003<\/p>\n<\/li>\n<li>\n<p>Function Calling \u7684\u843d\u5730 &#061; \u58f0\u660e\u5de5\u5177 &#043; \u6a21\u578b\u9009\u62e9 &#043; \u7a0b\u5e8f\u6267\u884c &#043; \u7ed3\u679c\u56de\u586b<\/p>\n<\/li>\n<li>\n<p>\u672c\u6559\u7a0b\u4ee3\u7801\u7ea6 100 \u884c&#xff0c;\u5374\u5df2\u7ecf\u5177\u5907\u771f\u5b9e Agent \u7684\u9aa8\u67b6&#xff0c;\u540e\u7eed\u6240\u6709\u6846\u67b6\u90fd\u53ea\u662f\u5728\u8fd9\u5957\u9aa8\u67b6\u4e0a\u7684\u5c01\u88c5\u548c\u589e\u5f3a<\/p>\n<\/li>\n<\/ul>\n<p>\u81f3\u6b64&#xff0c;\u3010AI Agent \u7cfb\u5217\u3011\u56db\u7bc7\u5b8c\u7ed3&#xff1a;\u6982\u5ff5 \u2192 \u67b6\u6784 \u2192 \u6846\u67b6 \u2192 \u5b9e\u6218\u3002\u5efa\u8bae\u6309\u987a\u5e8f\u5b66\u4e60&#xff0c;\u52a8\u624b\u8dd1\u4e00\u904d\u7b2c\u56db\u7bc7\u7684\u4ee3\u7801&#xff0c;\u4f60\u5bf9 Agent \u7684\u7406\u89e3\u4f1a\u4e0a\u4e00\u4e2a\u53f0\u9636\u3002<\/p>\n<p>\u5982\u679c\u672c\u6587\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u6b22\u8fce\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u5173\u6ce8&#xff01;\u6709\u95ee\u9898\u8bc4\u8bba\u533a\u89c1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent&#xff1a;Python \u5b9e\u6218&#xff08;\u9644\u5b8c\u6574\u4ee3\u7801&#xff09;\u524d\u8a00\u524d\u4e09\u7bc7\u6211\u4eec\u8bb2\u5b8c\u4e86\u6982\u5ff5\u3001\u67b6\u6784\u548c\u6846\u67b6\u3002\u8fd9\u7bc7\u6587\u7ae0\u56de\u5230\u672c\u8d28&#xff1a;\u4e0d\u4f9d\u8d56\u4efb\u4f55 Agent \u6846\u67b6&#xff0c;\u7528\u7eaf Python \u624b\u5199\u4e00\u4e2a\u53ef\u8fd0\u884c\u7684 ReAct Agent\u3002\u8bfb\u5b8c\u4f60\u4f1a\u7406\u89e3&#xff1a;ReAct \u5faa\u73af\u5728\u4ee3\u7801\u5c42\u9762\u5230\u5e95\u957f\u4ec0\u4e48\u6837Function Calling \u7684\\&#8221;\u58f0\u660e-\u9009\u62e9-\u6267\u884c-\u56de\u586b\\&#8221;\u5982\u4f55\u843d\u5730\u5982\u4f55\u5bf9\u63a5\u4efb\u610f OpenAI \u517c\u5bb9 API&#xff08;<\/p>\n","protected":false},"author":2,"featured_media":102313,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11653,81,524,50],"topic":[],"class_list":["post-102314","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-11653","tag-python","tag-react-js","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09 - \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\/102314.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent&#xff1a;Python \u5b9e\u6218&#xff08;\u9644\u5b8c\u6574\u4ee3\u7801&#xff09;\u524d\u8a00\u524d\u4e09\u7bc7\u6211\u4eec\u8bb2\u5b8c\u4e86\u6982\u5ff5\u3001\u67b6\u6784\u548c\u6846\u67b6\u3002\u8fd9\u7bc7\u6587\u7ae0\u56de\u5230\u672c\u8d28&#xff1a;\u4e0d\u4f9d\u8d56\u4efb\u4f55 Agent \u6846\u67b6&#xff0c;\u7528\u7eaf Python \u624b\u5199\u4e00\u4e2a\u53ef\u8fd0\u884c\u7684 ReAct Agent\u3002\u8bfb\u5b8c\u4f60\u4f1a\u7406\u89e3&#xff1a;ReAct \u5faa\u73af\u5728\u4ee3\u7801\u5c42\u9762\u5230\u5e95\u957f\u4ec0\u4e48\u6837Function Calling \u7684&quot;\u58f0\u660e-\u9009\u62e9-\u6267\u884c-\u56de\u586b&quot;\u5982\u4f55\u843d\u5730\u5982\u4f55\u5bf9\u63a5\u4efb\u610f OpenAI \u517c\u5bb9 API&#xff08;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/102314.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-08T05:01:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260908050114-6a9f969a5e6da.jpg\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102314.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/102314.html\",\"name\":\"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-08T05:01:16+00:00\",\"dateModified\":\"2026-09-08T05:01:16+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/102314.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/102314.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102314.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09\"}]},{\"@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":"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09 - \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\/102314.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent&#xff1a;Python \u5b9e\u6218&#xff08;\u9644\u5b8c\u6574\u4ee3\u7801&#xff09;\u524d\u8a00\u524d\u4e09\u7bc7\u6211\u4eec\u8bb2\u5b8c\u4e86\u6982\u5ff5\u3001\u67b6\u6784\u548c\u6846\u67b6\u3002\u8fd9\u7bc7\u6587\u7ae0\u56de\u5230\u672c\u8d28&#xff1a;\u4e0d\u4f9d\u8d56\u4efb\u4f55 Agent \u6846\u67b6&#xff0c;\u7528\u7eaf Python \u624b\u5199\u4e00\u4e2a\u53ef\u8fd0\u884c\u7684 ReAct Agent\u3002\u8bfb\u5b8c\u4f60\u4f1a\u7406\u89e3&#xff1a;ReAct \u5faa\u73af\u5728\u4ee3\u7801\u5c42\u9762\u5230\u5e95\u957f\u4ec0\u4e48\u6837Function Calling \u7684\"\u58f0\u660e-\u9009\u62e9-\u6267\u884c-\u56de\u586b\"\u5982\u4f55\u843d\u5730\u5982\u4f55\u5bf9\u63a5\u4efb\u610f OpenAI \u517c\u5bb9 API&#xff08;","og_url":"https:\/\/www.wsisp.com\/helps\/102314.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-08T05:01:16+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260908050114-6a9f969a5e6da.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/102314.html","url":"https:\/\/www.wsisp.com\/helps\/102314.html","name":"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-08T05:01:16+00:00","dateModified":"2026-09-08T05:01:16+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/102314.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/102314.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/102314.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4ece\u96f6\u624b\u5199\u4e00\u4e2a ReAct Agent\uff1aPython \u5b9e\u6218\uff08\u9644\u5b8c\u6574\u4ee3\u7801\uff09"}]},{"@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\/102314","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=102314"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102314\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/102313"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=102314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=102314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=102314"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=102314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}