import{s as kn,o as Bn,n as Re}from"../chunks/scheduler.889ebb13.js";import{S as Vn,i as En,g as o,s as a,r as f,m as x,A as Xn,h as r,f as n,c as s,j as Yt,u as y,x as u,n as J,k as j,y as _,a as l,v as w,d as b,t as g,w as M}from"../chunks/index.ca18042b.js";import{T as Ae}from"../chunks/Tip.b8116e3c.js";import{C as W}from"../chunks/CodeBlock.1db71023.js";import{H as Ge}from"../chunks/Heading.3daa581c.js";import{E as An}from"../chunks/EditOnGithub.2e95618d.js";function Rn(U){let c,m,T="this notebook",p;return{c(){c=x("You can follow the code in "),m=o("a"),m.textContent=T,p=x(" that you can run using Google Colab."),this.h()},l(i){c=J(i,"You can follow the code in "),m=r(i,"A",{href:!0,target:!0,"data-svelte-h":!0}),u(m)!=="svelte-8yz016"&&(m.textContent=T),p=J(i," that you can run using Google Colab."),this.h()},h(){j(m,"href","https://huggingface.co/agents-course/notebooks/blob/main/unit2/llama-index/components.ipynb"),j(m,"target","_blank")},m(i,v){l(i,c,v),l(i,m,v),l(i,p,v)},p:Re,d(i){i&&(n(c),n(m),n(p))}}}function Hn(U){let c,m,T="LlamaHub",p,i,v="LlamaParse",h;return{c(){c=x("Get familiar with "),m=o("a"),m.textContent=T,p=x(" loaders and "),i=o("a"),i.textContent=v,h=x(" parser for more complex data sources."),this.h()},l(d){c=J(d,"Get familiar with "),m=r(d,"A",{href:!0,"data-svelte-h":!0}),u(m)!=="svelte-533qfu"&&(m.textContent=T),p=J(d," loaders and "),i=r(d,"A",{href:!0,"data-svelte-h":!0}),u(i)!=="svelte-a3asoh"&&(i.textContent=v),h=J(d," parser for more complex data sources."),this.h()},h(){j(m,"href","https://docs.llamaindex.ai/en/stable/module_guides/loading/connector/"),j(i,"href","https://github.com/run-llama/llama_cloud_services/blob/main/parse.md")},m(d,$){l(d,c,$),l(d,m,$),l(d,p,$),l(d,i,$),l(d,h,$)},p:Re,d(d){d&&(n(c),n(m),n(p),n(i),n(h))}}}function Yn(U){let c,m,T="LlamaIndex documentation",p;return{c(){c=x("An overview of the different vector stores can be found in the "),m=o("a"),m.textContent=T,p=x("."),this.h()},l(i){c=J(i,"An overview of the different vector stores can be found in the "),m=r(i,"A",{href:!0,"data-svelte-h":!0}),u(m)!=="svelte-1e65i8i"&&(m.textContent=T),p=J(i,"."),this.h()},h(){j(m,"href","https://docs.llamaindex.ai/en/stable/module_guides/storing/vector_stores/")},m(i,v){l(i,c,v),l(i,m,v),l(i,p,v)},p:Re,d(i){i&&(n(c),n(m),n(p))}}}function Sn(U){let c,m,T="low-level composition API",p,i,v="Workflows";return{c(){c=x("Take fine-grained control of your query workflows with the "),m=o("a"),m.textContent=T,p=x(". This API lets you customize and fine-tune every step of the query process to match your exact needs, which also pairs great with "),i=o("a"),i.textContent=v,this.h()},l(h){c=J(h,"Take fine-grained control of your query workflows with the "),m=r(h,"A",{href:!0,"data-svelte-h":!0}),u(m)!=="svelte-arbcj7"&&(m.textContent=T),p=J(h,". This API lets you customize and fine-tune every step of the query process to match your exact needs, which also pairs great with "),i=r(h,"A",{href:!0,"data-svelte-h":!0}),u(i)!=="svelte-h6xwqz"&&(i.textContent=v),this.h()},h(){j(m,"href","https://docs.llamaindex.ai/en/stable/module_guides/deploying/query_engine/usage_pattern/#low-level-composition-api"),j(i,"href","https://docs.llamaindex.ai/en/stable/module_guides/workflow/")},m(h,d){l(h,c,d),l(h,m,d),l(h,p,d),l(h,i,d)},p:Re,d(h){h&&(n(c),n(m),n(p),n(i))}}}function Nn(U){let c,m,T="Components Guides",p,i,v="Guide on RAG",h;return{c(){c=x("Want to learn more about components and how to use them? Continue your journey with the "),m=o("a"),m.textContent=T,p=x(" or the "),i=o("a"),i.textContent=v,h=x("."),this.h()},l(d){c=J(d,"Want to learn more about components and how to use them? Continue your journey with the "),m=r(d,"A",{href:!0,"data-svelte-h":!0}),u(m)!=="svelte-1br2a7q"&&(m.textContent=T),p=J(d," or the "),i=r(d,"A",{href:!0,"data-svelte-h":!0}),u(i)!=="svelte-jojkhh"&&(i.textContent=v),h=J(d,"."),this.h()},h(){j(m,"href","https://docs.llamaindex.ai/en/stable/module_guides/"),j(i,"href","https://docs.llamaindex.ai/en/stable/understanding/rag/")},m(d,$){l(d,c,$),l(d,m,$),l(d,p,$),l(d,i,$),l(d,h,$)},p:Re,d(d){d&&(n(c),n(m),n(p),n(i),n(h))}}}function Fn(U){let c,m,T,p,i,v,h,d=`Remember Alfred, our helpful butler agent from Unit 1?
To assist us effectively, Alfred needs to understand our requests and <strong>prepare, find and use relevant information to help complete tasks.</strong>
This is where LlamaIndex’s components come in.`,$,E,qt=`While LlamaIndex has many components, <strong>we’ll focus specifically on the <code>QueryEngine</code> component.</strong>
Why? Because it can be used as a Retrieval-Augmented Generation (RAG) tool for an agent.`,He,X,Qt=`So, what is RAG? LLMs are trained on enormous bodies of data to learn general knowledge.
However, they may not be trained on relevant and up-to-date data.
RAG solves this problem by finding and retrieving relevant information from your data and giving that to the LLM.`,Ye,A,zt='<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/llama-index/rag.png" alt="RAG"/>',Se,R,Dt="Now, think about how Alfred works:",Ne,H,Kt="<li>You ask Alfred to help plan a dinner party</li> <li>Alfred needs to check your calendar, dietary preferences, and past successful menus</li> <li>The <code>QueryEngine</code> helps Alfred find this information and use it to plan the dinner party</li>",Fe,Y,Ot=`This makes the <code>QueryEngine</code> <strong>a key component for building agentic RAG workflows</strong> in LlamaIndex.
Just as Alfred needs to search through your household information to be helpful, any agent needs a way to find and understand relevant data.
The <code>QueryEngine</code> provides exactly this capability.`,Pe,S,en="Now, let’s dive a bit deeper into the components and see how you can <strong>combine components to create a RAG pipeline.</strong>",qe,N,Qe,L,ze,F,tn="There are five key stages within RAG, which in turn will be a part of most larger applications you build. These are:",De,P,nn="<li><strong>Loading</strong>: this refers to getting your data from where it lives — whether it’s text files, PDFs, another website, a database, or an API — into your workflow. LlamaHub provides hundreds of integrations to choose from.</li> <li><strong>Indexing</strong>: this means creating a data structure that allows for querying the data. For LLMs, this nearly always means creating vector embeddings. Which are numerical representations of the meaning of the data. Indexing can also refer to numerous other metadata strategies to make it easy to accurately find contextually relevant data based on properties.</li> <li><strong>Storing</strong>: once your data is indexed you will want to store your index, as well as other metadata, to avoid having to re-index it.</li> <li><strong>Querying</strong>: for any given indexing strategy there are many ways you can utilize LLMs and LlamaIndex data structures to query, including sub-queries, multi-step queries and hybrid strategies.</li> <li><strong>Evaluation</strong>: a critical step in any flow is checking how effective it is relative to other strategies, or when you make changes. Evaluation provides objective measures of how accurate, faithful and fast your responses to queries are.</li>",Ke,q,ln="Next, let’s see how we can reproduce these stages using components.",Oe,Q,et,z,an=`As mentioned before, LlamaIndex can work on top of your own data, however, <strong>before accessing data, we need to load it.</strong>
There are three main ways to load data into LlamaIndex:`,tt,D,sn="<li><code>SimpleDirectoryReader</code>: A built-in loader for various file types from a local directory.</li> <li><code>LlamaParse</code>: LlamaParse, LlamaIndex’s official tool for PDF parsing, available as a managed API.</li> <li><code>LlamaHub</code>: A registry of hundreds of data-loading libraries to ingest data from any source.</li>",nt,I,lt,K,on=`<strong>The simplest way to load data is with <code>SimpleDirectoryReader</code>.</strong>
This versatile component can load various file types from a folder and convert them into <code>Document</code> objects that LlamaIndex can work with.
Let’s see how we can use <code>SimpleDirectoryReader</code> to load data from a folder.`,at,O,st,ee,rn=`After loading our documents, we need to break them into smaller pieces called <code>Node</code> objects.
A <code>Node</code> is just a chunk of text from the original document that’s easier for the AI to work with, while it still has references to the original <code>Document</code> object.`,it,te,mn="The <code>IngestionPipeline</code> helps us create these nodes through two key transformations.",ot,ne,un="<li><code>SentenceSplitter</code> breaks down documents into manageable chunks by splitting them at natural sentence boundaries.</li> <li><code>HuggingFaceInferenceAPIEmbedding</code> converts each chunk into numerical embeddings - vector representations that capture the semantic meaning in a way AI can process efficiently.</li>",rt,le,dn="This process helps us organise our documents in a way that’s more useful for searching and analysis.",mt,ae,ut,se,dt,ie,cn="After creating our <code>Node</code> objects we need to index them to make them searchable, but before we can do that, we need a place to store our data.",ct,oe,pn=`Since we are using an ingestion pipeline, we can directly attach a vector store to the pipeline to populate it.
In this case, we will use <code>Chroma</code> to store our documents.`,pt,G,ke,hn="Install ChromaDB",St,re,ht,me,ft,k,yt,ue,fn=`This is where vector embeddings come in - by embedding both the query and nodes in the same vector space, we can find relevant matches.
The <code>VectorStoreIndex</code> handles this for us, using the same embedding model we used during ingestion to ensure consistency.`,wt,de,yn="Let’s see how to create this index from our vector store and embeddings:",bt,ce,gt,pe,wn="All infomration is automatically persisted within the <code>ChromaVectorStore</code> object and the passed directory path.",Mt,he,bn="Great! Now that we can save and load our index easily, let’s explore how to query it in different ways.",vt,fe,Tt,ye,gn="Before we can query our index, we need to convert it to a query interface. The most common conversion options are:",$t,we,Mn="<li><code>as_retriever</code>: For basic document retrieval, returning a list of <code>NodeWithScore</code> objects with similarity scores</li> <li><code>as_query_engine</code>: For single question-answer interactions, returning a written response</li> <li><code>as_chat_engine</code>: For conversational interactions that maintain memory across multiple messages, returning a written response using chat history and indexed context</li>",xt,be,vn=`We’ll focus on the query engine since it is more common for agent-like interactions.
We also pass in an LLM to the query engine to use for the response.`,Jt,ge,Ut,Me,Zt,ve,Tn=`Under the hood, the query engine doesn’t only use the LLM to answer the question but also uses a <code>ResponseSynthesizer</code> as a strategy to process the response.
Once again, this is fully customisable but there are three main strategies that work well out of the box:`,Ct,Te,$n="<li><code>refine</code>: create and refine an answer by sequentially going through each retrieved text chunk. This makes a separate LLM call per Node/retrieved chunk.</li> <li><code>compact</code> (default): similar to refining but concatenating the chunks beforehand, resulting in fewer LLM calls.</li> <li><code>tree_summarize</code>: create a detailed answer by going through each retrieved text chunk and creating a tree structure of the answer.</li>",jt,B,_t,$e,xn="The language model won’t always perform in predictable ways, so we can’t be sure that the answer we get is always correct. We can deal with this by <strong>evaluating the quality of the answer</strong>.",Wt,xe,Lt,Je,Jn=`LlamaIndex provides <strong>built-in evaluation tools to assess response quality.</strong>
These evaluators leverage LLMs to analyze responses across different dimensions.
Let’s look at the three main evaluators available:`,It,Ue,Un="<li><code>FaithfulnessEvaluator</code>: Evaluates the faithfulness of the answer by checking if the answer is supported by the context.</li> <li><code>AnswerRelevancyEvaluator</code>: Evaluate the relevance of the answer by checking if the answer is relevant to the question.</li> <li><code>CorrectnessEvaluator</code>: Evaluate the correctness of the answer by checking if the answer is correct.</li>",Gt,Ze,kt,Ce,Zn=`Even without direct evaluation, we can <strong>gain insights into how our system is performing through observability.</strong>
This is especially useful when we are building more complex workflows and want to understand how each component is performing.`,Bt,Z,Be,Cn="Install LlamaTrace",Nt,je,Ft,Ve,jn="Additionally, we need to set the <code>PHOENIX_API_KEY</code> environment variable to our LlamaTrace API key. We can get this by:",Pt,Ee,_n='<li>Creating an account at <a href="https://llamatrace.com/login" rel="nofollow">LlamaTrace</a></li> <li>Generating an API key in your account settings</li> <li>Using the API key in the code below to enable tracing</li>',Vt,_e,Et,V,Xt,We,Wn="We have seen how to use components to create a <code>QueryEngine</code>. Now, let’s see how we can <strong>use the <code>QueryEngine</code> as a tool for an agent!</strong>",At,Le,Rt,Xe,Ht;return i=new Ge({props:{title:"What are components in LlamaIndex?",local:"what-are-components-in-llamaindex",headingTag:"h1"}}),N=new Ge({props:{title:"Creating a RAG pipeline using components",local:"creating-a-rag-pipeline-using-components",headingTag:"h2"}}),L=new Ae({props:{$$slots:{default:[Rn]},$$scope:{ctx:U}}}),Q=new Ge({props:{title:"Loading and embedding documents",local:"loading-and-embedding-documents",headingTag:"h3"}}),I=new Ae({props:{$$slots:{default:[Hn]},$$scope:{ctx:U}}}),O=new W({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUlMjBpbXBvcnQlMjBTaW1wbGVEaXJlY3RvcnlSZWFkZXIlMEElMEFyZWFkZXIlMjAlM0QlMjBTaW1wbGVEaXJlY3RvcnlSZWFkZXIoaW5wdXRfZGlyJTNEJTIycGF0aCUyRnRvJTJGZGlyZWN0b3J5JTIyKSUwQWRvY3VtZW50cyUyMCUzRCUyMHJlYWRlci5sb2FkX2RhdGEoKQ==",highlighted:`<span class="hljs-keyword">from</span> llama_index.core <span class="hljs-keyword">import</span> SimpleDirectoryReader

reader = SimpleDirectoryReader(input_dir=<span class="hljs-string">&quot;path/to/directory&quot;</span>)
documents = reader.load_data()`,wrap:!1}}),ae=new W({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUlMjBpbXBvcnQlMjBEb2N1bWVudCUwQWZyb20lMjBsbGFtYV9pbmRleC5lbWJlZGRpbmdzLmh1Z2dpbmdmYWNlX2FwaSUyMGltcG9ydCUyMEh1Z2dpbmdGYWNlSW5mZXJlbmNlQVBJRW1iZWRkaW5nJTBBZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUubm9kZV9wYXJzZXIlMjBpbXBvcnQlMjBTZW50ZW5jZVNwbGl0dGVyJTBBZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUuaW5nZXN0aW9uJTIwaW1wb3J0JTIwSW5nZXN0aW9uUGlwZWxpbmUlMEElMEElMjMlMjBjcmVhdGUlMjB0aGUlMjBwaXBlbGluZSUyMHdpdGglMjB0cmFuc2Zvcm1hdGlvbnMlMEFwaXBlbGluZSUyMCUzRCUyMEluZ2VzdGlvblBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHRyYW5zZm9ybWF0aW9ucyUzRCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFNlbnRlbmNlU3BsaXR0ZXIoY2h1bmtfb3ZlcmxhcCUzRDApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUElFbWJlZGRpbmcobW9kZWxfbmFtZSUzRCUyMkJBQUklMkZiZ2Utc21hbGwtZW4tdjEuNSUyMiklMkMlMEElMjAlMjAlMjAlMjAlNUQlMEEpJTBBJTBBbm9kZXMlMjAlM0QlMjBhd2FpdCUyMHBpcGVsaW5lLmFydW4oZG9jdW1lbnRzJTNEJTVCRG9jdW1lbnQuZXhhbXBsZSgpJTVEKQ==",highlighted:`<span class="hljs-keyword">from</span> llama_index.core <span class="hljs-keyword">import</span> Document
<span class="hljs-keyword">from</span> llama_index.embeddings.huggingface_api <span class="hljs-keyword">import</span> HuggingFaceInferenceAPIEmbedding
<span class="hljs-keyword">from</span> llama_index.core.node_parser <span class="hljs-keyword">import</span> SentenceSplitter
<span class="hljs-keyword">from</span> llama_index.core.ingestion <span class="hljs-keyword">import</span> IngestionPipeline

<span class="hljs-comment"># create the pipeline with transformations</span>
pipeline = IngestionPipeline(
    transformations=[
        SentenceSplitter(chunk_overlap=<span class="hljs-number">0</span>),
        HuggingFaceInferenceAPIEmbedding(model_name=<span class="hljs-string">&quot;BAAI/bge-small-en-v1.5&quot;</span>),
    ]
)

nodes = <span class="hljs-keyword">await</span> pipeline.arun(documents=[Document.example()])`,wrap:!1}}),se=new Ge({props:{title:"Storing and indexing documents",local:"storing-and-indexing-documents",headingTag:"h3"}}),re=new W({props:{code:"cGlwJTIwaW5zdGFsbCUyMGxsYW1hLWluZGV4LXZlY3Rvci1zdG9yZXMtY2hyb21h",highlighted:"pip install llama-index-vector-stores-chroma",wrap:!1}}),me=new W({props:{code:"aW1wb3J0JTIwY2hyb21hZGIlMEFmcm9tJTIwbGxhbWFfaW5kZXgudmVjdG9yX3N0b3Jlcy5jaHJvbWElMjBpbXBvcnQlMjBDaHJvbWFWZWN0b3JTdG9yZSUwQSUwQWRiJTIwJTNEJTIwY2hyb21hZGIuUGVyc2lzdGVudENsaWVudChwYXRoJTNEJTIyLiUyRmFsZnJlZF9jaHJvbWFfZGIlMjIpJTBBY2hyb21hX2NvbGxlY3Rpb24lMjAlM0QlMjBkYi5nZXRfb3JfY3JlYXRlX2NvbGxlY3Rpb24oJTIyYWxmcmVkJTIyKSUwQXZlY3Rvcl9zdG9yZSUyMCUzRCUyMENocm9tYVZlY3RvclN0b3JlKGNocm9tYV9jb2xsZWN0aW9uJTNEY2hyb21hX2NvbGxlY3Rpb24pJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBJbmdlc3Rpb25QaXBlbGluZSglMEElMjAlMjAlMjAlMjB0cmFuc2Zvcm1hdGlvbnMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBTZW50ZW5jZVNwbGl0dGVyKGNodW5rX3NpemUlM0QyNSUyQyUyMGNodW5rX292ZXJsYXAlM0QwKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMEh1Z2dpbmdGYWNlSW5mZXJlbmNlQVBJRW1iZWRkaW5nKG1vZGVsX25hbWUlM0QlMjJCQUFJJTJGYmdlLXNtYWxsLWVuLXYxLjUlMjIpJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwdmVjdG9yX3N0b3JlJTNEdmVjdG9yX3N0b3JlJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> chromadb
<span class="hljs-keyword">from</span> llama_index.vector_stores.chroma <span class="hljs-keyword">import</span> ChromaVectorStore

db = chromadb.PersistentClient(path=<span class="hljs-string">&quot;./alfred_chroma_db&quot;</span>)
chroma_collection = db.get_or_create_collection(<span class="hljs-string">&quot;alfred&quot;</span>)
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)

pipeline = IngestionPipeline(
    transformations=[
        SentenceSplitter(chunk_size=<span class="hljs-number">25</span>, chunk_overlap=<span class="hljs-number">0</span>),
        HuggingFaceInferenceAPIEmbedding(model_name=<span class="hljs-string">&quot;BAAI/bge-small-en-v1.5&quot;</span>),
    ],
    vector_store=vector_store,
)`,wrap:!1}}),k=new Ae({props:{$$slots:{default:[Yn]},$$scope:{ctx:U}}}),ce=new W({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUlMjBpbXBvcnQlMjBWZWN0b3JTdG9yZUluZGV4JTBBZnJvbSUyMGxsYW1hX2luZGV4LmVtYmVkZGluZ3MuaHVnZ2luZ2ZhY2VfYXBpJTIwaW1wb3J0JTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUElFbWJlZGRpbmclMEElMEFlbWJlZF9tb2RlbCUyMCUzRCUyMEh1Z2dpbmdGYWNlSW5mZXJlbmNlQVBJRW1iZWRkaW5nKG1vZGVsX25hbWUlM0QlMjJCQUFJJTJGYmdlLXNtYWxsLWVuLXYxLjUlMjIpJTBBaW5kZXglMjAlM0QlMjBWZWN0b3JTdG9yZUluZGV4LmZyb21fdmVjdG9yX3N0b3JlKHZlY3Rvcl9zdG9yZSUyQyUyMGVtYmVkX21vZGVsJTNEZW1iZWRfbW9kZWwp",highlighted:`<span class="hljs-keyword">from</span> llama_index.core <span class="hljs-keyword">import</span> VectorStoreIndex
<span class="hljs-keyword">from</span> llama_index.embeddings.huggingface_api <span class="hljs-keyword">import</span> HuggingFaceInferenceAPIEmbedding

embed_model = HuggingFaceInferenceAPIEmbedding(model_name=<span class="hljs-string">&quot;BAAI/bge-small-en-v1.5&quot;</span>)
index = VectorStoreIndex.from_vector_store(vector_store, embed_model=embed_model)`,wrap:!1}}),fe=new Ge({props:{title:"Querying a VectorStoreIndex with prompts and LLMs",local:"querying-a-vectorstoreindex-with-prompts-and-llms",headingTag:"h3"}}),ge=new W({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmxsbXMuaHVnZ2luZ2ZhY2VfYXBpJTIwaW1wb3J0JTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUEklMEElMEFsbG0lMjAlM0QlMjBIdWdnaW5nRmFjZUluZmVyZW5jZUFQSShtb2RlbF9uYW1lJTNEJTIyUXdlbiUyRlF3ZW4yLjUtQ29kZXItMzJCLUluc3RydWN0JTIyKSUwQXF1ZXJ5X2VuZ2luZSUyMCUzRCUyMGluZGV4LmFzX3F1ZXJ5X2VuZ2luZSglMEElMjAlMjAlMjAlMjBsbG0lM0RsbG0lMkMlMEElMjAlMjAlMjAlMjByZXNwb25zZV9tb2RlJTNEJTIydHJlZV9zdW1tYXJpemUlMjIlMkMlMEEpJTBBcXVlcnlfZW5naW5lLnF1ZXJ5KCUyMldoYXQlMjBpcyUyMHRoZSUyMG1lYW5pbmclMjBvZiUyMGxpZmUlM0YlMjIpJTBBJTIzJTIwVGhlJTIwbWVhbmluZyUyMG9mJTIwbGlmZSUyMGlzJTIwNDI=",highlighted:`<span class="hljs-keyword">from</span> llama_index.llms.huggingface_api <span class="hljs-keyword">import</span> HuggingFaceInferenceAPI

llm = HuggingFaceInferenceAPI(model_name=<span class="hljs-string">&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</span>)
query_engine = index.as_query_engine(
    llm=llm,
    response_mode=<span class="hljs-string">&quot;tree_summarize&quot;</span>,
)
query_engine.query(<span class="hljs-string">&quot;What is the meaning of life?&quot;</span>)
<span class="hljs-comment"># The meaning of life is 42</span>`,wrap:!1}}),Me=new Ge({props:{title:"Response Processing",local:"response-processing",headingTag:"h3"}}),B=new Ae({props:{$$slots:{default:[Sn]},$$scope:{ctx:U}}}),xe=new Ge({props:{title:"Evaluation and observability",local:"evaluation-and-observability",headingTag:"h3"}}),Ze=new W({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUuZXZhbHVhdGlvbiUyMGltcG9ydCUyMEZhaXRoZnVsbmVzc0V2YWx1YXRvciUwQSUwQXF1ZXJ5X2VuZ2luZSUyMCUzRCUyMCUyMyUyMGZyb20lMjB0aGUlMjBwcmV2aW91cyUyMHNlY3Rpb24lMEFsbG0lMjAlM0QlMjAlMjMlMjBmcm9tJTIwdGhlJTIwcHJldmlvdXMlMjBzZWN0aW9uJTBBJTBBJTIzJTIwcXVlcnklMjBpbmRleCUwQWV2YWx1YXRvciUyMCUzRCUyMEZhaXRoZnVsbmVzc0V2YWx1YXRvcihsbG0lM0RsbG0pJTBBcmVzcG9uc2UlMjAlM0QlMjBxdWVyeV9lbmdpbmUucXVlcnkoJTBBJTIwJTIwJTIwJTIwJTIyV2hhdCUyMGJhdHRsZXMlMjB0b29rJTIwcGxhY2UlMjBpbiUyME5ldyUyMFlvcmslMjBDaXR5JTIwaW4lMjB0aGUlMjBBbWVyaWNhbiUyMFJldm9sdXRpb24lM0YlMjIlMEEpJTBBZXZhbF9yZXN1bHQlMjAlM0QlMjBldmFsdWF0b3IuZXZhbHVhdGVfcmVzcG9uc2UocmVzcG9uc2UlM0RyZXNwb25zZSklMEFldmFsX3Jlc3VsdC5wYXNzaW5n",highlighted:`<span class="hljs-keyword">from</span> llama_index.core.evaluation <span class="hljs-keyword">import</span> FaithfulnessEvaluator

query_engine = <span class="hljs-comment"># from the previous section</span>
llm = <span class="hljs-comment"># from the previous section</span>

<span class="hljs-comment"># query index</span>
evaluator = FaithfulnessEvaluator(llm=llm)
response = query_engine.query(
    <span class="hljs-string">&quot;What battles took place in New York City in the American Revolution?&quot;</span>
)
eval_result = evaluator.evaluate_response(response=response)
eval_result.passing`,wrap:!1}}),je=new W({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwbGxhbWEtaW5kZXgtY2FsbGJhY2tzLWFyaXplLXBob2VuaXg=",highlighted:"pip install -U llama-index-callbacks-arize-phoenix",wrap:!1}}),_e=new W({props:{code:"aW1wb3J0JTIwbGxhbWFfaW5kZXglMEFpbXBvcnQlMjBvcyUwQSUwQVBIT0VOSVhfQVBJX0tFWSUyMCUzRCUyMCUyMiUzQ1BIT0VOSVhfQVBJX0tFWSUzRSUyMiUwQW9zLmVudmlyb24lNUIlMjJPVEVMX0VYUE9SVEVSX09UTFBfSEVBREVSUyUyMiU1RCUyMCUzRCUyMGYlMjJhcGlfa2V5JTNEJTdCUEhPRU5JWF9BUElfS0VZJTdEJTIyJTBBbGxhbWFfaW5kZXguY29yZS5zZXRfZ2xvYmFsX2hhbmRsZXIoJTBBJTIwJTIwJTIwJTIwJTIyYXJpemVfcGhvZW5peCUyMiUyQyUwQSUyMCUyMCUyMCUyMGVuZHBvaW50JTNEJTIyaHR0cHMlM0ElMkYlMkZsbGFtYXRyYWNlLmNvbSUyRnYxJTJGdHJhY2VzJTIyJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> llama_index
<span class="hljs-keyword">import</span> os

PHOENIX_API_KEY = <span class="hljs-string">&quot;&lt;PHOENIX_API_KEY&gt;&quot;</span>
os.environ[<span class="hljs-string">&quot;OTEL_EXPORTER_OTLP_HEADERS&quot;</span>] = <span class="hljs-string">f&quot;api_key=<span class="hljs-subst">{PHOENIX_API_KEY}</span>&quot;</span>
llama_index.core.set_global_handler(
    <span class="hljs-string">&quot;arize_phoenix&quot;</span>,
    endpoint=<span class="hljs-string">&quot;https://llamatrace.com/v1/traces&quot;</span>
)`,wrap:!1}}),V=new Ae({props:{$$slots:{default:[Nn]},$$scope:{ctx:U}}}),Le=new An({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/en/unit2/llama-index/components.mdx"}}),{c(){c=o("meta"),m=a(),T=o("p"),p=a(),f(i.$$.fragment),v=a(),h=o("p"),h.innerHTML=d,$=a(),E=o("p"),E.innerHTML=qt,He=a(),X=o("p"),X.textContent=Qt,Ye=a(),A=o("p"),A.innerHTML=zt,Se=a(),R=o("p"),R.textContent=Dt,Ne=a(),H=o("ol"),H.innerHTML=Kt,Fe=a(),Y=o("p"),Y.innerHTML=Ot,Pe=a(),S=o("p"),S.innerHTML=en,qe=a(),f(N.$$.fragment),Qe=a(),f(L.$$.fragment),ze=a(),F=o("p"),F.textContent=tn,De=a(),P=o("ol"),P.innerHTML=nn,Ke=a(),q=o("p"),q.textContent=ln,Oe=a(),f(Q.$$.fragment),et=a(),z=o("p"),z.innerHTML=an,tt=a(),D=o("ol"),D.innerHTML=sn,nt=a(),f(I.$$.fragment),lt=a(),K=o("p"),K.innerHTML=on,at=a(),f(O.$$.fragment),st=a(),ee=o("p"),ee.innerHTML=rn,it=a(),te=o("p"),te.innerHTML=mn,ot=a(),ne=o("ol"),ne.innerHTML=un,rt=a(),le=o("p"),le.textContent=dn,mt=a(),f(ae.$$.fragment),ut=a(),f(se.$$.fragment),dt=a(),ie=o("p"),ie.innerHTML=cn,ct=a(),oe=o("p"),oe.innerHTML=pn,pt=a(),G=o("details"),ke=o("summary"),ke.textContent=hn,St=x(`
As introduced in the [section on the LlamaHub](llama-hub), we can install the ChromaDB vector store with the following command:

	`),f(re.$$.fragment),ht=a(),f(me.$$.fragment),ft=a(),f(k.$$.fragment),yt=a(),ue=o("p"),ue.innerHTML=fn,wt=a(),de=o("p"),de.textContent=yn,bt=a(),f(ce.$$.fragment),gt=a(),pe=o("p"),pe.innerHTML=wn,Mt=a(),he=o("p"),he.textContent=bn,vt=a(),f(fe.$$.fragment),Tt=a(),ye=o("p"),ye.textContent=gn,$t=a(),we=o("ul"),we.innerHTML=Mn,xt=a(),be=o("p"),be.textContent=vn,Jt=a(),f(ge.$$.fragment),Ut=a(),f(Me.$$.fragment),Zt=a(),ve=o("p"),ve.innerHTML=Tn,Ct=a(),Te=o("ul"),Te.innerHTML=$n,jt=a(),f(B.$$.fragment),_t=a(),$e=o("p"),$e.innerHTML=xn,Wt=a(),f(xe.$$.fragment),Lt=a(),Je=o("p"),Je.innerHTML=Jn,It=a(),Ue=o("ul"),Ue.innerHTML=Un,Gt=a(),f(Ze.$$.fragment),kt=a(),Ce=o("p"),Ce.innerHTML=Zn,Bt=a(),Z=o("details"),Be=o("summary"),Be.textContent=Cn,Nt=x(`
As introduced in the [section on the LlamaHub](llama-hub), we can install the LlamaTrace callback from Arize Phoenix with the following command:

	`),f(je.$$.fragment),Ft=a(),Ve=o("p"),Ve.innerHTML=jn,Pt=a(),Ee=o("ul"),Ee.innerHTML=_n,Vt=a(),f(_e.$$.fragment),Et=a(),f(V.$$.fragment),Xt=a(),We=o("p"),We.innerHTML=Wn,At=a(),f(Le.$$.fragment),Rt=a(),Xe=o("p"),this.h()},l(e){const t=Xn("svelte-u9bgzb",document.head);c=r(t,"META",{name:!0,content:!0}),t.forEach(n),m=s(e),T=r(e,"P",{}),Yt(T).forEach(n),p=s(e),y(i.$$.fragment,e),v=s(e),h=r(e,"P",{"data-svelte-h":!0}),u(h)!=="svelte-1vh4okn"&&(h.innerHTML=d),$=s(e),E=r(e,"P",{"data-svelte-h":!0}),u(E)!=="svelte-35rbyv"&&(E.innerHTML=qt),He=s(e),X=r(e,"P",{"data-svelte-h":!0}),u(X)!=="svelte-1dt1sd0"&&(X.textContent=Qt),Ye=s(e),A=r(e,"P",{"data-svelte-h":!0}),u(A)!=="svelte-kysd50"&&(A.innerHTML=zt),Se=s(e),R=r(e,"P",{"data-svelte-h":!0}),u(R)!=="svelte-aqkixd"&&(R.textContent=Dt),Ne=s(e),H=r(e,"OL",{"data-svelte-h":!0}),u(H)!=="svelte-135qvuu"&&(H.innerHTML=Kt),Fe=s(e),Y=r(e,"P",{"data-svelte-h":!0}),u(Y)!=="svelte-mnkj36"&&(Y.innerHTML=Ot),Pe=s(e),S=r(e,"P",{"data-svelte-h":!0}),u(S)!=="svelte-ga98sq"&&(S.innerHTML=en),qe=s(e),y(N.$$.fragment,e),Qe=s(e),y(L.$$.fragment,e),ze=s(e),F=r(e,"P",{"data-svelte-h":!0}),u(F)!=="svelte-bhgae9"&&(F.textContent=tn),De=s(e),P=r(e,"OL",{"data-svelte-h":!0}),u(P)!=="svelte-1y6wwuy"&&(P.innerHTML=nn),Ke=s(e),q=r(e,"P",{"data-svelte-h":!0}),u(q)!=="svelte-12zc4us"&&(q.textContent=ln),Oe=s(e),y(Q.$$.fragment,e),et=s(e),z=r(e,"P",{"data-svelte-h":!0}),u(z)!=="svelte-1246hsd"&&(z.innerHTML=an),tt=s(e),D=r(e,"OL",{"data-svelte-h":!0}),u(D)!=="svelte-iz7p8h"&&(D.innerHTML=sn),nt=s(e),y(I.$$.fragment,e),lt=s(e),K=r(e,"P",{"data-svelte-h":!0}),u(K)!=="svelte-1c6elju"&&(K.innerHTML=on),at=s(e),y(O.$$.fragment,e),st=s(e),ee=r(e,"P",{"data-svelte-h":!0}),u(ee)!=="svelte-4bo0to"&&(ee.innerHTML=rn),it=s(e),te=r(e,"P",{"data-svelte-h":!0}),u(te)!=="svelte-1uspfck"&&(te.innerHTML=mn),ot=s(e),ne=r(e,"OL",{"data-svelte-h":!0}),u(ne)!=="svelte-30wrf4"&&(ne.innerHTML=un),rt=s(e),le=r(e,"P",{"data-svelte-h":!0}),u(le)!=="svelte-7ysnum"&&(le.textContent=dn),mt=s(e),y(ae.$$.fragment,e),ut=s(e),y(se.$$.fragment,e),dt=s(e),ie=r(e,"P",{"data-svelte-h":!0}),u(ie)!=="svelte-1symqva"&&(ie.innerHTML=cn),ct=s(e),oe=r(e,"P",{"data-svelte-h":!0}),u(oe)!=="svelte-1j1sj1y"&&(oe.innerHTML=pn),pt=s(e),G=r(e,"DETAILS",{});var Ie=Yt(G);ke=r(Ie,"SUMMARY",{"data-svelte-h":!0}),u(ke)!=="svelte-187ducf"&&(ke.textContent=hn),St=J(Ie,`
As introduced in the [section on the LlamaHub](llama-hub), we can install the ChromaDB vector store with the following command:

	`),y(re.$$.fragment,Ie),Ie.forEach(n),ht=s(e),y(me.$$.fragment,e),ft=s(e),y(k.$$.fragment,e),yt=s(e),ue=r(e,"P",{"data-svelte-h":!0}),u(ue)!=="svelte-axr536"&&(ue.innerHTML=fn),wt=s(e),de=r(e,"P",{"data-svelte-h":!0}),u(de)!=="svelte-s47gic"&&(de.textContent=yn),bt=s(e),y(ce.$$.fragment,e),gt=s(e),pe=r(e,"P",{"data-svelte-h":!0}),u(pe)!=="svelte-8ij05"&&(pe.innerHTML=wn),Mt=s(e),he=r(e,"P",{"data-svelte-h":!0}),u(he)!=="svelte-1j63axa"&&(he.textContent=bn),vt=s(e),y(fe.$$.fragment,e),Tt=s(e),ye=r(e,"P",{"data-svelte-h":!0}),u(ye)!=="svelte-18ur37c"&&(ye.textContent=gn),$t=s(e),we=r(e,"UL",{"data-svelte-h":!0}),u(we)!=="svelte-d9r342"&&(we.innerHTML=Mn),xt=s(e),be=r(e,"P",{"data-svelte-h":!0}),u(be)!=="svelte-rqskw5"&&(be.textContent=vn),Jt=s(e),y(ge.$$.fragment,e),Ut=s(e),y(Me.$$.fragment,e),Zt=s(e),ve=r(e,"P",{"data-svelte-h":!0}),u(ve)!=="svelte-1j4gc2q"&&(ve.innerHTML=Tn),Ct=s(e),Te=r(e,"UL",{"data-svelte-h":!0}),u(Te)!=="svelte-3mam70"&&(Te.innerHTML=$n),jt=s(e),y(B.$$.fragment,e),_t=s(e),$e=r(e,"P",{"data-svelte-h":!0}),u($e)!=="svelte-16j3xwr"&&($e.innerHTML=xn),Wt=s(e),y(xe.$$.fragment,e),Lt=s(e),Je=r(e,"P",{"data-svelte-h":!0}),u(Je)!=="svelte-1m4sp8c"&&(Je.innerHTML=Jn),It=s(e),Ue=r(e,"UL",{"data-svelte-h":!0}),u(Ue)!=="svelte-252wdz"&&(Ue.innerHTML=Un),Gt=s(e),y(Ze.$$.fragment,e),kt=s(e),Ce=r(e,"P",{"data-svelte-h":!0}),u(Ce)!=="svelte-f2lt8l"&&(Ce.innerHTML=Zn),Bt=s(e),Z=r(e,"DETAILS",{});var C=Yt(Z);Be=r(C,"SUMMARY",{"data-svelte-h":!0}),u(Be)!=="svelte-1csrw0t"&&(Be.textContent=Cn),Nt=J(C,`
As introduced in the [section on the LlamaHub](llama-hub), we can install the LlamaTrace callback from Arize Phoenix with the following command:

	`),y(je.$$.fragment,C),Ft=s(C),Ve=r(C,"P",{"data-svelte-h":!0}),u(Ve)!=="svelte-2gef6z"&&(Ve.innerHTML=jn),Pt=s(C),Ee=r(C,"UL",{"data-svelte-h":!0}),u(Ee)!=="svelte-13n4s9w"&&(Ee.innerHTML=_n),C.forEach(n),Vt=s(e),y(_e.$$.fragment,e),Et=s(e),y(V.$$.fragment,e),Xt=s(e),We=r(e,"P",{"data-svelte-h":!0}),u(We)!=="svelte-13rfypl"&&(We.innerHTML=Wn),At=s(e),y(Le.$$.fragment,e),Rt=s(e),Xe=r(e,"P",{}),Yt(Xe).forEach(n),this.h()},h(){j(c,"name","hf:doc:metadata"),j(c,"content",Pn)},m(e,t){_(document.head,c),l(e,m,t),l(e,T,t),l(e,p,t),w(i,e,t),l(e,v,t),l(e,h,t),l(e,$,t),l(e,E,t),l(e,He,t),l(e,X,t),l(e,Ye,t),l(e,A,t),l(e,Se,t),l(e,R,t),l(e,Ne,t),l(e,H,t),l(e,Fe,t),l(e,Y,t),l(e,Pe,t),l(e,S,t),l(e,qe,t),w(N,e,t),l(e,Qe,t),w(L,e,t),l(e,ze,t),l(e,F,t),l(e,De,t),l(e,P,t),l(e,Ke,t),l(e,q,t),l(e,Oe,t),w(Q,e,t),l(e,et,t),l(e,z,t),l(e,tt,t),l(e,D,t),l(e,nt,t),w(I,e,t),l(e,lt,t),l(e,K,t),l(e,at,t),w(O,e,t),l(e,st,t),l(e,ee,t),l(e,it,t),l(e,te,t),l(e,ot,t),l(e,ne,t),l(e,rt,t),l(e,le,t),l(e,mt,t),w(ae,e,t),l(e,ut,t),w(se,e,t),l(e,dt,t),l(e,ie,t),l(e,ct,t),l(e,oe,t),l(e,pt,t),l(e,G,t),_(G,ke),_(G,St),w(re,G,null),l(e,ht,t),w(me,e,t),l(e,ft,t),w(k,e,t),l(e,yt,t),l(e,ue,t),l(e,wt,t),l(e,de,t),l(e,bt,t),w(ce,e,t),l(e,gt,t),l(e,pe,t),l(e,Mt,t),l(e,he,t),l(e,vt,t),w(fe,e,t),l(e,Tt,t),l(e,ye,t),l(e,$t,t),l(e,we,t),l(e,xt,t),l(e,be,t),l(e,Jt,t),w(ge,e,t),l(e,Ut,t),w(Me,e,t),l(e,Zt,t),l(e,ve,t),l(e,Ct,t),l(e,Te,t),l(e,jt,t),w(B,e,t),l(e,_t,t),l(e,$e,t),l(e,Wt,t),w(xe,e,t),l(e,Lt,t),l(e,Je,t),l(e,It,t),l(e,Ue,t),l(e,Gt,t),w(Ze,e,t),l(e,kt,t),l(e,Ce,t),l(e,Bt,t),l(e,Z,t),_(Z,Be),_(Z,Nt),w(je,Z,null),_(Z,Ft),_(Z,Ve),_(Z,Pt),_(Z,Ee),l(e,Vt,t),w(_e,e,t),l(e,Et,t),w(V,e,t),l(e,Xt,t),l(e,We,t),l(e,At,t),w(Le,e,t),l(e,Rt,t),l(e,Xe,t),Ht=!0},p(e,[t]){const Ie={};t&2&&(Ie.$$scope={dirty:t,ctx:e}),L.$set(Ie);const C={};t&2&&(C.$$scope={dirty:t,ctx:e}),I.$set(C);const Ln={};t&2&&(Ln.$$scope={dirty:t,ctx:e}),k.$set(Ln);const In={};t&2&&(In.$$scope={dirty:t,ctx:e}),B.$set(In);const Gn={};t&2&&(Gn.$$scope={dirty:t,ctx:e}),V.$set(Gn)},i(e){Ht||(b(i.$$.fragment,e),b(N.$$.fragment,e),b(L.$$.fragment,e),b(Q.$$.fragment,e),b(I.$$.fragment,e),b(O.$$.fragment,e),b(ae.$$.fragment,e),b(se.$$.fragment,e),b(re.$$.fragment,e),b(me.$$.fragment,e),b(k.$$.fragment,e),b(ce.$$.fragment,e),b(fe.$$.fragment,e),b(ge.$$.fragment,e),b(Me.$$.fragment,e),b(B.$$.fragment,e),b(xe.$$.fragment,e),b(Ze.$$.fragment,e),b(je.$$.fragment,e),b(_e.$$.fragment,e),b(V.$$.fragment,e),b(Le.$$.fragment,e),Ht=!0)},o(e){g(i.$$.fragment,e),g(N.$$.fragment,e),g(L.$$.fragment,e),g(Q.$$.fragment,e),g(I.$$.fragment,e),g(O.$$.fragment,e),g(ae.$$.fragment,e),g(se.$$.fragment,e),g(re.$$.fragment,e),g(me.$$.fragment,e),g(k.$$.fragment,e),g(ce.$$.fragment,e),g(fe.$$.fragment,e),g(ge.$$.fragment,e),g(Me.$$.fragment,e),g(B.$$.fragment,e),g(xe.$$.fragment,e),g(Ze.$$.fragment,e),g(je.$$.fragment,e),g(_e.$$.fragment,e),g(V.$$.fragment,e),g(Le.$$.fragment,e),Ht=!1},d(e){e&&(n(m),n(T),n(p),n(v),n(h),n($),n(E),n(He),n(X),n(Ye),n(A),n(Se),n(R),n(Ne),n(H),n(Fe),n(Y),n(Pe),n(S),n(qe),n(Qe),n(ze),n(F),n(De),n(P),n(Ke),n(q),n(Oe),n(et),n(z),n(tt),n(D),n(nt),n(lt),n(K),n(at),n(st),n(ee),n(it),n(te),n(ot),n(ne),n(rt),n(le),n(mt),n(ut),n(dt),n(ie),n(ct),n(oe),n(pt),n(G),n(ht),n(ft),n(yt),n(ue),n(wt),n(de),n(bt),n(gt),n(pe),n(Mt),n(he),n(vt),n(Tt),n(ye),n($t),n(we),n(xt),n(be),n(Jt),n(Ut),n(Zt),n(ve),n(Ct),n(Te),n(jt),n(_t),n($e),n(Wt),n(Lt),n(Je),n(It),n(Ue),n(Gt),n(kt),n(Ce),n(Bt),n(Z),n(Vt),n(Et),n(Xt),n(We),n(At),n(Rt),n(Xe)),n(c),M(i,e),M(N,e),M(L,e),M(Q,e),M(I,e),M(O,e),M(ae,e),M(se,e),M(re),M(me,e),M(k,e),M(ce,e),M(fe,e),M(ge,e),M(Me,e),M(B,e),M(xe,e),M(Ze,e),M(je),M(_e,e),M(V,e),M(Le,e)}}}const Pn='{"title":"What are components in LlamaIndex?","local":"what-are-components-in-llamaindex","sections":[{"title":"Creating a RAG pipeline using components","local":"creating-a-rag-pipeline-using-components","sections":[{"title":"Loading and embedding documents","local":"loading-and-embedding-documents","sections":[],"depth":3},{"title":"Storing and indexing documents","local":"storing-and-indexing-documents","sections":[],"depth":3},{"title":"Querying a VectorStoreIndex with prompts and LLMs","local":"querying-a-vectorstoreindex-with-prompts-and-llms","sections":[],"depth":3},{"title":"Response Processing","local":"response-processing","sections":[],"depth":3},{"title":"Evaluation and observability","local":"evaluation-and-observability","sections":[],"depth":3}],"depth":2}],"depth":1}';function qn(U){return Bn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class tl extends Vn{constructor(c){super(),En(this,c,qn,Fn,kn,{})}}export{tl as component};
