import{s as et,n as st,o as nt}from"../chunks/scheduler.37c15a92.js";import{S as at,i as Jt,g as J,s as n,r as o,A as Mt,h as M,f as e,c as a,j as tt,u as p,x as i,k as z,y as it,a as s,v as T,d as y,t as m,w as c}from"../chunks/index.2bf4358c.js";import{C as El}from"../chunks/CodeBlock.4e987730.js";import{H as Wl}from"../chunks/Heading.8ada512a.js";import{E as Ut}from"../chunks/getInferenceSnippets.0aa3753f.js";function ot(Ql){let U,O,H,P,j,D,d,Zl=`还记得我们之前那位得力的管家智能体 Alfred 吗？现在他要迎来重大升级了！
在了解了 LlamaIndex 中的工具后，我们可以赋予 Alfred 新的能力来更好地服务我们。`,K,b,Nl=`不过在继续之前，让我们先回顾一下智能体（如 Alfred）的核心机制。
在第一单元中我们学习到：`,ll,I,Gl="<p>智能体是一个利用 AI 模型与环境交互以实现用户定义目标的系统。它通过结合推理、规划和动作执行（通常通过外部工具）来完成各种任务。</p>",tl,C,Al="LlamaIndex 支持<strong>三种主要类型的推理智能体</strong>：",el,h,kl='<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/llama-index/agents.png" alt="智能体类型"/>',sl,g,Fl="<li><code>函数调用智能体</code> - 适用于支持调用特定函数的 AI 模型</li> <li><code>ReAct 智能体</code> - 适用于具有聊天或文本完成能力的 AI 模型，擅长处理复杂推理任务</li> <li><code>高级自定义智能体</code> - 使用更复杂的方法处理高阶任务和工作流</li>",nl,u,Sl='<p>有关高级智能体的更多信息，请访问 <a href="https://github.com/run-llama/llama_index/blob/main/llama-index-core/llama_index/core/agent/workflow/base_agent.py">BaseWorkflowAgent</a></p>',al,V,Jl,r,_l='<p>您可以通过 <a href="https://huggingface.co/agents-course/notebooks/blob/main/unit2/llama-index/agents.ipynb" target="_blank">这个 Notebook</a> 跟随代码实践（使用 Google Colab 运行）。</p>',Ml,f,vl=`创建智能体时，我们首先需要为其提供<strong>定义其能力的功能/工具集合</strong>。
让我们看看如何使用基础工具创建智能体。当前实现中，智能体会自动使用函数调用 API（如果可用），或标准的 ReAct 智能体循环。`,il,B,Rl="支持工具/函数 API 的 LLM 是相对较新的技术，它们通过避免特定提示工程、允许 LLM 根据提供的模式创建工具调用，提供了强大的工具调用能力。",Ul,x,Xl="ReAct 智能体同样擅长复杂推理任务，可与任何具备聊天或文本完成能力的 LLM 配合使用。这类智能体的响应更详细，会展示其决策背后的推理过程。",ol,E,pl,W,$l=`<strong>智能体默认是无状态的</strong>，如需记忆过往交互，需显式使用 <code>Context</code> 对象。
这在需要记忆历史交互的场景中非常有用，例如：需要跨消息保持上下文的聊天机器人，或需要追踪长期任务进度的任务管理器。`,Tl,Q,yl,Z,ql='您会注意到 <code>LlamaIndex</code> 中的智能体采用异步模式（使用 Python 的 <code>await</code> 操作符）。如果您是 Python 异步编程的新手，或需要复习相关知识，请参考 <a href="https://docs.llamaindex.ai/en/stable/getting_started/async_python/" rel="nofollow">官方异步编程指南</a>。',ml,N,Yl="现在我们已经掌握基础知识，接下来让我们探索如何为智能体赋予更复杂的工具能力。",cl,G,ul,A,Hl=`<strong>智能体增强检索（Agentic RAG）</strong> 是通过智能体实现数据问答的强大范式。我们可以为 Alfred 配备多种工具来辅助问题解答。
但不同于传统 RAG 直接基于文档回答问题，Alfred 能够自主决定是否使用其他工具或流程来响应查询。`,rl,k,Ll='<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/llama-index/agentic-rag.png" alt="智能体增强 RAG"/>',wl,F,zl=`将 <code>QueryEngine</code> 封装为智能体工具非常简单。
在此过程中，我们需要<strong>定义工具名称和描述</strong>，这些元数据将帮助 LLM 正确选择和使用工具。
以下示例演示如何基于<a href="02_components">组件章节</a>创建的 <code>QueryEngine</code> 加载 <code>QueryEngineTool</code>：`,jl,S,dl,_,bl,v,Ol="<code>AgentWorkflow</code> 类原生支持多智能体系统。通过为每个智能体分配名称和描述，系统可维护单一活跃会话主体，同时允许智能体之间进行任务交接。",Il,R,Pl="通过精准定义每个智能体的职责边界，我们能够有效提升系统响应消息时的整体准确性。",Cl,X,Dl="<strong>LlamaIndex 中的智能体也可直接作为其他智能体的工具</strong>，这种设计支持构建复杂的定制化场景：",hl,$,gl,w,Kl='<p>还没学够吗？在<a href="https://docs.llamaindex.ai/en/stable/examples/agent/agent_workflow_basic/">《AgentWorkflow 基本介绍》</a>或<a href="https://docs.llamaindex.ai/en/stable/understanding/agent/">《Agent 学习指南》</a>中，您可以了解到更多关于流媒体、上下文序列化和人在环路中的信息！</p>',Vl,q,lt="现在我们已经掌握了 LlamaIndex 中智能体和工具的基础知识，接下来让我们探索如何利用 LlamaIndex 来<strong>创建可配置、易管理的工作流</strong>！",fl,Y,Bl,L,xl;return j=new Wl({props:{title:"在 LlamaIndex 中使用智能体",local:"在-llamaindex-中使用智能体",headingTag:"h1"}}),V=new Wl({props:{title:"初始化智能体",local:"初始化智能体",headingTag:"h2"}}),E=new El({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmxsbXMuaHVnZ2luZ2ZhY2VfYXBpJTIwaW1wb3J0JTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUEklMEFmcm9tJTIwbGxhbWFfaW5kZXguY29yZS5hZ2VudC53b3JrZmxvdyUyMGltcG9ydCUyMEFnZW50V29ya2Zsb3clMEFmcm9tJTIwbGxhbWFfaW5kZXguY29yZS50b29scyUyMGltcG9ydCUyMEZ1bmN0aW9uVG9vbCUwQSUwQSUyMyUyMCVFNSVBRSU5QSVFNCVCOSU4OSVFNyVBNCVCQSVFNCVCRSU4QiVFNSVCNyVBNSVFNSU4NSVCNy0tJUU3JUIxJUJCJUU1JTlFJThCJUU2JUIzJUE4JUU5JTg3JThBJUUzJTgwJTgxJUU1JTg3JUJEJUU2JTk1JUIwJUU1JTkwJThEJUU1JTkyJThDJTIwZG9jc3RyaW5ncyUyMCVFOSU4MyVCRCVFNSU4QyU4NSVFNSU5MCVBQiVFNSU5QyVBOCVFOCVBNyVBMyVFNiU5RSU5MCVFNyU5QSU4NCVFNiVBOCVBMSVFNSVCQyU4RiVFNCVCOCVBRCVFRiVCQyU4MSUwQWRlZiUyMG11bHRpcGx5KGElM0ElMjBpbnQlMkMlMjBiJTNBJTIwaW50KSUyMC0lM0UlMjBpbnQlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjJNdWx0aXBsaWVzJTIwdHdvJTIwaW50ZWdlcnMlMjBhbmQlMjByZXR1cm5zJTIwdGhlJTIwcmVzdWx0aW5nJTIwaW50ZWdlciUyMiUyMiUyMiUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGElMjAqJTIwYiUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiUyMGxsbSUwQWxsbSUyMCUzRCUyMEh1Z2dpbmdGYWNlSW5mZXJlbmNlQVBJKG1vZGVsX25hbWUlM0QlMjJRd2VuJTJGUXdlbjIuNS1Db2Rlci0zMkItSW5zdHJ1Y3QlMjIpJTBBJTBBJTIzJTIwJUU1JTg4JTlEJUU1JUE3JThCJUU1JThDJTk2JTIwYWdlbnQlMEFhZ2VudCUyMCUzRCUyMEFnZW50V29ya2Zsb3cuZnJvbV90b29sc19vcl9mdW5jdGlvbnMoJTBBJTIwJTIwJTIwJTIwJTVCRnVuY3Rpb25Ub29sLmZyb21fZGVmYXVsdHMobXVsdGlwbHkpJTVEJTJDJTBBJTIwJTIwJTIwJTIwbGxtJTNEbGxtJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> llama_index.llms.huggingface_api <span class="hljs-keyword">import</span> HuggingFaceInferenceAPI
<span class="hljs-keyword">from</span> llama_index.core.agent.workflow <span class="hljs-keyword">import</span> AgentWorkflow
<span class="hljs-keyword">from</span> llama_index.core.tools <span class="hljs-keyword">import</span> FunctionTool

<span class="hljs-comment"># 定义示例工具--类型注释、函数名和 docstrings 都包含在解析的模式中！</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">multiply</span>(<span class="hljs-params">a: <span class="hljs-built_in">int</span>, b: <span class="hljs-built_in">int</span></span>) -&gt; <span class="hljs-built_in">int</span>:
    <span class="hljs-string">&quot;&quot;&quot;Multiplies two integers and returns the resulting integer&quot;&quot;&quot;</span>
    <span class="hljs-keyword">return</span> a * b

<span class="hljs-comment"># 初始化 llm</span>
llm = HuggingFaceInferenceAPI(model_name=<span class="hljs-string">&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</span>)

<span class="hljs-comment"># 初始化 agent</span>
agent = AgentWorkflow.from_tools_or_functions(
    [FunctionTool.from_defaults(multiply)],
    llm=llm
)`,wrap:!1}}),Q=new El({props:{code:"JTIzJTIwc3RhdGVsZXNzJTBBcmVzcG9uc2UlMjAlM0QlMjBhd2FpdCUyMGFnZW50LnJ1biglMjJXaGF0JTIwaXMlMjAyJTIwdGltZXMlMjAyJTNGJTIyKSUwQSUwQSUyMyUyMHJlbWVtYmVyaW5nJTIwc3RhdGUlMEFmcm9tJTIwbGxhbWFfaW5kZXguY29yZS53b3JrZmxvdyUyMGltcG9ydCUyMENvbnRleHQlMEElMEFjdHglMjAlM0QlMjBDb250ZXh0KGFnZW50KSUwQSUwQXJlc3BvbnNlJTIwJTNEJTIwYXdhaXQlMjBhZ2VudC5ydW4oJTIyTXklMjBuYW1lJTIwaXMlMjBCb2IuJTIyJTJDJTIwY3R4JTNEY3R4KSUwQXJlc3BvbnNlJTIwJTNEJTIwYXdhaXQlMjBhZ2VudC5ydW4oJTIyV2hhdCUyMHdhcyUyMG15JTIwbmFtZSUyMGFnYWluJTNGJTIyJTJDJTIwY3R4JTNEY3R4KQ==",highlighted:`<span class="hljs-comment"># stateless</span>
response = <span class="hljs-keyword">await</span> agent.run(<span class="hljs-string">&quot;What is 2 times 2?&quot;</span>)

<span class="hljs-comment"># remembering state</span>
<span class="hljs-keyword">from</span> llama_index.core.workflow <span class="hljs-keyword">import</span> Context

ctx = Context(agent)

response = <span class="hljs-keyword">await</span> agent.run(<span class="hljs-string">&quot;My name is Bob.&quot;</span>, ctx=ctx)
response = <span class="hljs-keyword">await</span> agent.run(<span class="hljs-string">&quot;What was my name again?&quot;</span>, ctx=ctx)`,wrap:!1}}),G=new Wl({props:{title:"使用 QueryEngineTools 创建 RAG 智能体",local:"使用-queryenginetools-创建-rag-智能体",headingTag:"h2"}}),S=new El({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUudG9vbHMlMjBpbXBvcnQlMjBRdWVyeUVuZ2luZVRvb2wlMEElMEFxdWVyeV9lbmdpbmUlMjAlM0QlMjBpbmRleC5hc19xdWVyeV9lbmdpbmUobGxtJTNEbGxtJTJDJTIwc2ltaWxhcml0eV90b3BfayUzRDMpJTIwJTIzJTIwYXMlMjBzaG93biUyMGluJTIwdGhlJTIwcHJldmlvdXMlMjBzZWN0aW9uJTBBJTBBcXVlcnlfZW5naW5lX3Rvb2wlMjAlM0QlMjBRdWVyeUVuZ2luZVRvb2wuZnJvbV9kZWZhdWx0cyglMEElMjAlMjAlMjAlMjBxdWVyeV9lbmdpbmUlM0RxdWVyeV9lbmdpbmUlMkMlMEElMjAlMjAlMjAlMjBuYW1lJTNEJTIybmFtZSUyMiUyQyUwQSUyMCUyMCUyMCUyMGRlc2NyaXB0aW9uJTNEJTIyYSUyMHNwZWNpZmljJTIwZGVzY3JpcHRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGlyZWN0JTNERmFsc2UlMkMlMEEpJTBBcXVlcnlfZW5naW5lX2FnZW50JTIwJTNEJTIwQWdlbnRXb3JrZmxvdy5mcm9tX3Rvb2xzX29yX2Z1bmN0aW9ucyglMEElMjAlMjAlMjAlMjAlNUJxdWVyeV9lbmdpbmVfdG9vbCU1RCUyQyUwQSUyMCUyMCUyMCUyMGxsbSUzRGxsbSUyQyUwQSUyMCUyMCUyMCUyMHN5c3RlbV9wcm9tcHQlM0QlMjJZb3UlMjBhcmUlMjBhJTIwaGVscGZ1bCUyMGFzc2lzdGFudCUyMHRoYXQlMjBoYXMlMjBhY2Nlc3MlMjB0byUyMGElMjBkYXRhYmFzZSUyMGNvbnRhaW5pbmclMjBwZXJzb25hJTIwZGVzY3JpcHRpb25zLiUyMCUyMiUwQSk=",highlighted:`<span class="hljs-keyword">from</span> llama_index.core.tools <span class="hljs-keyword">import</span> QueryEngineTool

query_engine = index.as_query_engine(llm=llm, similarity_top_k=<span class="hljs-number">3</span>) <span class="hljs-comment"># as shown in the previous section</span>

query_engine_tool = QueryEngineTool.from_defaults(
    query_engine=query_engine,
    name=<span class="hljs-string">&quot;name&quot;</span>,
    description=<span class="hljs-string">&quot;a specific description&quot;</span>,
    return_direct=<span class="hljs-literal">False</span>,
)
query_engine_agent = AgentWorkflow.from_tools_or_functions(
    [query_engine_tool],
    llm=llm,
    system_prompt=<span class="hljs-string">&quot;You are a helpful assistant that has access to a database containing persona descriptions. &quot;</span>
)`,wrap:!1}}),_=new Wl({props:{title:"创建多智能体系统",local:"创建多智能体系统",headingTag:"h2"}}),$=new El({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUuYWdlbnQud29ya2Zsb3clMjBpbXBvcnQlMjAoJTBBJTIwJTIwJTIwJTIwQWdlbnRXb3JrZmxvdyUyQyUwQSUyMCUyMCUyMCUyMEZ1bmN0aW9uQWdlbnQlMkMlMEElMjAlMjAlMjAlMjBSZUFjdEFnZW50JTJDJTBBKSUwQSUwQSUyMyUyMERlZmluZSUyMHNvbWUlMjB0b29scyUwQWRlZiUyMGFkZChhJTNBJTIwaW50JTJDJTIwYiUzQSUyMGludCklMjAtJTNFJTIwaW50JTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyQWRkJTIwdHdvJTIwbnVtYmVycy4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjByZXR1cm4lMjBhJTIwJTJCJTIwYiUwQSUwQSUwQWRlZiUyMHN1YnRyYWN0KGElM0ElMjBpbnQlMkMlMjBiJTNBJTIwaW50KSUyMC0lM0UlMjBpbnQlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjJTdWJ0cmFjdCUyMHR3by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weW91JTIwYWRkJTIwNSUyMGFuZCUyMDMlM0YlMjIp",highlighted:`<span class="hljs-keyword">from</span> llama_index.core.agent.workflow <span class="hljs-keyword">import</span> (
    AgentWorkflow,
    FunctionAgent,
    ReActAgent,
)

<span class="hljs-comment"># Define some tools</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">add</span>(<span class="hljs-params">a: <span class="hljs-built_in">int</span>, b: <span class="hljs-built_in">int</span></span>) -&gt; <span class="hljs-built_in">int</span>:
    <span class="hljs-string">&quot;&quot;&quot;Add two numbers.&quot;&quot;&quot;</span>
    <span class="hljs-keyword">return</span> a + b


<span class="hljs-keyword">def</span> <span class="hljs-title function_">subtract</span>(<span class="hljs-params">a: <span class="hljs-built_in">int</span>, b: <span class="hljs-built_in">int</span></span>) -&gt; <span class="hljs-built_in">int</span>:
    <span class="hljs-string">&quot;&quot;&quot;Subtract two numbers.&quot;&quot;&quot;</span>
    <span class="hljs-keyword">return</span> a - b


<span class="hljs-comment"># 创建智能体配置</span>
<span class="hljs-comment"># 注意：我们可以在此使用 FunctionAgent 或 ReActAgent。</span>
<span class="hljs-comment"># FunctionAgent 适用于具有函数调用 API 的 LLM。</span>
<span class="hljs-comment"># ReActAgent 适用于任何 LLM。</span>
calculator_agent = ReActAgent(
    name=<span class="hljs-string">&quot;calculator&quot;</span>,
    description=<span class="hljs-string">&quot;Performs basic arithmetic operations&quot;</span>,
    system_prompt=<span class="hljs-string">&quot;You are a calculator assistant. Use your tools for any math operation.&quot;</span>,
    tools=[add, subtract],
    llm=llm,
)

query_agent = ReActAgent(
    name=<span class="hljs-string">&quot;info_lookup&quot;</span>,
    description=<span class="hljs-string">&quot;Looks up information about XYZ&quot;</span>,
    system_prompt=<span class="hljs-string">&quot;Use your tool to query a RAG system to answer information about XYZ&quot;</span>,
    tools=[query_engine_tool],
    llm=llm
)

<span class="hljs-comment"># 创建并运行工作流程</span>
agent = AgentWorkflow(
    agents=[calculator_agent, query_agent], root_agent=<span class="hljs-string">&quot;calculator&quot;</span>
)

<span class="hljs-comment"># 运行系统</span>
response = <span class="hljs-keyword">await</span> agent.run(user_msg=<span class="hljs-string">&quot;Can you add 5 and 3?&quot;</span>)`,wrap:!1}}),Y=new Ut({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit2/llama-index/agents.mdx"}}),{c(){U=J("meta"),O=n(),H=J("p"),P=n(),o(j.$$.fragment),D=n(),d=J("p"),d.textContent=Zl,K=n(),b=J("p"),b.textContent=Nl,ll=n(),I=J("blockquote"),I.innerHTML=Gl,tl=n(),C=J("p"),C.innerHTML=Al,el=n(),h=J("p"),h.innerHTML=kl,sl=n(),g=J("ol"),g.innerHTML=Fl,nl=n(),u=J("blockquote"),u.innerHTML=Sl,al=n(),o(V.$$.fragment),Jl=n(),r=J("blockquote"),r.innerHTML=_l,Ml=n(),f=J("p"),f.innerHTML=vl,il=n(),B=J("p"),B.textContent=Rl,Ul=n(),x=J("p"),x.textContent=Xl,ol=n(),o(E.$$.fragment),pl=n(),W=J("p"),W.innerHTML=$l,Tl=n(),o(Q.$$.fragment),yl=n(),Z=J("p"),Z.innerHTML=ql,ml=n(),N=J("p"),N.textContent=Yl,cl=n(),o(G.$$.fragment),ul=n(),A=J("p"),A.innerHTML=Hl,rl=n(),k=J("p"),k.innerHTML=Ll,wl=n(),F=J("p"),F.innerHTML=zl,jl=n(),o(S.$$.fragment),dl=n(),o(_.$$.fragment),bl=n(),v=J("p"),v.innerHTML=Ol,Il=n(),R=J("p"),R.textContent=Pl,Cl=n(),X=J("p"),X.innerHTML=Dl,hl=n(),o($.$$.fragment),gl=n(),w=J("blockquote"),w.innerHTML=Kl,Vl=n(),q=J("p"),q.innerHTML=lt,fl=n(),o(Y.$$.fragment),Bl=n(),L=J("p"),this.h()},l(l){const t=Mt("svelte-u9bgzb",document.head);U=M(t,"META",{name:!0,content:!0}),t.forEach(e),O=a(l),H=M(l,"P",{}),tt(H).forEach(e),P=a(l),p(j.$$.fragment,l),D=a(l),d=M(l,"P",{"data-svelte-h":!0}),i(d)!=="svelte-10d7e98"&&(d.textContent=Zl),K=a(l),b=M(l,"P",{"data-svelte-h":!0}),i(b)!=="svelte-hkw26n"&&(b.textContent=Nl),ll=a(l),I=M(l,"BLOCKQUOTE",{"data-svelte-h":!0}),i(I)!=="svelte-1ksbkzo"&&(I.innerHTML=Gl),tl=a(l),C=M(l,"P",{"data-svelte-h":!0}),i(C)!=="svelte-17xgwds"&&(C.innerHTML=Al),el=a(l),h=M(l,"P",{"data-svelte-h":!0}),i(h)!=="svelte-3nptas"&&(h.innerHTML=kl),sl=a(l),g=M(l,"OL",{"data-svelte-h":!0}),i(g)!=="svelte-fuuhge"&&(g.innerHTML=Fl),nl=a(l),u=M(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),i(u)!=="svelte-ilkz"&&(u.innerHTML=Sl),al=a(l),p(V.$$.fragment,l),Jl=a(l),r=M(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),i(r)!=="svelte-12eyqa1"&&(r.innerHTML=_l),Ml=a(l),f=M(l,"P",{"data-svelte-h":!0}),i(f)!=="svelte-z71ivx"&&(f.innerHTML=vl),il=a(l),B=M(l,"P",{"data-svelte-h":!0}),i(B)!=="svelte-x4ueck"&&(B.textContent=Rl),Ul=a(l),x=M(l,"P",{"data-svelte-h":!0}),i(x)!=="svelte-p7mr9a"&&(x.textContent=Xl),ol=a(l),p(E.$$.fragment,l),pl=a(l),W=M(l,"P",{"data-svelte-h":!0}),i(W)!=="svelte-18rw6xl"&&(W.innerHTML=$l),Tl=a(l),p(Q.$$.fragment,l),yl=a(l),Z=M(l,"P",{"data-svelte-h":!0}),i(Z)!=="svelte-66jeeb"&&(Z.innerHTML=ql),ml=a(l),N=M(l,"P",{"data-svelte-h":!0}),i(N)!=="svelte-741za"&&(N.textContent=Yl),cl=a(l),p(G.$$.fragment,l),ul=a(l),A=M(l,"P",{"data-svelte-h":!0}),i(A)!=="svelte-gbmyfe"&&(A.innerHTML=Hl),rl=a(l),k=M(l,"P",{"data-svelte-h":!0}),i(k)!=="svelte-10ho98a"&&(k.innerHTML=Ll),wl=a(l),F=M(l,"P",{"data-svelte-h":!0}),i(F)!=="svelte-uxehys"&&(F.innerHTML=zl),jl=a(l),p(S.$$.fragment,l),dl=a(l),p(_.$$.fragment,l),bl=a(l),v=M(l,"P",{"data-svelte-h":!0}),i(v)!=="svelte-hio4gu"&&(v.innerHTML=Ol),Il=a(l),R=M(l,"P",{"data-svelte-h":!0}),i(R)!=="svelte-bo2cy"&&(R.textContent=Pl),Cl=a(l),X=M(l,"P",{"data-svelte-h":!0}),i(X)!=="svelte-q3vd3v"&&(X.innerHTML=Dl),hl=a(l),p($.$$.fragment,l),gl=a(l),w=M(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),i(w)!=="svelte-9lkdhc"&&(w.innerHTML=Kl),Vl=a(l),q=M(l,"P",{"data-svelte-h":!0}),i(q)!=="svelte-19brcgj"&&(q.innerHTML=lt),fl=a(l),p(Y.$$.fragment,l),Bl=a(l),L=M(l,"P",{}),tt(L).forEach(e),this.h()},h(){z(U,"name","hf:doc:metadata"),z(U,"content",pt),z(u,"class","tip"),z(r,"class","tip"),z(w,"class","tip")},m(l,t){it(document.head,U),s(l,O,t),s(l,H,t),s(l,P,t),T(j,l,t),s(l,D,t),s(l,d,t),s(l,K,t),s(l,b,t),s(l,ll,t),s(l,I,t),s(l,tl,t),s(l,C,t),s(l,el,t),s(l,h,t),s(l,sl,t),s(l,g,t),s(l,nl,t),s(l,u,t),s(l,al,t),T(V,l,t),s(l,Jl,t),s(l,r,t),s(l,Ml,t),s(l,f,t),s(l,il,t),s(l,B,t),s(l,Ul,t),s(l,x,t),s(l,ol,t),T(E,l,t),s(l,pl,t),s(l,W,t),s(l,Tl,t),T(Q,l,t),s(l,yl,t),s(l,Z,t),s(l,ml,t),s(l,N,t),s(l,cl,t),T(G,l,t),s(l,ul,t),s(l,A,t),s(l,rl,t),s(l,k,t),s(l,wl,t),s(l,F,t),s(l,jl,t),T(S,l,t),s(l,dl,t),T(_,l,t),s(l,bl,t),s(l,v,t),s(l,Il,t),s(l,R,t),s(l,Cl,t),s(l,X,t),s(l,hl,t),T($,l,t),s(l,gl,t),s(l,w,t),s(l,Vl,t),s(l,q,t),s(l,fl,t),T(Y,l,t),s(l,Bl,t),s(l,L,t),xl=!0},p:st,i(l){xl||(y(j.$$.fragment,l),y(V.$$.fragment,l),y(E.$$.fragment,l),y(Q.$$.fragment,l),y(G.$$.fragment,l),y(S.$$.fragment,l),y(_.$$.fragment,l),y($.$$.fragment,l),y(Y.$$.fragment,l),xl=!0)},o(l){m(j.$$.fragment,l),m(V.$$.fragment,l),m(E.$$.fragment,l),m(Q.$$.fragment,l),m(G.$$.fragment,l),m(S.$$.fragment,l),m(_.$$.fragment,l),m($.$$.fragment,l),m(Y.$$.fragment,l),xl=!1},d(l){l&&(e(O),e(H),e(P),e(D),e(d),e(K),e(b),e(ll),e(I),e(tl),e(C),e(el),e(h),e(sl),e(g),e(nl),e(u),e(al),e(Jl),e(r),e(Ml),e(f),e(il),e(B),e(Ul),e(x),e(ol),e(pl),e(W),e(Tl),e(yl),e(Z),e(ml),e(N),e(cl),e(ul),e(A),e(rl),e(k),e(wl),e(F),e(jl),e(dl),e(bl),e(v),e(Il),e(R),e(Cl),e(X),e(hl),e(gl),e(w),e(Vl),e(q),e(fl),e(Bl),e(L)),e(U),c(j,l),c(V,l),c(E,l),c(Q,l),c(G,l),c(S,l),c(_,l),c($,l),c(Y,l)}}}const pt='{"title":"在 LlamaIndex 中使用智能体","local":"在-llamaindex-中使用智能体","sections":[{"title":"初始化智能体","local":"初始化智能体","sections":[],"depth":2},{"title":"使用 QueryEngineTools 创建 RAG 智能体","local":"使用-queryenginetools-创建-rag-智能体","sections":[],"depth":2},{"title":"创建多智能体系统","local":"创建多智能体系统","sections":[],"depth":2}],"depth":1}';function Tt(Ql){return nt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class wt extends at{constructor(U){super(),Jt(this,U,Tt,ot,et,{})}}export{wt as component};
