import{s as et,n as nt,o as at}from"../chunks/scheduler.f6319a2a.js";import{S as lt,i as st,g as i,s as l,r as V,A as it,h as o,f as n,c as s,j as Y,u as F,x as c,k as O,y as ot,a,v as W,d as X,t as Z,w as tt}from"../chunks/index.85aa684c.js";import{H as mt,E as ct}from"../chunks/getInferenceSnippets.0233181f.js";function gt(S){let m,b,L,T,r,A,f,U='ReAct 框架（<a href="https://huggingface.co/papers/2210.03629" rel="nofollow">Yao et al., 2022</a>）是目前构建 agent 的主要方法。',M,p,B="该名称基于两个词的组合：“Reason” （推理）和 “Act” （行动）。实际上，遵循此架构的 agent 将根据需要尽可能多的步骤来解决其任务，每个步骤包括一个推理步骤，然后是一个行动步骤，在该步骤中，它制定工具调用，使其更接近解决手头的任务。",H,h,D="ReAct 过程涉及保留过去步骤的记忆。",P,g,G='<p>阅读 <a href="https://huggingface.co/blog/open-source-llms-as-agents" rel="nofollow">Open-source LLMs as LangChain Agents</a> 博客文章以了解更多关于多步 agent 的信息。</p>',w,d,I="以下是其工作原理的视频概述：",k,u,J='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/Agent_ManimCE.gif"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/Agent_ManimCE.gif"/>',E,v,K='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/open-source-llms-as-agents/ReAct.png" alt="ReAct agent 的框架"/>',y,C,N="我们实现了两个版本的 ToolCallingAgent：",R,_,Q='<li><a href="/docs/smolagents/main/zh/reference/agents#smolagents.ToolCallingAgent">ToolCallingAgent</a> 在其输出中生成 JSON 格式的工具调用。</li> <li><a href="/docs/smolagents/main/zh/reference/agents#smolagents.CodeAgent">CodeAgent</a> 是一种新型的 ToolCallingAgent，它生成代码块形式的工具调用，这对于具有强大编码性能的 LLM 非常有效。</li>',j,x,q,$,z;return r=new mt({props:{title:"多步骤 agent 是如何工作的？",local:"多步骤-agent-是如何工作的",headingTag:"h1"}}),x=new ct({props:{source:"https://github.com/huggingface/smolagents/blob/main/docs/source/zh/conceptual_guides/react.md"}}),{c(){m=i("meta"),b=l(),L=i("p"),T=l(),V(r.$$.fragment),A=l(),f=i("p"),f.innerHTML=U,M=l(),p=i("p"),p.textContent=B,H=l(),h=i("p"),h.textContent=D,P=l(),g=i("blockquote"),g.innerHTML=G,w=l(),d=i("p"),d.textContent=I,k=l(),u=i("div"),u.innerHTML=J,E=l(),v=i("p"),v.innerHTML=K,y=l(),C=i("p"),C.textContent=N,R=l(),_=i("ul"),_.innerHTML=Q,j=l(),V(x.$$.fragment),q=l(),$=i("p"),this.h()},l(t){const e=it("svelte-u9bgzb",document.head);m=o(e,"META",{name:!0,content:!0}),e.forEach(n),b=s(t),L=o(t,"P",{}),Y(L).forEach(n),T=s(t),F(r.$$.fragment,t),A=s(t),f=o(t,"P",{"data-svelte-h":!0}),c(f)!=="svelte-gm4bn2"&&(f.innerHTML=U),M=s(t),p=o(t,"P",{"data-svelte-h":!0}),c(p)!=="svelte-ktrkfc"&&(p.textContent=B),H=s(t),h=o(t,"P",{"data-svelte-h":!0}),c(h)!=="svelte-lhy2wj"&&(h.textContent=D),P=s(t),g=o(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),c(g)!=="svelte-1syzs5b"&&(g.innerHTML=G),w=s(t),d=o(t,"P",{"data-svelte-h":!0}),c(d)!=="svelte-1ghba8i"&&(d.textContent=I),k=s(t),u=o(t,"DIV",{class:!0,"data-svelte-h":!0}),c(u)!=="svelte-4ra9xq"&&(u.innerHTML=J),E=s(t),v=o(t,"P",{"data-svelte-h":!0}),c(v)!=="svelte-1qm66iv"&&(v.innerHTML=K),y=s(t),C=o(t,"P",{"data-svelte-h":!0}),c(C)!=="svelte-1j4ubj4"&&(C.textContent=N),R=s(t),_=o(t,"UL",{"data-svelte-h":!0}),c(_)!=="svelte-icav5y"&&(_.innerHTML=Q),j=s(t),F(x.$$.fragment,t),q=s(t),$=o(t,"P",{}),Y($).forEach(n),this.h()},h(){O(m,"name","hf:doc:metadata"),O(m,"content",ut),O(g,"class","tip"),O(u,"class","flex justify-center")},m(t,e){ot(document.head,m),a(t,b,e),a(t,L,e),a(t,T,e),W(r,t,e),a(t,A,e),a(t,f,e),a(t,M,e),a(t,p,e),a(t,H,e),a(t,h,e),a(t,P,e),a(t,g,e),a(t,w,e),a(t,d,e),a(t,k,e),a(t,u,e),a(t,E,e),a(t,v,e),a(t,y,e),a(t,C,e),a(t,R,e),a(t,_,e),a(t,j,e),W(x,t,e),a(t,q,e),a(t,$,e),z=!0},p:nt,i(t){z||(X(r.$$.fragment,t),X(x.$$.fragment,t),z=!0)},o(t){Z(r.$$.fragment,t),Z(x.$$.fragment,t),z=!1},d(t){t&&(n(b),n(L),n(T),n(A),n(f),n(M),n(p),n(H),n(h),n(P),n(g),n(w),n(d),n(k),n(u),n(E),n(v),n(y),n(C),n(R),n(_),n(j),n(q),n($)),n(m),tt(r,t),tt(x,t)}}}const ut='{"title":"多步骤 agent 是如何工作的？","local":"多步骤-agent-是如何工作的","sections":[],"depth":1}';function rt(S){return at(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class dt extends lt{constructor(m){super(),st(this,m,rt,gt,et,{})}}export{dt as component};
