import{s as Rt,o as kt,n as wt}from"../chunks/scheduler.889ebb13.js";import{S as It,i as Et,g as a,s as i,r as E,A as zt,h as o,f as n,c as s,j as bt,u as z,x as f,k as Mt,y as qt,a as l,v as q,d as S,t as O,w as G,m as At,n as Ht}from"../chunks/index.ca18042b.js";import{T as Pt}from"../chunks/Tip.b8116e3c.js";import{H as yt,E as St}from"../chunks/EditOnGithub.b0b59db6.js";function Ot(w){let r;return{c(){r=At('本节将深入探讨 AI 智能体的内部运作机制——其推理与规划能力。我们将解析智能体如何通过内部对话分析信息，将复杂问题分解为可管理的步骤，并决策下一步行动。同时介绍 ReAct 方法，是一种鼓励模型在行动前"逐步思考"的提示技术。')},l(p){r=Ht(p,'本节将深入探讨 AI 智能体的内部运作机制——其推理与规划能力。我们将解析智能体如何通过内部对话分析信息，将复杂问题分解为可管理的步骤，并决策下一步行动。同时介绍 ReAct 方法，是一种鼓励模型在行动前"逐步思考"的提示技术。')},m(p,u){l(p,r,u)},d(p){p&&n(r)}}}function Gt(w){let r,p,u="它们通过特殊标记（<code>&lt;thought&gt;</code> 和 <code>&lt;/thought&gt;</code>）来界定 <em>思考</em> 部分。这不仅是类似 ReAct 的提示技巧，更是通过分析数千个示范案例，让模型学习生成这些思考段的训练方法。";return{c(){r=At(`近期推理策略受到广泛关注，这体现在 Deepseek R1 或 OpenAI 的 o1 等模型的开发中。这些模型经过微调，被训练为"先思考再回答"。
`),p=a("p"),p.innerHTML=u},l(m){r=Ht(m,`近期推理策略受到广泛关注，这体现在 Deepseek R1 或 OpenAI 的 o1 等模型的开发中。这些模型经过微调，被训练为"先思考再回答"。
`),p=o(m,"P",{"data-svelte-h":!0}),f(p)!=="svelte-53m53f"&&(p.innerHTML=u)},m(m,d){l(m,r,d),l(m,p,d)},p:wt,d(m){m&&(n(r),n(p))}}}function Bt(w){let r,p,u,m,d,B,c,D,h,ot="思维（Thought）代表着智能体<strong>解决任务的内部推理与规划过程</strong>。",U,g,pt="这利用了智能体的大型语言模型 (LLM) 能力<strong>来分析其 prompt 中的信息</strong>。",j,v,ft="可将其视为智能体的内部对话，在此过程中它会考量当前任务并制定应对策略。",F,x,mt="智能体的思维负责获取当前观察结果，并决定下一步应采取的行动。",K,_,ut="通过这一过程，智能体能够<strong>将复杂问题分解为更小、更易管理的步骤</strong>，反思过往经验，并根据新信息持续调整计划。",N,T,dt="以下是常见思维模式的示例：",Q,C,ct="<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>",J,L,$t=`<p><strong>注意：</strong> 对于专为 function-calling 微调的 LLMs，思维过程是可选的。
<em>若您不熟悉 function-calling 概念，后续”行动”章节将提供详细说明。</em></p>`,V,b,W,M,ht="核心方法是 <strong>ReAct 方法</strong>，即”推理”（Reasoning/Think）与”行动”（Acting/Act）的结合。",X,P,gt="ReAct 是一种简单的提示技术，在让 LLM 解码后续 token 前添加”Let’s think step by step”（让我们逐步思考）的提示。",Y,y,vt="通过提示模型”逐步思考”，可以引导解码过程生成<strong>计划</strong>而非直接输出最终解决方案，因为模型被鼓励将问题<strong>分解</strong>为<em>子任务</em>。",Z,A,xt="这种方法使模型能够更详细地考虑各个子步骤，通常比直接生成最终方案产生更少错误。",tt,H,_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>',et,$,nt,lt,it,R,Tt="现在我们已经深入理解了思维过程，接下来将更深入探讨流程的第二部分：行动。",st,k,rt,I,at;return d=new yt({props:{title:"思维机制：内部推理与 ReAct 方法",local:"思维机制内部推理与-react-方法",headingTag:"h1"}}),c=new Pt({props:{$$slots:{default:[Ot]},$$scope:{ctx:w}}}),b=new yt({props:{title:"ReAct 方法",local:"react-方法",headingTag:"h2"}}),$=new Pt({props:{$$slots:{default:[Gt]},$$scope:{ctx:w}}}),k=new St({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit1/thoughts.mdx"}}),{c(){r=a("meta"),p=i(),u=a("p"),m=i(),E(d.$$.fragment),B=i(),E(c.$$.fragment),D=i(),h=a("p"),h.innerHTML=ot,U=i(),g=a("p"),g.innerHTML=pt,j=i(),v=a("p"),v.textContent=ft,F=i(),x=a("p"),x.textContent=mt,K=i(),_=a("p"),_.innerHTML=ut,N=i(),T=a("p"),T.textContent=dt,Q=i(),C=a("table"),C.innerHTML=ct,J=i(),L=a("blockquote"),L.innerHTML=$t,V=i(),E(b.$$.fragment),W=i(),M=a("p"),M.innerHTML=ht,X=i(),P=a("p"),P.textContent=gt,Y=i(),y=a("p"),y.innerHTML=vt,Z=i(),A=a("p"),A.textContent=xt,tt=i(),H=a("figure"),H.innerHTML=_t,et=i(),E($.$$.fragment),nt=i(),lt=a("hr"),it=i(),R=a("p"),R.textContent=Tt,st=i(),E(k.$$.fragment),rt=i(),I=a("p"),this.h()},l(t){const e=zt("svelte-u9bgzb",document.head);r=o(e,"META",{name:!0,content:!0}),e.forEach(n),p=s(t),u=o(t,"P",{}),bt(u).forEach(n),m=s(t),z(d.$$.fragment,t),B=s(t),z(c.$$.fragment,t),D=s(t),h=o(t,"P",{"data-svelte-h":!0}),f(h)!=="svelte-1jwb6my"&&(h.innerHTML=ot),U=s(t),g=o(t,"P",{"data-svelte-h":!0}),f(g)!=="svelte-pm8gty"&&(g.innerHTML=pt),j=s(t),v=o(t,"P",{"data-svelte-h":!0}),f(v)!=="svelte-hq518o"&&(v.textContent=ft),F=s(t),x=o(t,"P",{"data-svelte-h":!0}),f(x)!=="svelte-13gnuxe"&&(x.textContent=mt),K=s(t),_=o(t,"P",{"data-svelte-h":!0}),f(_)!=="svelte-tynx3x"&&(_.innerHTML=ut),N=s(t),T=o(t,"P",{"data-svelte-h":!0}),f(T)!=="svelte-oh940c"&&(T.textContent=dt),Q=s(t),C=o(t,"TABLE",{"data-svelte-h":!0}),f(C)!=="svelte-144b83x"&&(C.innerHTML=ct),J=s(t),L=o(t,"BLOCKQUOTE",{"data-svelte-h":!0}),f(L)!=="svelte-zleg4a"&&(L.innerHTML=$t),V=s(t),z(b.$$.fragment,t),W=s(t),M=o(t,"P",{"data-svelte-h":!0}),f(M)!=="svelte-1u5zk6a"&&(M.innerHTML=ht),X=s(t),P=o(t,"P",{"data-svelte-h":!0}),f(P)!=="svelte-p6eyld"&&(P.textContent=gt),Y=s(t),y=o(t,"P",{"data-svelte-h":!0}),f(y)!=="svelte-1rlfkid"&&(y.innerHTML=vt),Z=s(t),A=o(t,"P",{"data-svelte-h":!0}),f(A)!=="svelte-6wwek0"&&(A.textContent=xt),tt=s(t),H=o(t,"FIGURE",{"data-svelte-h":!0}),f(H)!=="svelte-11oc9ch"&&(H.innerHTML=_t),et=s(t),z($.$$.fragment,t),nt=s(t),lt=o(t,"HR",{}),it=s(t),R=o(t,"P",{"data-svelte-h":!0}),f(R)!=="svelte-no8p97"&&(R.textContent=Tt),st=s(t),z(k.$$.fragment,t),rt=s(t),I=o(t,"P",{}),bt(I).forEach(n),this.h()},h(){Mt(r,"name","hf:doc:metadata"),Mt(r,"content",Dt)},m(t,e){qt(document.head,r),l(t,p,e),l(t,u,e),l(t,m,e),q(d,t,e),l(t,B,e),q(c,t,e),l(t,D,e),l(t,h,e),l(t,U,e),l(t,g,e),l(t,j,e),l(t,v,e),l(t,F,e),l(t,x,e),l(t,K,e),l(t,_,e),l(t,N,e),l(t,T,e),l(t,Q,e),l(t,C,e),l(t,J,e),l(t,L,e),l(t,V,e),q(b,t,e),l(t,W,e),l(t,M,e),l(t,X,e),l(t,P,e),l(t,Y,e),l(t,y,e),l(t,Z,e),l(t,A,e),l(t,tt,e),l(t,H,e),l(t,et,e),q($,t,e),l(t,nt,e),l(t,lt,e),l(t,it,e),l(t,R,e),l(t,st,e),q(k,t,e),l(t,rt,e),l(t,I,e),at=!0},p(t,[e]){const Ct={};e&2&&(Ct.$$scope={dirty:e,ctx:t}),c.$set(Ct);const Lt={};e&2&&(Lt.$$scope={dirty:e,ctx:t}),$.$set(Lt)},i(t){at||(S(d.$$.fragment,t),S(c.$$.fragment,t),S(b.$$.fragment,t),S($.$$.fragment,t),S(k.$$.fragment,t),at=!0)},o(t){O(d.$$.fragment,t),O(c.$$.fragment,t),O(b.$$.fragment,t),O($.$$.fragment,t),O(k.$$.fragment,t),at=!1},d(t){t&&(n(p),n(u),n(m),n(B),n(D),n(h),n(U),n(g),n(j),n(v),n(F),n(x),n(K),n(_),n(N),n(T),n(Q),n(C),n(J),n(L),n(V),n(W),n(M),n(X),n(P),n(Y),n(y),n(Z),n(A),n(tt),n(H),n(et),n(nt),n(lt),n(it),n(R),n(st),n(rt),n(I)),n(r),G(d,t),G(c,t),G(b,t),G($,t),G(k,t)}}}const Dt='{"title":"思维机制：内部推理与 ReAct 方法","local":"思维机制内部推理与-react-方法","sections":[{"title":"ReAct 方法","local":"react-方法","sections":[],"depth":2}],"depth":1}';function Ut(w){return kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qt extends It{constructor(r){super(),Et(this,r,Ut,Bt,Rt,{})}}export{Qt as component};
