import{s as oe,o as ie,n as At}from"../chunks/scheduler.889ebb13.js";import{S as re,i as pe,g as r,s,r as w,A as ce,h as p,f as n,c as a,j as ae,u as h,x as m,k as tt,y as me,a as l,v as g,d as J,t as b,w as T,m as et,n as nt}from"../chunks/index.ca18042b.js";import{T as Qt}from"../chunks/Tip.b8116e3c.js";import{C as _t}from"../chunks/CodeBlock.1db71023.js";import{H as kt}from"../chunks/Heading.3daa581c.js";import{E as ue}from"../chunks/EditOnGithub.2e95618d.js";function Me(j){let c,o,y="BaseWorkflowAgent";return{c(){c=et("Find more information on advanced agents on "),o=r("a"),o.textContent=y,this.h()},l(u){c=nt(u,"Find more information on advanced agents on "),o=p(u,"A",{href:!0,"data-svelte-h":!0}),m(o)!=="svelte-1l6wzqu"&&(o.textContent=y),this.h()},h(){tt(o,"href","https://github.com/run-llama/llama_index/blob/main/llama-index-core/llama_index/core/agent/workflow/base_agent.py")},m(u,i){l(u,c,i),l(u,o,i)},p:At,d(u){u&&(n(c),n(o))}}}function ye(j){let c,o,y="this notebook",u;return{c(){c=et("You can follow the code in "),o=r("a"),o.textContent=y,u=et(" that you can run using Google Colab."),this.h()},l(i){c=nt(i,"You can follow the code in "),o=p(i,"A",{href:!0,target:!0,"data-svelte-h":!0}),m(o)!=="svelte-1yc57o8"&&(o.textContent=y),u=nt(i," that you can run using Google Colab."),this.h()},h(){tt(o,"href","https://huggingface.co/agents-course/notebooks/blob/main/unit2/llama-index/agents.ipynb"),tt(o,"target","_blank")},m(i,f){l(i,c,f),l(i,o,f),l(i,u,f)},p:At,d(i){i&&(n(c),n(o),n(u))}}}function de(j){let c,o,y="AgentWorkflow Basic Introduction",u,i,f="Agent Learning Guide",d;return{c(){c=et("Haven't learned enough yet? There is a lot more to discover about agents and tools in LlamaIndex within the "),o=r("a"),o.textContent=y,u=et(" or the "),i=r("a"),i.textContent=f,d=et(", where you can read more about streaming, context serialization, and human-in-the-loop!"),this.h()},l(M){c=nt(M,"Haven't learned enough yet? There is a lot more to discover about agents and tools in LlamaIndex within the "),o=p(M,"A",{href:!0,"data-svelte-h":!0}),m(o)!=="svelte-ogskyl"&&(o.textContent=y),u=nt(M," or the "),i=p(M,"A",{href:!0,"data-svelte-h":!0}),m(i)!=="svelte-tyusc2"&&(i.textContent=f),d=nt(M,", where you can read more about streaming, context serialization, and human-in-the-loop!"),this.h()},h(){tt(o,"href","https://docs.llamaindex.ai/en/stable/examples/agent/agent_workflow_basic/"),tt(i,"href","https://docs.llamaindex.ai/en/stable/understanding/agent/")},m(M,U){l(M,c,U),l(M,o,U),l(M,u,U),l(M,i,U),l(M,d,U)},p:At,d(M){M&&(n(c),n(o),n(u),n(i),n(d))}}}function we(j){let c,o,y,u,i,f,d,M=`Remember Alfred, our helpful butler agent from earlier? Well, he’s about to get an upgrade!
Now that we understand the tools available in LlamaIndex, we can give Alfred new capabilities to serve us better.`,U,C,Vt=`But before we continue, let’s remind ourselves what makes an agent like Alfred tick.
Back in Unit 1, we learned that:`,st,v,Rt="<p>An Agent is a system that leverages an AI model to interact with its environment to achieve a user-defined objective. It combines reasoning, planning, and action execution (often via external tools) to fulfil tasks.</p>",at,G,Et="LlamaIndex supports <strong>three main types of reasoning agents:</strong>",ot,W,St='<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/llama-index/agents.png" alt="Agents"/>',it,Z,Yt="<li><code>Function Calling Agents</code> - These work with AI models that can call specific functions.</li> <li><code>ReAct Agents</code> - These can work with any AI that does chat or text endpoint and deal with complex reasoning tasks.</li> <li><code>Advanced Custom Agents</code> - These use more complex methods to deal with more complex tasks and workflows.</li>",rt,I,pt,$,ct,B,mt,_,Xt=`To create an agent, we start by providing it with a <strong>set of functions/tools that define its capabilities</strong>.
Let’s look at how to create an agent with some basic tools. As of this writing, the agent will automatically use the function calling API (if available), or a standard ReAct agent loop.`,ut,k,Ht="LLMs that support a tools/functions API are relatively new, but they provide a powerful way to call tools by avoiding specific prompting and allowing the LLM to create tool calls based on provided schemas.",Mt,Q,Nt="ReAct agents are also good at complex reasoning tasks and can work with any LLM that has chat or text completion capabilities. They are more verbose, and show the reasoning behind certain actions that they take.",yt,A,dt,V,qt=`<strong>Agents are stateless by default</strong>, add remembering past interactions is opt-in using a <code>Context</code> object
This might be useful if you want to use an agent that needs to remember previous interactions, like a chatbot that maintains context across multiple messages or a task manager that needs to track progress over time.`,wt,R,ht,E,Ft='You’ll notice that agents in <code>LlamaIndex</code> are async because they use Python’s <code>await</code> operator. If you are new to async code in Python, or need a refresher, they have an <a href="https://docs.llamaindex.ai/en/stable/getting_started/async_python/" rel="nofollow">excellent async guide</a>.',gt,S,Lt="Now we’ve gotten the basics, let’s take a look at how we can use more complex tools in our agents.",Jt,Y,bt,X,zt=`<strong>Agentic RAG is a powerful way to use agents to answer questions about your data.</strong> We can pass various tools to Alfred to help him answer questions.
However, instead of answering the question on top of documents automatically, Alfred can decide to use any other tool or flow to answer the question.`,Tt,H,Pt='<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/llama-index/agentic-rag.png" alt="Agentic RAG"/>',ft,N,Dt=`It is easy to <strong>wrap <code>QueryEngine</code> as a tool</strong> for an agent.
When doing so, we need to <strong>define a name and description</strong>. The LLM will use this information to correctly use the tool.
Let’s see how to load in a <code>QueryEngineTool</code> using the <code>QueryEngine</code> we created in the <a href="02_components">component section</a>.`,Ut,q,jt,F,It,L,Kt="The <code>AgentWorkflow</code> class also directly supports multi-agent systems. By giving each agent a name and description, the system maintains a single active speaker, with each agent having the ability to hand off to another agent.",Bt,z,Ot="By narrowing the scope of each agent, we can help increase their general accuracy when responding to user messages.",xt,P,te="<strong>Agents in LlamaIndex can also directly be used as tools</strong> for other agents, for more complex and custom scenarios.",Ct,D,vt,x,Gt,K,ee="Now that we understand the basics of agents and tools in LlamaIndex, let’s see how we can use LlamaIndex to <strong>create configurable and manageable workflows!</strong>",Wt,O,Zt,lt,$t;return i=new kt({props:{title:"Using Agents in LlamaIndex",local:"using-agents-in-llamaindex",headingTag:"h1"}}),I=new Qt({props:{$$slots:{default:[Me]},$$scope:{ctx:j}}}),$=new kt({props:{title:"Initialising Agents",local:"initialising-agents",headingTag:"h2"}}),B=new Qt({props:{$$slots:{default:[ye]},$$scope:{ctx:j}}}),A=new _t({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmxsbXMuaHVnZ2luZ2ZhY2VfYXBpJTIwaW1wb3J0JTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUEklMEFmcm9tJTIwbGxhbWFfaW5kZXguY29yZS5hZ2VudC53b3JrZmxvdyUyMGltcG9ydCUyMEFnZW50V29ya2Zsb3clMEFmcm9tJTIwbGxhbWFfaW5kZXguY29yZS50b29scyUyMGltcG9ydCUyMEZ1bmN0aW9uVG9vbCUwQSUwQSUyMyUyMGRlZmluZSUyMHNhbXBsZSUyMFRvb2wlMjAtLSUyMHR5cGUlMjBhbm5vdGF0aW9ucyUyQyUyMGZ1bmN0aW9uJTIwbmFtZXMlMkMlMjBhbmQlMjBkb2NzdHJpbmdzJTJDJTIwYXJlJTIwYWxsJTIwaW5jbHVkZWQlMjBpbiUyMHBhcnNlZCUyMHNjaGVtYXMhJTBBZGVmJTIwbXVsdGlwbHkoYSUzQSUyMGludCUyQyUyMGIlM0ElMjBpbnQpJTIwLSUzRSUyMGludCUzQSUwQSUyMCUyMCUyMCUyMCUyMiUyMiUyMk11bHRpcGxpZXMlMjB0d28lMjBpbnRlZ2VycyUyMGFuZCUyMHJldHVybnMlMjB0aGUlMjByZXN1bHRpbmclMjBpbnRlZ2VyJTIyJTIyJTIyJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwYSUyMColMjBiJTBBJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMGxsbSUwQWxsbSUyMCUzRCUyMEh1Z2dpbmdGYWNlSW5mZXJlbmNlQVBJKG1vZGVsX25hbWUlM0QlMjJRd2VuJTJGUXdlbjIuNS1Db2Rlci0zMkItSW5zdHJ1Y3QlMjIpJTBBJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMGFnZW50JTBBYWdlbnQlMjAlM0QlMjBBZ2VudFdvcmtmbG93LmZyb21fdG9vbHNfb3JfZnVuY3Rpb25zKCUwQSUyMCUyMCUyMCUyMCU1QkZ1bmN0aW9uVG9vbC5mcm9tX2RlZmF1bHRzKG11bHRpcGx5KSU1RCUyQyUwQSUyMCUyMCUyMCUyMGxsbSUzRGxsbSUwQSk=",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"># define sample Tool -- type annotations, function names, and docstrings, are all included in parsed schemas!</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"># initialize llm</span>
llm = HuggingFaceInferenceAPI(model_name=<span class="hljs-string">&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</span>)

<span class="hljs-comment"># initialize agent</span>
agent = AgentWorkflow.from_tools_or_functions(
    [FunctionTool.from_defaults(multiply)],
    llm=llm
)`,wrap:!1}}),R=new _t({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}}),Y=new kt({props:{title:"Creating RAG Agents with QueryEngineTools",local:"creating-rag-agents-with-queryenginetools",headingTag:"h2"}}),q=new _t({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}}),F=new kt({props:{title:"Creating Multi-agent systems",local:"creating-multi-agent-systems",headingTag:"h2"}}),D=new _t({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUuYWdl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FnZW50JTNEJTIyY2FsY3VsYXRvciUyMiUwQSklMEElMEElMjMlMjBSdW4lMjB0aGUlMjBzeXN0ZW0lMEFyZXNwb25zZSUyMCUzRCUyMGF3YWl0JTIwYWdlbnQucnVuKHVzZXJfbXNnJTNEJTIyQ2FuJTIweW91JTIwYWRkJTIwNSUyMGFuZCUyMDMlM0YlMjIp",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"># Create agent configs</span>
<span class="hljs-comment"># <span class="hljs-doctag">NOTE:</span> we can use FunctionAgent or ReActAgent here.</span>
<span class="hljs-comment"># FunctionAgent works for LLMs with a function calling API.</span>
<span class="hljs-comment"># ReActAgent works for any 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"># Create and run the workflow</span>
agent = AgentWorkflow(
    agents=[calculator_agent, query_agent], root_agent=<span class="hljs-string">&quot;calculator&quot;</span>
)

<span class="hljs-comment"># Run the system</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}}),x=new Qt({props:{$$slots:{default:[de]},$$scope:{ctx:j}}}),O=new ue({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/en/unit2/llama-index/agents.mdx"}}),{c(){c=r("meta"),o=s(),y=r("p"),u=s(),w(i.$$.fragment),f=s(),d=r("p"),d.textContent=M,U=s(),C=r("p"),C.textContent=Vt,st=s(),v=r("blockquote"),v.innerHTML=Rt,at=s(),G=r("p"),G.innerHTML=Et,ot=s(),W=r("p"),W.innerHTML=St,it=s(),Z=r("ol"),Z.innerHTML=Yt,rt=s(),w(I.$$.fragment),pt=s(),w($.$$.fragment),ct=s(),w(B.$$.fragment),mt=s(),_=r("p"),_.innerHTML=Xt,ut=s(),k=r("p"),k.textContent=Ht,Mt=s(),Q=r("p"),Q.textContent=Nt,yt=s(),w(A.$$.fragment),dt=s(),V=r("p"),V.innerHTML=qt,wt=s(),w(R.$$.fragment),ht=s(),E=r("p"),E.innerHTML=Ft,gt=s(),S=r("p"),S.textContent=Lt,Jt=s(),w(Y.$$.fragment),bt=s(),X=r("p"),X.innerHTML=zt,Tt=s(),H=r("p"),H.innerHTML=Pt,ft=s(),N=r("p"),N.innerHTML=Dt,Ut=s(),w(q.$$.fragment),jt=s(),w(F.$$.fragment),It=s(),L=r("p"),L.innerHTML=Kt,Bt=s(),z=r("p"),z.textContent=Ot,xt=s(),P=r("p"),P.innerHTML=te,Ct=s(),w(D.$$.fragment),vt=s(),w(x.$$.fragment),Gt=s(),K=r("p"),K.innerHTML=ee,Wt=s(),w(O.$$.fragment),Zt=s(),lt=r("p"),this.h()},l(t){const e=ce("svelte-u9bgzb",document.head);c=p(e,"META",{name:!0,content:!0}),e.forEach(n),o=a(t),y=p(t,"P",{}),ae(y).forEach(n),u=a(t),h(i.$$.fragment,t),f=a(t),d=p(t,"P",{"data-svelte-h":!0}),m(d)!=="svelte-k20nvn"&&(d.textContent=M),U=a(t),C=p(t,"P",{"data-svelte-h":!0}),m(C)!=="svelte-1hjwxub"&&(C.textContent=Vt),st=a(t),v=p(t,"BLOCKQUOTE",{"data-svelte-h":!0}),m(v)!=="svelte-15o6tbi"&&(v.innerHTML=Rt),at=a(t),G=p(t,"P",{"data-svelte-h":!0}),m(G)!=="svelte-1i02awx"&&(G.innerHTML=Et),ot=a(t),W=p(t,"P",{"data-svelte-h":!0}),m(W)!=="svelte-14dee9q"&&(W.innerHTML=St),it=a(t),Z=p(t,"OL",{"data-svelte-h":!0}),m(Z)!=="svelte-1bz4j87"&&(Z.innerHTML=Yt),rt=a(t),h(I.$$.fragment,t),pt=a(t),h($.$$.fragment,t),ct=a(t),h(B.$$.fragment,t),mt=a(t),_=p(t,"P",{"data-svelte-h":!0}),m(_)!=="svelte-1k9r5ws"&&(_.innerHTML=Xt),ut=a(t),k=p(t,"P",{"data-svelte-h":!0}),m(k)!=="svelte-gafhou"&&(k.textContent=Ht),Mt=a(t),Q=p(t,"P",{"data-svelte-h":!0}),m(Q)!=="svelte-dm7947"&&(Q.textContent=Nt),yt=a(t),h(A.$$.fragment,t),dt=a(t),V=p(t,"P",{"data-svelte-h":!0}),m(V)!=="svelte-1j4mjjh"&&(V.innerHTML=qt),wt=a(t),h(R.$$.fragment,t),ht=a(t),E=p(t,"P",{"data-svelte-h":!0}),m(E)!=="svelte-18kp6fu"&&(E.innerHTML=Ft),gt=a(t),S=p(t,"P",{"data-svelte-h":!0}),m(S)!=="svelte-epz1ho"&&(S.textContent=Lt),Jt=a(t),h(Y.$$.fragment,t),bt=a(t),X=p(t,"P",{"data-svelte-h":!0}),m(X)!=="svelte-cdj536"&&(X.innerHTML=zt),Tt=a(t),H=p(t,"P",{"data-svelte-h":!0}),m(H)!=="svelte-1srircl"&&(H.innerHTML=Pt),ft=a(t),N=p(t,"P",{"data-svelte-h":!0}),m(N)!=="svelte-1tgvryu"&&(N.innerHTML=Dt),Ut=a(t),h(q.$$.fragment,t),jt=a(t),h(F.$$.fragment,t),It=a(t),L=p(t,"P",{"data-svelte-h":!0}),m(L)!=="svelte-pnrrlw"&&(L.innerHTML=Kt),Bt=a(t),z=p(t,"P",{"data-svelte-h":!0}),m(z)!=="svelte-1lnlpu9"&&(z.textContent=Ot),xt=a(t),P=p(t,"P",{"data-svelte-h":!0}),m(P)!=="svelte-19na4nh"&&(P.innerHTML=te),Ct=a(t),h(D.$$.fragment,t),vt=a(t),h(x.$$.fragment,t),Gt=a(t),K=p(t,"P",{"data-svelte-h":!0}),m(K)!=="svelte-1synfbm"&&(K.innerHTML=ee),Wt=a(t),h(O.$$.fragment,t),Zt=a(t),lt=p(t,"P",{}),ae(lt).forEach(n),this.h()},h(){tt(c,"name","hf:doc:metadata"),tt(c,"content",he)},m(t,e){me(document.head,c),l(t,o,e),l(t,y,e),l(t,u,e),g(i,t,e),l(t,f,e),l(t,d,e),l(t,U,e),l(t,C,e),l(t,st,e),l(t,v,e),l(t,at,e),l(t,G,e),l(t,ot,e),l(t,W,e),l(t,it,e),l(t,Z,e),l(t,rt,e),g(I,t,e),l(t,pt,e),g($,t,e),l(t,ct,e),g(B,t,e),l(t,mt,e),l(t,_,e),l(t,ut,e),l(t,k,e),l(t,Mt,e),l(t,Q,e),l(t,yt,e),g(A,t,e),l(t,dt,e),l(t,V,e),l(t,wt,e),g(R,t,e),l(t,ht,e),l(t,E,e),l(t,gt,e),l(t,S,e),l(t,Jt,e),g(Y,t,e),l(t,bt,e),l(t,X,e),l(t,Tt,e),l(t,H,e),l(t,ft,e),l(t,N,e),l(t,Ut,e),g(q,t,e),l(t,jt,e),g(F,t,e),l(t,It,e),l(t,L,e),l(t,Bt,e),l(t,z,e),l(t,xt,e),l(t,P,e),l(t,Ct,e),g(D,t,e),l(t,vt,e),g(x,t,e),l(t,Gt,e),l(t,K,e),l(t,Wt,e),g(O,t,e),l(t,Zt,e),l(t,lt,e),$t=!0},p(t,[e]){const ne={};e&2&&(ne.$$scope={dirty:e,ctx:t}),I.$set(ne);const le={};e&2&&(le.$$scope={dirty:e,ctx:t}),B.$set(le);const se={};e&2&&(se.$$scope={dirty:e,ctx:t}),x.$set(se)},i(t){$t||(J(i.$$.fragment,t),J(I.$$.fragment,t),J($.$$.fragment,t),J(B.$$.fragment,t),J(A.$$.fragment,t),J(R.$$.fragment,t),J(Y.$$.fragment,t),J(q.$$.fragment,t),J(F.$$.fragment,t),J(D.$$.fragment,t),J(x.$$.fragment,t),J(O.$$.fragment,t),$t=!0)},o(t){b(i.$$.fragment,t),b(I.$$.fragment,t),b($.$$.fragment,t),b(B.$$.fragment,t),b(A.$$.fragment,t),b(R.$$.fragment,t),b(Y.$$.fragment,t),b(q.$$.fragment,t),b(F.$$.fragment,t),b(D.$$.fragment,t),b(x.$$.fragment,t),b(O.$$.fragment,t),$t=!1},d(t){t&&(n(o),n(y),n(u),n(f),n(d),n(U),n(C),n(st),n(v),n(at),n(G),n(ot),n(W),n(it),n(Z),n(rt),n(pt),n(ct),n(mt),n(_),n(ut),n(k),n(Mt),n(Q),n(yt),n(dt),n(V),n(wt),n(ht),n(E),n(gt),n(S),n(Jt),n(bt),n(X),n(Tt),n(H),n(ft),n(N),n(Ut),n(jt),n(It),n(L),n(Bt),n(z),n(xt),n(P),n(Ct),n(vt),n(Gt),n(K),n(Wt),n(Zt),n(lt)),n(c),T(i,t),T(I,t),T($,t),T(B,t),T(A,t),T(R,t),T(Y,t),T(q,t),T(F,t),T(D,t),T(x,t),T(O,t)}}}const he='{"title":"Using Agents in LlamaIndex","local":"using-agents-in-llamaindex","sections":[{"title":"Initialising Agents","local":"initialising-agents","sections":[],"depth":2},{"title":"Creating RAG Agents with QueryEngineTools","local":"creating-rag-agents-with-queryenginetools","sections":[],"depth":2},{"title":"Creating Multi-agent systems","local":"creating-multi-agent-systems","sections":[],"depth":2}],"depth":1}';function ge(j){return ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ie extends re{constructor(c){super(),pe(this,c,ge,we,oe,{})}}export{Ie as component};
