import{s as Pt,n as Ht,o as kt}from"../chunks/scheduler.37c15a92.js";import{S as At,i as Rt,g as a,s as i,r as nt,A as wt,h as r,f as n,c as s,j as $t,u as lt,x as o,k as et,y as Et,a as l,v as it,d as st,t as at,w as rt}from"../chunks/index.2bf4358c.js";import{H as yt}from"../chunks/Heading.8ada512a.js";import{E as qt}from"../chunks/getInferenceSnippets.0aa3753f.js";function It(ot){let p,R,k,w,d,E,u,pt="<p>本节将深入探讨 AI 智能体的内部运作机制——其推理与规划能力。我们将解析智能体如何通过内部对话分析信息，将复杂问题分解为可管理的步骤，并决策下一步行动。同时介绍 ReAct 方法，是一种鼓励模型在行动前”逐步思考”的提示技术。</p>",q,f,ut="思维（Thought）代表着智能体<strong>解决任务的内部推理与规划过程</strong>。",I,c,mt="这利用了智能体的大型语言模型 (LLM) 能力<strong>来分析其 prompt 中的信息</strong>。",O,h,dt="可将其视为智能体的内部对话，在此过程中它会考量当前任务并制定应对策略。",z,v,ft="智能体的思维负责获取当前观察结果，并决定下一步应采取的行动。",S,x,ct="通过这一过程，智能体能够<strong>将复杂问题分解为更小、更易管理的步骤</strong>，反思过往经验，并根据新信息持续调整计划。",B,g,ht="以下是常见思维模式的示例：",U,C,vt="<thead><tr><th>思维类型</th> <th>示例</th></tr></thead> <tbody><tr><td>Planning（规划）</td> <td>“I need to break this task into three steps: 1) gather data, 2) analyze trends, 3) generate report”（“我需要将任务分解为三步：1）收集数据 2）分析趋势 3）生成报告”）</td></tr> <tr><td>Analysis（分析）</td> <td>“Based on the error message, the issue appears to be with the database connection parameters”（“根据错误信息，问题似乎出在数据库连接参数”）</td></tr> <tr><td>Decision Making（决策）</td> <td>“Given the user’s budget constraints, I should recommend the mid-tier option”（“考虑到用户的预算限制，应推荐中端选项”）</td></tr> <tr><td>Problem Solving（问题解决）</td> <td>“To optimize this code, I should first profile it to identify bottlenecks”（“优化此代码需先进行性能分析定位瓶颈”）</td></tr> <tr><td>Memory Integration（记忆整合）</td> <td>“The user mentioned their preference for Python earlier, so I’ll provide examples in Python”（“用户先前提到偏好 Python，因此我将提供 Python 示例”）</td></tr> <tr><td>Self-Reflection（自我反思）</td> <td>“My last approach didn’t work well, I should try a different strategy”（“上次方法效果不佳，应尝试不同策略”）</td></tr> <tr><td>Goal Setting（目标设定）</td> <td>“To complete this task, I need to first establish the acceptance criteria”（“完成此任务需先确定验收标准”）</td></tr> <tr><td>Prioritization（优先级排序）</td> <td>“The security vulnerability should be addressed before adding new features”（“在添加新功能前应先修复安全漏洞”）</td></tr></tbody>",G,L,xt=`<p><strong>注意：</strong> 对于专为 function-calling 微调的 LLMs，思维过程是可选的。
<em>若您不熟悉 function-calling 概念，后续”行动”章节将提供详细说明。</em></p>`,K,T,Q,_,gt="核心方法是 <strong>ReAct 方法</strong>，即”推理”（Reasoning/Think）与”行动”（Acting/Act）的结合。",j,b,Ct="ReAct 是一种简单的提示技术，在让 LLM 解码后续 token 前添加”Let’s think step by step”（让我们逐步思考）的提示。",D,M,Lt="通过提示模型”逐步思考”，可以引导解码过程生成<strong>计划</strong>而非直接输出最终解决方案，因为模型被鼓励将问题<strong>分解</strong>为<em>子任务</em>。",F,$,Tt="这种方法使模型能够更详细地考虑各个子步骤，通常比直接生成最终方案产生更少错误。",N,y,_t='<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/ReAct.png" alt="ReAct"/> <figcaption>图 (d) 展示了 ReAct 方法示例，我们通过&quot;Let&#39;s think step by step&quot;提示模型</figcaption>',J,m,bt="<p>近期推理策略受到广泛关注，这体现在 Deepseek R1 或 OpenAI 的 o1 等模型的开发中。这些模型经过微调，被训练为”先思考再回答”。</p> <p>它们通过特殊标记（<code>&lt;thought&gt;</code> 和 <code>&lt;/thought&gt;</code>）来界定 <em>思考</em> 部分。这不仅是类似 ReAct 的提示技巧，更是通过分析数千个示范案例，让模型学习生成这些思考段的训练方法。</p>",V,W,X,P,Mt="现在我们已经深入理解了思维过程，接下来将更深入探讨流程的第二部分：行动。",Y,H,Z,A,tt;return d=new yt({props:{title:"思维机制：内部推理与 ReAct 方法",local:"思维机制内部推理与-react-方法",headingTag:"h1"}}),T=new yt({props:{title:"ReAct 方法",local:"react-方法",headingTag:"h2"}}),H=new qt({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit1/thoughts.mdx"}}),{c(){p=a("meta"),R=i(),k=a("p"),w=i(),nt(d.$$.fragment),E=i(),u=a("blockquote"),u.innerHTML=pt,q=i(),f=a("p"),f.innerHTML=ut,I=i(),c=a("p"),c.innerHTML=mt,O=i(),h=a("p"),h.textContent=dt,z=i(),v=a("p"),v.textContent=ft,S=i(),x=a("p"),x.innerHTML=ct,B=i(),g=a("p"),g.textContent=ht,U=i(),C=a("table"),C.innerHTML=vt,G=i(),L=a("blockquote"),L.innerHTML=xt,K=i(),nt(T.$$.fragment),Q=i(),_=a("p"),_.innerHTML=gt,j=i(),b=a("p"),b.textContent=Ct,D=i(),M=a("p"),M.innerHTML=Lt,F=i(),$=a("p"),$.textContent=Tt,N=i(),y=a("figure"),y.innerHTML=_t,J=i(),m=a("blockquote"),m.innerHTML=bt,V=i(),W=a("hr"),X=i(),P=a("p"),P.textContent=Mt,Y=i(),nt(H.$$.fragment),Z=i(),A=a("p"),this.h()},l(t){const e=wt("svelte-u9bgzb",document.head);p=r(e,"META",{name:!0,content:!0}),e.forEach(n),R=s(t),k=r(t,"P",{}),$t(k).forEach(n),w=s(t),lt(d.$$.fragment,t),E=s(t),u=r(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),o(u)!=="svelte-1tlgihp"&&(u.innerHTML=pt),q=s(t),f=r(t,"P",{"data-svelte-h":!0}),o(f)!=="svelte-1jwb6my"&&(f.innerHTML=ut),I=s(t),c=r(t,"P",{"data-svelte-h":!0}),o(c)!=="svelte-pm8gty"&&(c.innerHTML=mt),O=s(t),h=r(t,"P",{"data-svelte-h":!0}),o(h)!=="svelte-hq518o"&&(h.textContent=dt),z=s(t),v=r(t,"P",{"data-svelte-h":!0}),o(v)!=="svelte-13gnuxe"&&(v.textContent=ft),S=s(t),x=r(t,"P",{"data-svelte-h":!0}),o(x)!=="svelte-tynx3x"&&(x.innerHTML=ct),B=s(t),g=r(t,"P",{"data-svelte-h":!0}),o(g)!=="svelte-oh940c"&&(g.textContent=ht),U=s(t),C=r(t,"TABLE",{"data-svelte-h":!0}),o(C)!=="svelte-144b83x"&&(C.innerHTML=vt),G=s(t),L=r(t,"BLOCKQUOTE",{"data-svelte-h":!0}),o(L)!=="svelte-zleg4a"&&(L.innerHTML=xt),K=s(t),lt(T.$$.fragment,t),Q=s(t),_=r(t,"P",{"data-svelte-h":!0}),o(_)!=="svelte-1u5zk6a"&&(_.innerHTML=gt),j=s(t),b=r(t,"P",{"data-svelte-h":!0}),o(b)!=="svelte-p6eyld"&&(b.textContent=Ct),D=s(t),M=r(t,"P",{"data-svelte-h":!0}),o(M)!=="svelte-1rlfkid"&&(M.innerHTML=Lt),F=s(t),$=r(t,"P",{"data-svelte-h":!0}),o($)!=="svelte-6wwek0"&&($.textContent=Tt),N=s(t),y=r(t,"FIGURE",{"data-svelte-h":!0}),o(y)!=="svelte-11oc9ch"&&(y.innerHTML=_t),J=s(t),m=r(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),o(m)!=="svelte-1059a45"&&(m.innerHTML=bt),V=s(t),W=r(t,"HR",{}),X=s(t),P=r(t,"P",{"data-svelte-h":!0}),o(P)!=="svelte-no8p97"&&(P.textContent=Mt),Y=s(t),lt(H.$$.fragment,t),Z=s(t),A=r(t,"P",{}),$t(A).forEach(n),this.h()},h(){et(p,"name","hf:doc:metadata"),et(p,"content",Ot),et(u,"class","tip"),et(m,"class","tip")},m(t,e){Et(document.head,p),l(t,R,e),l(t,k,e),l(t,w,e),it(d,t,e),l(t,E,e),l(t,u,e),l(t,q,e),l(t,f,e),l(t,I,e),l(t,c,e),l(t,O,e),l(t,h,e),l(t,z,e),l(t,v,e),l(t,S,e),l(t,x,e),l(t,B,e),l(t,g,e),l(t,U,e),l(t,C,e),l(t,G,e),l(t,L,e),l(t,K,e),it(T,t,e),l(t,Q,e),l(t,_,e),l(t,j,e),l(t,b,e),l(t,D,e),l(t,M,e),l(t,F,e),l(t,$,e),l(t,N,e),l(t,y,e),l(t,J,e),l(t,m,e),l(t,V,e),l(t,W,e),l(t,X,e),l(t,P,e),l(t,Y,e),it(H,t,e),l(t,Z,e),l(t,A,e),tt=!0},p:Ht,i(t){tt||(st(d.$$.fragment,t),st(T.$$.fragment,t),st(H.$$.fragment,t),tt=!0)},o(t){at(d.$$.fragment,t),at(T.$$.fragment,t),at(H.$$.fragment,t),tt=!1},d(t){t&&(n(R),n(k),n(w),n(E),n(u),n(q),n(f),n(I),n(c),n(O),n(h),n(z),n(v),n(S),n(x),n(B),n(g),n(U),n(C),n(G),n(L),n(K),n(Q),n(_),n(j),n(b),n(D),n(M),n(F),n($),n(N),n(y),n(J),n(m),n(V),n(W),n(X),n(P),n(Y),n(Z),n(A)),n(p),rt(d,t),rt(T,t),rt(H,t)}}}const Ot='{"title":"思维机制：内部推理与 ReAct 方法","local":"思维机制内部推理与-react-方法","sections":[{"title":"ReAct 方法","local":"react-方法","sections":[],"depth":2}],"depth":1}';function zt(ot){return kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Kt extends At{constructor(p){super(),Rt(this,p,zt,It,Pt,{})}}export{Kt as component};
