import{s as yl,o as Tl}from"../chunks/scheduler.65852ee5.js";import{S as Jl,i as vl,g as i,s as a,r as o,A as Cl,h as m,f as l,c as s,j as wl,u as r,x as p,k as xl,y as cl,a as n,v as f,d as $,t as d,w as u,m as Ul,n as jl}from"../chunks/index.aa74147d.js";import{T as Ll}from"../chunks/Tip.bb8ccac8.js";import{D as Il,C as h}from"../chunks/DocNotebookDropdown.1a7e6a42.js";import{H as M,E as Gl}from"../chunks/getInferenceSnippets.a1cbc7e2.js";function Zl(je){let b;return{c(){b=Ul("LlamaIndex 默认的块大小是 1024 个字符，块与块之间有 20 个字符的重叠。如果需要了解更多细节，可以查看 [LlamaIndex 的文档](https://docs.llamaindex.ai/en/stable/optimizing/basic_strategies/basic_strategies.html#chunk-sizes)。")},l(g){b=jl(g,"LlamaIndex 默认的块大小是 1024 个字符，块与块之间有 20 个字符的重叠。如果需要了解更多细节，可以查看 [LlamaIndex 的文档](https://docs.llamaindex.ai/en/stable/optimizing/basic_strategies/basic_strategies.html#chunk-sizes)。")},m(g,x){n(g,b,x)},d(g){g&&l(b)}}}function _l(je){let b,g,x,Le,y,Ie,T,Ge,J,Ht='<em>作者: <a href="https://huggingface.co/jinnovation" rel="nofollow">Jonathan Jin</a></em>',Ze,v,_e,C,Vt=`这份教程将指导你如何快速为你的电子书库创建一个基于 RAG 图书助手。
就像图书馆的图书管理员帮你找书一样，这个助手也能帮你从你的电子书里找到你需要的书。`,ke,c,We,U,Rt="这个助手要做得<strong>轻巧</strong>，<strong>尽量在本地运行</strong>，而且<strong>不要用太多其他的东西</strong>。我们会尽量用免费的开源软件，选择那种在<strong>本地普通电脑上，比如 M1 型号的 MacBook 上就能运行的模型</strong>。",Be,j,Xe,L,At="我们的解决方案将包括以下组件：",He,I,Yt='<li><a href="https://docs.llamaindex.ai/en/stable/index.html" rel="nofollow">LlamaIndex</a>，一个基于LLM的应用数据框架，与 <a href="https://python.langchain.com/docs/get_started/introduction" rel="nofollow">LangChain</a> 不同，它是专门为 RAG 设计的；</li> <li><a href="https://ollama.com/" rel="nofollow">Ollama</a>，一个简单易用的工具，可以让你在本地运行语言模型，比如Llama 2；</li> <li><a href="https://huggingface.co/BAAI/bge-base-en-v1.5" rel="nofollow"><code>BAAI/bge-base-en-v1.5</code></a> 嵌入模型，它的表现<a href="https://huggingface.co/spaces/mteb/leaderboard" rel="nofollow">相当好，并且大小适中</a>；</li> <li><a href="https://ollama.com/library/llama2" rel="nofollow">Llama 2</a>，我们将通过 <a href="https://ollama.com/" rel="nofollow">Ollama</a> 运行它。</li>',Ve,G,Re,Z,Pt="首先安装依赖库",Ae,_,Ye,k,Pe,W,Se,B,St="我们接下来要弄个测试用的“书库”。",Qe,X,Qt="简单点说，我们的“书库”就是一个放有 <code>.epub</code> 格式电子书文件的<strong>文件夹</strong>。这个方法很容易就能扩展到像 Calibre 那种带有个 <code>metadata.db</code> 数据库文件的书库。怎么扩展这个问题，我们留给读者自己思考。😇",qe,H,qt='现在，我们先从<a href="https://www.gutenberg.org/" rel="nofollow">古腾堡计划网站</a>下载两本<code>.epub</code>格式的电子书放到我们的书库里。',Ee,V,Fe,R,ze,A,Et="使用 LlamaIndex 的 RAG 主要包括以下三个阶段：",Ne,Y,Ft="<li><strong>加载</strong>，在这个阶段你告诉 LlamaIndex 你的数据在哪里以及如何加载它；</li> <li><strong>索引</strong>，在这个阶段你扩充加载的数据以方便查询，例如使用向量嵌入；</li> <li><strong>查询</strong>，在这个阶段你配置一个 LLM 作为你索引数据的查询接口。</li>",De,P,zt='以上解释仅是对 LlamaIndex 可实现功能的表面说明。要想了解更多深入细节，我强烈推荐阅读 LlamaIndex 文档中的<a href="https://docs.llamaindex.ai/en/stable/getting_started/concepts.html" rel="nofollow">“高级概念”页面</a>。',Oe,S,Ke,Q,Nt="好的，我们首先从<strong>加载</strong>阶段开始。",et,q,Dt='之前提到，LlamaIndex 是专为 RAG 这种混合检索生成模型设计的。这一点从它的<a href="https://docs.llamaindex.ai/en/stable/module_guides/loading/simpledirectoryreader.html" rel="nofollow"><code>SimpleDirectoryReader</code></a>功能就可以明显看出，它能<strong>神奇地</strong>免费支持很多种文件类型。幸运的是， <code>.epub</code> 文件格式也在支持范围内。',tt,E,lt,F,Ot='<code>SimpleDirectoryReader.load_data()</code> 将我们的电子书转换成一组 LlamaIndex 可以处理的 <a href="https://docs.llamaindex.ai/en/stable/api/llama_index.core.schema.Document.html" rel="nofollow"><code>Document</code>s</a>。',nt,z,Kt="这里有一个重要的事情要注意，就是这个阶段的文档<strong>还没有被分块</strong>——这将在索引阶段进行。继续往下看…",at,N,st,D,el="在把数据<strong>加载</strong>进来之后，接下来我们要做的是<strong>建立索引</strong>。这样我们的 RAG 系统就能找到与用户查询相关的信息，然后把这些信息传给语言模型（LLM），以便它能够<strong>增强</strong>回答的内容。同时，这一步也将对文档进行分块。",it,O,tl=`在 LlamaIndex 中，<a href="https://docs.llamaindex.ai/en/stable/module_guides/indexing/vector_store_index.html" rel="nofollow"><code>VectorStoreIndex</code></a> 是用来建立索引的一个“默认”工具。这个工具默认使用一个简单、基于内存的字典来保存索引，但随着你的使用规模扩大，LlamaIndex 还支持
<a href="https://docs.llamaindex.ai/en/stable/module_guides/storing/vector_stores.html" rel="nofollow">多种向量存储解决方案</a>。`,mt,w,pt,K,ll='如前所述，我们选择使用 <a href="https://huggingface.co/BAAI/bge-base-en-v1.5" rel="nofollow"><code>BAAI/bge-small-en-v1.5</code></a> 生成嵌入，以避免使用默认的 OpenAI（特别是 gpt-3.5-turbo）模型，因为我们需要一个轻量级、可在本地运行的完整解决方案。',ot,ee,nl="幸运的是，LlamaIndex 可以通过 <code>HuggingFaceEmbedding</code> 类方便地从 Hugging Face 获取嵌入模型，因此我们将使用它。",rt,te,ft,le,al="我们将把这个模型传递给 <code>VectorStoreIndex</code>，作为我们的嵌入模型，以绕过 OpenAI 的默认行为。",$t,ne,dt,ae,ut,se,sl="现在我们要完成 RAG 智能助手的最后一部分——设置查询接口。",Mt,ie,il="在这个教程中，我们将使用 Llama 2 作为语言模型，但我建议你试试不同的模型，看看哪个能给出最好的回答。",bt,me,ml='首先，我们需要在一个新的终端窗口中启动 Ollama 服务器。不过，<a href="https://github.com/ollama/ollama-python" rel="nofollow">Ollama 的 Python 客户端</a>不支持直接启动和关闭服务器，所以我们需要在 Python 环境之外操作。',gt,pe,pl="打开一个新的终端窗口，输入命令：<code>ollama serve</code>。等我们这里操作完成后，别忘了关闭服务器！",ht,oe,ol="现在，让我们将 Llama 2 连接到 LlamaIndex，并使用它作为我们查询引擎的基础。",wt,re,xt,fe,yt,$e,rl="有了这些，我们的基本的 RAG 电子书库智能助手就设置好了，我们可以开始询问有关我们电子书库的问题了。例如：",Tt,de,Jt,ue,fl=`Based on the context provided, there are two books available:

1. "Pride and Prejudice" by Jane Austen
2. "Les Misérables" by Victor Hugo

The context used to derive this answer includes:

* The file path for each book, which provides information about the location of the book files on the computer.
* The titles of the books, which are mentioned in the context as being available for reading.
* A list of words associated with each book, such as "epub" and "notebooks", which provide additional information about the format and storage location of each book.
`,vt,Me,Ct,be,$l=`The main character of 'Pride and Prejudice' is Elizabeth Bennet.
`,ct,ge,Ut,he,dl="我们成功地展示了如何创建一个完全在本地运行的基本 RAG 的电子书库智能助手，甚至在苹果的 Apple silicon Macs 上也能运行。在这个过程中，我们还全面了解了 LlamaIndex 是如何帮助我们简化建立基于 RAG 的应用程序的。",jt,we,ul="尽管如此，我们其实只是接触到了一些皮毛。下面是一些关于如何改进和在这个基础上进一步发展的想法。",Lt,xe,It,ye,Ml="为了避免图书馆员的虚构响应，我们怎样才能要求它为其回答提供引用？",Gt,Te,Zt,Je,bl='像 <a href="https://calibre-ebook.com/" rel="nofollow">Calibre</a> 这样的电子书库管理工具会为电子书创建更多的元数据。这些元数据可以提供一些在书中文本里找不到的信息，比如出版商或版本。我们怎样才能扩展我们的 RAG 流程，使其也能利用那些不是 .epub 文件的额外信息源呢？',_t,ve,kt,Ce,gl="如果我们把这里做的所有东西写成一个脚本或可执行程序，那么每次运行这个脚本时，它都会重新索引我们的图书馆。对于只有两个文件的微型测试库来说，这样还行，但对于稍大一点的图书馆来说，每次都重新索引会让用户感到非常烦恼。我们怎样才能让索引持久化，并且只在图书馆内容有重要变化时，比如添加了新书，才去更新索引呢？",Wt,ce,Bt,Ue,Xt;return y=new Il({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/cookbook/blob/main/notebooks/zh-CN/rag_llamaindex_librarian.ipynb"}]}}),T=new M({props:{title:"用 LlamaIndex 构建一个 RAG 电子书库智能助手",local:"用-llamaindex-构建一个-rag-电子书库智能助手",headingTag:"h1"}}),v=new M({props:{title:"简介",local:"简介",headingTag:"h2"}}),c=new M({props:{title:"要求",local:"要求",headingTag:"h2"}}),j=new M({props:{title:"组件",local:"组件",headingTag:"h2"}}),G=new M({props:{title:"依赖",local:"依赖",headingTag:"h2"}}),_=new h({props:{code:"JTI1cGlwJTIwaW5zdGFsbCUyMC1xJTIwJTVDJTBBJTIwJTIwJTIwJTIwbGxhbWEtaW5kZXglMjAlNUMlMEElMjAlMjAlMjAlMjBFYm9va0xpYiUyMCU1QyUwQSUyMCUyMCUyMCUyMGh0bWwydGV4dCUyMCU1QyUwQSUyMCUyMCUyMCUyMGxsYW1hLWluZGV4LWVtYmVkZGluZ3MtaHVnZ2luZ2ZhY2UlMjAlNUMlMEElMjAlMjAlMjAlMjBsbGFtYS1pbmRleC1sbG1zLW9sbGFtYQ==",highlighted:`%pip install -q \\
    llama-index \\
    EbookLib \\
    html2text \\
    llama-index-embeddings-huggingface \\
    llama-index-llms-ollama`,wrap:!1}}),k=new h({props:{code:"IWJyZXclMjBpbnN0YWxsJTIwb2xsYW1h",highlighted:"!brew install ollama",wrap:!1}}),W=new M({props:{title:"设置测试书库",local:"设置测试书库",headingTag:"h2"}}),V=new h({props:{code:"IW1rZGlyJTIwLXAlMjAlMjIudGVzdCUyRmxpYnJhcnklMkZqYW5lLWF1c3RlbiUyMiUwQSFta2RpciUyMC1wJTIwJTIyLnRlc3QlMkZsaWJyYXJ5JTJGdmljdG9yLWh1Z28lMjIlMEEhd2dldCUyMGh0dHBzJTNBJTJGJTJGd3d3Lmd1dGVuYmVyZy5vcmclMkZlYm9va3MlMkYxMzQyLmVwdWIubm9pbWFnZXMlMjAtTyUyMCUyMi50ZXN0JTJGbGlicmFyeSUyRmphbmUtYXVzdGVuJTJGcHJpZGUtYW5kLXByZWp1ZGljZS5lcHViJTIyJTBBIXdnZXQlMjBodHRwcyUzQSUyRiUyRnd3dy5ndXRlbmJlcmcub3JnJTJGZWJvb2tzJTJGMTM1LmVwdWIubm9pbWFnZXMlMjAtTyUyMCUyMi50ZXN0JTJGbGlicmFyeSUyRnZpY3Rvci1odWdvJTJGbGVzLW1pc2VyYWJsZXMuZXB1YiUyMg==",highlighted:`!mkdir -p <span class="hljs-string">&quot;.test/library/jane-austen&quot;</span>
!mkdir -p <span class="hljs-string">&quot;.test/library/victor-hugo&quot;</span>
!wget https://www.gutenberg.org/ebooks/<span class="hljs-number">1342.</span>epub.noimages -O <span class="hljs-string">&quot;.test/library/jane-austen/pride-and-prejudice.epub&quot;</span>
!wget https://www.gutenberg.org/ebooks/<span class="hljs-number">135.</span>epub.noimages -O <span class="hljs-string">&quot;.test/library/victor-hugo/les-miserables.epub&quot;</span>`,wrap:!1}}),R=new M({props:{title:"用 LlamaIndex 构建 RAG",local:"用-llamaindex-构建-rag",headingTag:"h2"}}),S=new M({props:{title:"加载",local:"加载",headingTag:"h3"}}),E=new h({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUlMjBpbXBvcnQlMjBTaW1wbGVEaXJlY3RvcnlSZWFkZXIlMEElMEFsb2FkZXIlMjAlM0QlMjBTaW1wbGVEaXJlY3RvcnlSZWFkZXIoJTBBJTIwJTIwJTIwJTIwaW5wdXRfZGlyJTNEJTIyLiUyRi50ZXN0JTJGJTIyJTJDJTBBJTIwJTIwJTIwJTIwcmVjdXJzaXZlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHJlcXVpcmVkX2V4dHMlM0QlNUIlMjIuZXB1YiUyMiU1RCUyQyUwQSklMEElMEFkb2N1bWVudHMlMjAlM0QlMjBsb2FkZXIubG9hZF9kYXRhKCk=",highlighted:`<span class="hljs-keyword">from</span> llama_index.core <span class="hljs-keyword">import</span> SimpleDirectoryReader

loader = SimpleDirectoryReader(
    input_dir=<span class="hljs-string">&quot;./.test/&quot;</span>,
    recursive=<span class="hljs-literal">True</span>,
    required_exts=[<span class="hljs-string">&quot;.epub&quot;</span>],
)

documents = loader.load_data()`,wrap:!1}}),N=new M({props:{title:"索引",local:"索引",headingTag:"h3"}}),w=new Ll({props:{$$slots:{default:[Zl]},$$scope:{ctx:je}}}),te=new h({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmVtYmVkZGluZ3MuaHVnZ2luZ2ZhY2UlMjBpbXBvcnQlMjBIdWdnaW5nRmFjZUVtYmVkZGluZyUwQSUwQWVtYmVkZGluZ19tb2RlbCUyMCUzRCUyMEh1Z2dpbmdGYWNlRW1iZWRkaW5nKG1vZGVsX25hbWUlM0QlMjJCQUFJJTJGYmdlLXNtYWxsLWVuLXYxLjUlMjIp",highlighted:`<span class="hljs-keyword">from</span> llama_index.embeddings.huggingface <span class="hljs-keyword">import</span> HuggingFaceEmbedding

embedding_model = HuggingFaceEmbedding(model_name=<span class="hljs-string">&quot;BAAI/bge-small-en-v1.5&quot;</span>)`,wrap:!1}}),ne=new h({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUlMjBpbXBvcnQlMjBWZWN0b3JTdG9yZUluZGV4JTBBJTBBaW5kZXglMjAlM0QlMjBWZWN0b3JTdG9yZUluZGV4LmZyb21fZG9jdW1lbnRzKCUwQSUyMCUyMCUyMCUyMGRvY3VtZW50cyUyQyUwQSUyMCUyMCUyMCUyMGVtYmVkX21vZGVsJTNEZW1iZWRkaW5nX21vZGVsJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> llama_index.core <span class="hljs-keyword">import</span> VectorStoreIndex

index = VectorStoreIndex.from_documents(
    documents,
    embed_model=embedding_model,
)`,wrap:!1}}),ae=new M({props:{title:"查询",local:"查询",headingTag:"h3"}}),re=new h({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmxsbXMub2xsYW1hJTIwaW1wb3J0JTIwT2xsYW1hJTBBJTBBbGxhbWElMjAlM0QlMjBPbGxhbWEoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJsbGFtYTIlMjIlMkMlMEElMjAlMjAlMjAlMjByZXF1ZXN0X3RpbWVvdXQlM0Q0MC4wJTJDJTBBKSUwQSUwQXF1ZXJ5X2VuZ2luZSUyMCUzRCUyMGluZGV4LmFzX3F1ZXJ5X2VuZ2luZShsbG0lM0RsbGFtYSk=",highlighted:`<span class="hljs-keyword">from</span> llama_index.llms.ollama <span class="hljs-keyword">import</span> Ollama

llama = Ollama(
    model=<span class="hljs-string">&quot;llama2&quot;</span>,
    request_timeout=<span class="hljs-number">40.0</span>,
)

query_engine = index.as_query_engine(llm=llama)`,wrap:!1}}),fe=new M({props:{title:"最终结果",local:"最终结果",headingTag:"h2"}}),de=new h({props:{code:"cHJpbnQoJTBBJTIwJTIwJTIwJTIwcXVlcnlfZW5naW5lLnF1ZXJ5KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMldoYXQlMjBhcmUlMjB0aGUlMjB0aXRsZXMlMjBvZiUyMGFsbCUyMHRoZSUyMGJvb2tzJTIwYXZhaWxhYmxlJTNGJTIwU2hvdyUyMG1lJTIwdGhlJTIwY29udGV4dCUyMHVzZWQlMjB0byUyMGRlcml2ZSUyMHlvdXIlMjBhbnN3ZXIuJTIyJTBBJTIwJTIwJTIwJTIwKSUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(
<span class="hljs-meta">... </span>    query_engine.query(
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;What are the titles of all the books available? Show me the context used to derive your answer.&quot;</span>
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>)`,wrap:!1}}),Me=new h({props:{code:"cHJpbnQocXVlcnlfZW5naW5lLnF1ZXJ5KCUyMldobyUyMGlzJTIwdGhlJTIwbWFpbiUyMGNoYXJhY3RlciUyMG9mJTIwJ1ByaWRlJTIwYW5kJTIwUHJlanVkaWNlJyUzRiUyMikp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(query_engine.query(<span class="hljs-string">&quot;Who is the main character of &#x27;Pride and Prejudice&#x27;?&quot;</span>))',wrap:!1}}),ge=new M({props:{title:"总结和未来可能的提升",local:"总结和未来可能的提升",headingTag:"h2"}}),xe=new M({props:{title:"强制引用",local:"强制引用",headingTag:"h3"}}),Te=new M({props:{title:"使用扩充的元数据",local:"使用扩充的元数据",headingTag:"h3"}}),ve=new M({props:{title:"高效索引",local:"高效索引",headingTag:"h3"}}),ce=new Gl({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/zh-CN/rag_llamaindex_librarian.md"}}),{c(){b=i("meta"),g=a(),x=i("p"),Le=a(),o(y.$$.fragment),Ie=a(),o(T.$$.fragment),Ge=a(),J=i("p"),J.innerHTML=Ht,Ze=a(),o(v.$$.fragment),_e=a(),C=i("p"),C.textContent=Vt,ke=a(),o(c.$$.fragment),We=a(),U=i("p"),U.innerHTML=Rt,Be=a(),o(j.$$.fragment),Xe=a(),L=i("p"),L.textContent=At,He=a(),I=i("ul"),I.innerHTML=Yt,Ve=a(),o(G.$$.fragment),Re=a(),Z=i("p"),Z.textContent=Pt,Ae=a(),o(_.$$.fragment),Ye=a(),o(k.$$.fragment),Pe=a(),o(W.$$.fragment),Se=a(),B=i("p"),B.textContent=St,Qe=a(),X=i("p"),X.innerHTML=Qt,qe=a(),H=i("p"),H.innerHTML=qt,Ee=a(),o(V.$$.fragment),Fe=a(),o(R.$$.fragment),ze=a(),A=i("p"),A.textContent=Et,Ne=a(),Y=i("ol"),Y.innerHTML=Ft,De=a(),P=i("p"),P.innerHTML=zt,Oe=a(),o(S.$$.fragment),Ke=a(),Q=i("p"),Q.innerHTML=Nt,et=a(),q=i("p"),q.innerHTML=Dt,tt=a(),o(E.$$.fragment),lt=a(),F=i("p"),F.innerHTML=Ot,nt=a(),z=i("p"),z.innerHTML=Kt,at=a(),o(N.$$.fragment),st=a(),D=i("p"),D.innerHTML=el,it=a(),O=i("p"),O.innerHTML=tl,mt=a(),o(w.$$.fragment),pt=a(),K=i("p"),K.innerHTML=ll,ot=a(),ee=i("p"),ee.innerHTML=nl,rt=a(),o(te.$$.fragment),ft=a(),le=i("p"),le.innerHTML=al,$t=a(),o(ne.$$.fragment),dt=a(),o(ae.$$.fragment),ut=a(),se=i("p"),se.textContent=sl,Mt=a(),ie=i("p"),ie.textContent=il,bt=a(),me=i("p"),me.innerHTML=ml,gt=a(),pe=i("p"),pe.innerHTML=pl,ht=a(),oe=i("p"),oe.textContent=ol,wt=a(),o(re.$$.fragment),xt=a(),o(fe.$$.fragment),yt=a(),$e=i("p"),$e.textContent=rl,Tt=a(),o(de.$$.fragment),Jt=a(),ue=i("pre"),ue.textContent=fl,vt=a(),o(Me.$$.fragment),Ct=a(),be=i("pre"),be.textContent=$l,ct=a(),o(ge.$$.fragment),Ut=a(),he=i("p"),he.textContent=dl,jt=a(),we=i("p"),we.textContent=ul,Lt=a(),o(xe.$$.fragment),It=a(),ye=i("p"),ye.textContent=Ml,Gt=a(),o(Te.$$.fragment),Zt=a(),Je=i("p"),Je.innerHTML=bl,_t=a(),o(ve.$$.fragment),kt=a(),Ce=i("p"),Ce.textContent=gl,Wt=a(),o(ce.$$.fragment),Bt=a(),Ue=i("p"),this.h()},l(e){const t=Cl("svelte-u9bgzb",document.head);b=m(t,"META",{name:!0,content:!0}),t.forEach(l),g=s(e),x=m(e,"P",{}),wl(x).forEach(l),Le=s(e),r(y.$$.fragment,e),Ie=s(e),r(T.$$.fragment,e),Ge=s(e),J=m(e,"P",{"data-svelte-h":!0}),p(J)!=="svelte-1fxggfq"&&(J.innerHTML=Ht),Ze=s(e),r(v.$$.fragment,e),_e=s(e),C=m(e,"P",{"data-svelte-h":!0}),p(C)!=="svelte-t7vqnu"&&(C.textContent=Vt),ke=s(e),r(c.$$.fragment,e),We=s(e),U=m(e,"P",{"data-svelte-h":!0}),p(U)!=="svelte-181ybcs"&&(U.innerHTML=Rt),Be=s(e),r(j.$$.fragment,e),Xe=s(e),L=m(e,"P",{"data-svelte-h":!0}),p(L)!=="svelte-31j3g1"&&(L.textContent=At),He=s(e),I=m(e,"UL",{"data-svelte-h":!0}),p(I)!=="svelte-tc6qwv"&&(I.innerHTML=Yt),Ve=s(e),r(G.$$.fragment,e),Re=s(e),Z=m(e,"P",{"data-svelte-h":!0}),p(Z)!=="svelte-1yop8fk"&&(Z.textContent=Pt),Ae=s(e),r(_.$$.fragment,e),Ye=s(e),r(k.$$.fragment,e),Pe=s(e),r(W.$$.fragment,e),Se=s(e),B=m(e,"P",{"data-svelte-h":!0}),p(B)!=="svelte-bgqcan"&&(B.textContent=St),Qe=s(e),X=m(e,"P",{"data-svelte-h":!0}),p(X)!=="svelte-qr3d2u"&&(X.innerHTML=Qt),qe=s(e),H=m(e,"P",{"data-svelte-h":!0}),p(H)!=="svelte-qsdbu3"&&(H.innerHTML=qt),Ee=s(e),r(V.$$.fragment,e),Fe=s(e),r(R.$$.fragment,e),ze=s(e),A=m(e,"P",{"data-svelte-h":!0}),p(A)!=="svelte-1vf385b"&&(A.textContent=Et),Ne=s(e),Y=m(e,"OL",{"data-svelte-h":!0}),p(Y)!=="svelte-13qt93n"&&(Y.innerHTML=Ft),De=s(e),P=m(e,"P",{"data-svelte-h":!0}),p(P)!=="svelte-1bhq17n"&&(P.innerHTML=zt),Oe=s(e),r(S.$$.fragment,e),Ke=s(e),Q=m(e,"P",{"data-svelte-h":!0}),p(Q)!=="svelte-wlzo9w"&&(Q.innerHTML=Nt),et=s(e),q=m(e,"P",{"data-svelte-h":!0}),p(q)!=="svelte-1pf4mk1"&&(q.innerHTML=Dt),tt=s(e),r(E.$$.fragment,e),lt=s(e),F=m(e,"P",{"data-svelte-h":!0}),p(F)!=="svelte-1ds1k09"&&(F.innerHTML=Ot),nt=s(e),z=m(e,"P",{"data-svelte-h":!0}),p(z)!=="svelte-1g3ei9p"&&(z.innerHTML=Kt),at=s(e),r(N.$$.fragment,e),st=s(e),D=m(e,"P",{"data-svelte-h":!0}),p(D)!=="svelte-1ljw3zw"&&(D.innerHTML=el),it=s(e),O=m(e,"P",{"data-svelte-h":!0}),p(O)!=="svelte-1277j1h"&&(O.innerHTML=tl),mt=s(e),r(w.$$.fragment,e),pt=s(e),K=m(e,"P",{"data-svelte-h":!0}),p(K)!=="svelte-16otklm"&&(K.innerHTML=ll),ot=s(e),ee=m(e,"P",{"data-svelte-h":!0}),p(ee)!=="svelte-m191gf"&&(ee.innerHTML=nl),rt=s(e),r(te.$$.fragment,e),ft=s(e),le=m(e,"P",{"data-svelte-h":!0}),p(le)!=="svelte-j2nhc9"&&(le.innerHTML=al),$t=s(e),r(ne.$$.fragment,e),dt=s(e),r(ae.$$.fragment,e),ut=s(e),se=m(e,"P",{"data-svelte-h":!0}),p(se)!=="svelte-1uj4qna"&&(se.textContent=sl),Mt=s(e),ie=m(e,"P",{"data-svelte-h":!0}),p(ie)!=="svelte-9fzwy5"&&(ie.textContent=il),bt=s(e),me=m(e,"P",{"data-svelte-h":!0}),p(me)!=="svelte-egg81c"&&(me.innerHTML=ml),gt=s(e),pe=m(e,"P",{"data-svelte-h":!0}),p(pe)!=="svelte-nrvcvb"&&(pe.innerHTML=pl),ht=s(e),oe=m(e,"P",{"data-svelte-h":!0}),p(oe)!=="svelte-2yfztk"&&(oe.textContent=ol),wt=s(e),r(re.$$.fragment,e),xt=s(e),r(fe.$$.fragment,e),yt=s(e),$e=m(e,"P",{"data-svelte-h":!0}),p($e)!=="svelte-3apvjl"&&($e.textContent=rl),Tt=s(e),r(de.$$.fragment,e),Jt=s(e),ue=m(e,"PRE",{"data-svelte-h":!0}),p(ue)!=="svelte-czhhw9"&&(ue.textContent=fl),vt=s(e),r(Me.$$.fragment,e),Ct=s(e),be=m(e,"PRE",{"data-svelte-h":!0}),p(be)!=="svelte-13j10yu"&&(be.textContent=$l),ct=s(e),r(ge.$$.fragment,e),Ut=s(e),he=m(e,"P",{"data-svelte-h":!0}),p(he)!=="svelte-1g80xm3"&&(he.textContent=dl),jt=s(e),we=m(e,"P",{"data-svelte-h":!0}),p(we)!=="svelte-fbi3xx"&&(we.textContent=ul),Lt=s(e),r(xe.$$.fragment,e),It=s(e),ye=m(e,"P",{"data-svelte-h":!0}),p(ye)!=="svelte-onk5ks"&&(ye.textContent=Ml),Gt=s(e),r(Te.$$.fragment,e),Zt=s(e),Je=m(e,"P",{"data-svelte-h":!0}),p(Je)!=="svelte-1yn6jew"&&(Je.innerHTML=bl),_t=s(e),r(ve.$$.fragment,e),kt=s(e),Ce=m(e,"P",{"data-svelte-h":!0}),p(Ce)!=="svelte-tjr3o1"&&(Ce.textContent=gl),Wt=s(e),r(ce.$$.fragment,e),Bt=s(e),Ue=m(e,"P",{}),wl(Ue).forEach(l),this.h()},h(){xl(b,"name","hf:doc:metadata"),xl(b,"content",kl)},m(e,t){cl(document.head,b),n(e,g,t),n(e,x,t),n(e,Le,t),f(y,e,t),n(e,Ie,t),f(T,e,t),n(e,Ge,t),n(e,J,t),n(e,Ze,t),f(v,e,t),n(e,_e,t),n(e,C,t),n(e,ke,t),f(c,e,t),n(e,We,t),n(e,U,t),n(e,Be,t),f(j,e,t),n(e,Xe,t),n(e,L,t),n(e,He,t),n(e,I,t),n(e,Ve,t),f(G,e,t),n(e,Re,t),n(e,Z,t),n(e,Ae,t),f(_,e,t),n(e,Ye,t),f(k,e,t),n(e,Pe,t),f(W,e,t),n(e,Se,t),n(e,B,t),n(e,Qe,t),n(e,X,t),n(e,qe,t),n(e,H,t),n(e,Ee,t),f(V,e,t),n(e,Fe,t),f(R,e,t),n(e,ze,t),n(e,A,t),n(e,Ne,t),n(e,Y,t),n(e,De,t),n(e,P,t),n(e,Oe,t),f(S,e,t),n(e,Ke,t),n(e,Q,t),n(e,et,t),n(e,q,t),n(e,tt,t),f(E,e,t),n(e,lt,t),n(e,F,t),n(e,nt,t),n(e,z,t),n(e,at,t),f(N,e,t),n(e,st,t),n(e,D,t),n(e,it,t),n(e,O,t),n(e,mt,t),f(w,e,t),n(e,pt,t),n(e,K,t),n(e,ot,t),n(e,ee,t),n(e,rt,t),f(te,e,t),n(e,ft,t),n(e,le,t),n(e,$t,t),f(ne,e,t),n(e,dt,t),f(ae,e,t),n(e,ut,t),n(e,se,t),n(e,Mt,t),n(e,ie,t),n(e,bt,t),n(e,me,t),n(e,gt,t),n(e,pe,t),n(e,ht,t),n(e,oe,t),n(e,wt,t),f(re,e,t),n(e,xt,t),f(fe,e,t),n(e,yt,t),n(e,$e,t),n(e,Tt,t),f(de,e,t),n(e,Jt,t),n(e,ue,t),n(e,vt,t),f(Me,e,t),n(e,Ct,t),n(e,be,t),n(e,ct,t),f(ge,e,t),n(e,Ut,t),n(e,he,t),n(e,jt,t),n(e,we,t),n(e,Lt,t),f(xe,e,t),n(e,It,t),n(e,ye,t),n(e,Gt,t),f(Te,e,t),n(e,Zt,t),n(e,Je,t),n(e,_t,t),f(ve,e,t),n(e,kt,t),n(e,Ce,t),n(e,Wt,t),f(ce,e,t),n(e,Bt,t),n(e,Ue,t),Xt=!0},p(e,[t]){const hl={};t&2&&(hl.$$scope={dirty:t,ctx:e}),w.$set(hl)},i(e){Xt||($(y.$$.fragment,e),$(T.$$.fragment,e),$(v.$$.fragment,e),$(c.$$.fragment,e),$(j.$$.fragment,e),$(G.$$.fragment,e),$(_.$$.fragment,e),$(k.$$.fragment,e),$(W.$$.fragment,e),$(V.$$.fragment,e),$(R.$$.fragment,e),$(S.$$.fragment,e),$(E.$$.fragment,e),$(N.$$.fragment,e),$(w.$$.fragment,e),$(te.$$.fragment,e),$(ne.$$.fragment,e),$(ae.$$.fragment,e),$(re.$$.fragment,e),$(fe.$$.fragment,e),$(de.$$.fragment,e),$(Me.$$.fragment,e),$(ge.$$.fragment,e),$(xe.$$.fragment,e),$(Te.$$.fragment,e),$(ve.$$.fragment,e),$(ce.$$.fragment,e),Xt=!0)},o(e){d(y.$$.fragment,e),d(T.$$.fragment,e),d(v.$$.fragment,e),d(c.$$.fragment,e),d(j.$$.fragment,e),d(G.$$.fragment,e),d(_.$$.fragment,e),d(k.$$.fragment,e),d(W.$$.fragment,e),d(V.$$.fragment,e),d(R.$$.fragment,e),d(S.$$.fragment,e),d(E.$$.fragment,e),d(N.$$.fragment,e),d(w.$$.fragment,e),d(te.$$.fragment,e),d(ne.$$.fragment,e),d(ae.$$.fragment,e),d(re.$$.fragment,e),d(fe.$$.fragment,e),d(de.$$.fragment,e),d(Me.$$.fragment,e),d(ge.$$.fragment,e),d(xe.$$.fragment,e),d(Te.$$.fragment,e),d(ve.$$.fragment,e),d(ce.$$.fragment,e),Xt=!1},d(e){e&&(l(g),l(x),l(Le),l(Ie),l(Ge),l(J),l(Ze),l(_e),l(C),l(ke),l(We),l(U),l(Be),l(Xe),l(L),l(He),l(I),l(Ve),l(Re),l(Z),l(Ae),l(Ye),l(Pe),l(Se),l(B),l(Qe),l(X),l(qe),l(H),l(Ee),l(Fe),l(ze),l(A),l(Ne),l(Y),l(De),l(P),l(Oe),l(Ke),l(Q),l(et),l(q),l(tt),l(lt),l(F),l(nt),l(z),l(at),l(st),l(D),l(it),l(O),l(mt),l(pt),l(K),l(ot),l(ee),l(rt),l(ft),l(le),l($t),l(dt),l(ut),l(se),l(Mt),l(ie),l(bt),l(me),l(gt),l(pe),l(ht),l(oe),l(wt),l(xt),l(yt),l($e),l(Tt),l(Jt),l(ue),l(vt),l(Ct),l(be),l(ct),l(Ut),l(he),l(jt),l(we),l(Lt),l(It),l(ye),l(Gt),l(Zt),l(Je),l(_t),l(kt),l(Ce),l(Wt),l(Bt),l(Ue)),l(b),u(y,e),u(T,e),u(v,e),u(c,e),u(j,e),u(G,e),u(_,e),u(k,e),u(W,e),u(V,e),u(R,e),u(S,e),u(E,e),u(N,e),u(w,e),u(te,e),u(ne,e),u(ae,e),u(re,e),u(fe,e),u(de,e),u(Me,e),u(ge,e),u(xe,e),u(Te,e),u(ve,e),u(ce,e)}}}const kl='{"title":"用 LlamaIndex 构建一个 RAG 电子书库智能助手","local":"用-llamaindex-构建一个-rag-电子书库智能助手","sections":[{"title":"简介","local":"简介","sections":[],"depth":2},{"title":"要求","local":"要求","sections":[],"depth":2},{"title":"组件","local":"组件","sections":[],"depth":2},{"title":"依赖","local":"依赖","sections":[],"depth":2},{"title":"设置测试书库","local":"设置测试书库","sections":[],"depth":2},{"title":"用 LlamaIndex 构建 RAG","local":"用-llamaindex-构建-rag","sections":[{"title":"加载","local":"加载","sections":[],"depth":3},{"title":"索引","local":"索引","sections":[],"depth":3},{"title":"查询","local":"查询","sections":[],"depth":3}],"depth":2},{"title":"最终结果","local":"最终结果","sections":[],"depth":2},{"title":"总结和未来可能的提升","local":"总结和未来可能的提升","sections":[{"title":"强制引用","local":"强制引用","sections":[],"depth":3},{"title":"使用扩充的元数据","local":"使用扩充的元数据","sections":[],"depth":3},{"title":"高效索引","local":"高效索引","sections":[],"depth":3}],"depth":2}],"depth":1}';function Wl(je){return Tl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Al extends Jl{constructor(b){super(),vl(this,b,Wl,_l,yl,{})}}export{Al as component};
