import{s as cl,b as Cl,u as _l,g as Ll,d as Ul,o as jl}from"../chunks/scheduler.1f027d5a.js";import{S as vl,i as Jl,e as i,a as m,f as At,d as l,k as Rt,m as n,t as o,o as r,s as a,c as $,h as Gl,b as s,g as u,j as p,l as Zl,n as d,p as g,r as Il,u as kl}from"../chunks/index.6117a65d.js";import{C as Wl}from"../chunks/CopyLLMTxtMenu.610b106b.js";import{D as Xl,C as v}from"../chunks/DocNotebookDropdown.4ae0d470.js";import{H as y,E as Bl}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.bd18ae98.js";function Hl(T){let f,h,w;const c=T[2].default,M=Cl(c,T,T[1],null);return{c(){f=i("blockquote"),M&&M.c(),this.h()},l(b){f=m(b,"BLOCKQUOTE",{class:!0});var x=At(f);M&&M.l(x),x.forEach(l),this.h()},h(){Rt(f,"class",h=T[0]?"warning":"tip")},m(b,x){n(b,f,x),M&&M.m(f,null),w=!0},p(b,[x]){M&&M.p&&(!w||x&2)&&_l(M,c,b,b[1],w?Ul(c,b[1],x,null):Ll(b[1]),null),(!w||x&1&&h!==(h=b[0]?"warning":"tip"))&&Rt(f,"class",h)},i(b){w||(o(M,b),w=!0)},o(b){r(M,b),w=!1},d(b){b&&l(f),M&&M.d(b)}}}function Vl(T,f,h){let{$$slots:w={},$$scope:c}=f,{warning:M=!1}=f;return T.$$set=b=>{"warning"in b&&h(0,M=b.warning),"$$scope"in b&&h(1,c=b.$$scope)},[M,c,w]}class Rl extends vl{constructor(f){super(),Jl(this,f,Vl,Hl,cl,{warning:0})}}function Al(T){let f;return{c(){f=Il("LlamaIndex 默认的块大小是 1024 个字符，块与块之间有 20 个字符的重叠。如果需要了解更多细节，可以查看 [LlamaIndex 的文档](https://docs.llamaindex.ai/en/stable/optimizing/basic_strategies/basic_strategies.html#chunk-sizes)。")},l(h){f=kl(h,"LlamaIndex 默认的块大小是 1024 个字符，块与块之间有 20 个字符的重叠。如果需要了解更多细节，可以查看 [LlamaIndex 的文档](https://docs.llamaindex.ai/en/stable/optimizing/basic_strategies/basic_strategies.html#chunk-sizes)。")},m(h,w){n(h,f,w)},d(h){h&&l(f)}}}function Yl(T){let f,h,w,c,M,b,x,Ze,C,Ie,_,Yt='<em>作者: <a href="https://huggingface.co/jinnovation" rel="nofollow">Jonathan Jin</a></em>',ke,L,We,U,Pt=`这份教程将指导你如何快速为你的电子书库创建一个基于 RAG 图书助手。
就像图书馆的图书管理员帮你找书一样，这个助手也能帮你从你的电子书里找到你需要的书。`,Xe,j,Be,G,qt="这个助手要做得<strong>轻巧</strong>，<strong>尽量在本地运行</strong>，而且<strong>不要用太多其他的东西</strong>。我们会尽量用免费的开源软件，选择那种在<strong>本地普通电脑上，比如 M1 型号的 MacBook 上就能运行的模型</strong>。",He,Z,Ve,I,St="我们的解决方案将包括以下组件：",Re,k,Qt='<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>',Ae,W,Ye,X,Et="首先安装依赖库",Pe,B,qe,H,Se,V,Qe,R,zt="我们接下来要弄个测试用的“书库”。",Ee,A,Ft="简单点说，我们的“书库”就是一个放有 <code>.epub</code> 格式电子书文件的<strong>文件夹</strong>。这个方法很容易就能扩展到像 Calibre 那种带有个 <code>metadata.db</code> 数据库文件的书库。怎么扩展这个问题，我们留给读者自己思考。😇",ze,Y,Nt='现在，我们先从<a href="https://www.gutenberg.org/" rel="nofollow">古腾堡计划网站</a>下载两本<code>.epub</code>格式的电子书放到我们的书库里。',Fe,P,Ne,q,Oe,S,Ot="使用 LlamaIndex 的 RAG 主要包括以下三个阶段：",De,Q,Dt="<li><strong>加载</strong>，在这个阶段你告诉 LlamaIndex 你的数据在哪里以及如何加载它；</li> <li><strong>索引</strong>，在这个阶段你扩充加载的数据以方便查询，例如使用向量嵌入；</li> <li><strong>查询</strong>，在这个阶段你配置一个 LLM 作为你索引数据的查询接口。</li>",Ke,E,Kt='以上解释仅是对 LlamaIndex 可实现功能的表面说明。要想了解更多深入细节，我强烈推荐阅读 LlamaIndex 文档中的<a href="https://docs.llamaindex.ai/en/stable/getting_started/concepts.html" rel="nofollow">“高级概念”页面</a>。',et,z,tt,F,el="好的，我们首先从<strong>加载</strong>阶段开始。",lt,N,tl='之前提到，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> 文件格式也在支持范围内。',nt,O,at,D,ll='<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>。',st,K,nl="这里有一个重要的事情要注意，就是这个阶段的文档<strong>还没有被分块</strong>——这将在索引阶段进行。继续往下看…",it,ee,mt,te,al="在把数据<strong>加载</strong>进来之后，接下来我们要做的是<strong>建立索引</strong>。这样我们的 RAG 系统就能找到与用户查询相关的信息，然后把这些信息传给语言模型（LLM），以便它能够<strong>增强</strong>回答的内容。同时，这一步也将对文档进行分块。",pt,le,sl=`在 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>。`,ot,J,rt,ne,il='如前所述，我们选择使用 <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）模型，因为我们需要一个轻量级、可在本地运行的完整解决方案。',ft,ae,ml="幸运的是，LlamaIndex 可以通过 <code>HuggingFaceEmbedding</code> 类方便地从 Hugging Face 获取嵌入模型，因此我们将使用它。",$t,se,ut,ie,pl="我们将把这个模型传递给 <code>VectorStoreIndex</code>，作为我们的嵌入模型，以绕过 OpenAI 的默认行为。",dt,me,gt,pe,bt,oe,ol="现在我们要完成 RAG 智能助手的最后一部分——设置查询接口。",Mt,re,rl="在这个教程中，我们将使用 Llama 2 作为语言模型，但我建议你试试不同的模型，看看哪个能给出最好的回答。",ht,fe,fl='首先，我们需要在一个新的终端窗口中启动 Ollama 服务器。不过，<a href="https://github.com/ollama/ollama-python" rel="nofollow">Ollama 的 Python 客户端</a>不支持直接启动和关闭服务器，所以我们需要在 Python 环境之外操作。',wt,$e,$l="打开一个新的终端窗口，输入命令：<code>ollama serve</code>。等我们这里操作完成后，别忘了关闭服务器！",xt,ue,ul="现在，让我们将 Llama 2 连接到 LlamaIndex，并使用它作为我们查询引擎的基础。",yt,de,Tt,ge,ct,be,dl="有了这些，我们的基本的 RAG 电子书库智能助手就设置好了，我们可以开始询问有关我们电子书库的问题了。例如：",vt,Me,Jt,he,gl=`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.
`,Ct,we,_t,xe,bl=`The main character of 'Pride and Prejudice' is Elizabeth Bennet.
`,Lt,ye,Ut,Te,Ml="我们成功地展示了如何创建一个完全在本地运行的基本 RAG 的电子书库智能助手，甚至在苹果的 Apple silicon Macs 上也能运行。在这个过程中，我们还全面了解了 LlamaIndex 是如何帮助我们简化建立基于 RAG 的应用程序的。",jt,ce,hl="尽管如此，我们其实只是接触到了一些皮毛。下面是一些关于如何改进和在这个基础上进一步发展的想法。",Gt,ve,Zt,Je,wl="为了避免图书馆员的虚构响应，我们怎样才能要求它为其回答提供引用？",It,Ce,kt,_e,xl='像 <a href="https://calibre-ebook.com/" rel="nofollow">Calibre</a> 这样的电子书库管理工具会为电子书创建更多的元数据。这些元数据可以提供一些在书中文本里找不到的信息，比如出版商或版本。我们怎样才能扩展我们的 RAG 流程，使其也能利用那些不是 .epub 文件的额外信息源呢？',Wt,Le,Xt,Ue,yl="如果我们把这里做的所有东西写成一个脚本或可执行程序，那么每次运行这个脚本时，它都会重新索引我们的图书馆。对于只有两个文件的微型测试库来说，这样还行，但对于稍大一点的图书馆来说，每次都重新索引会让用户感到非常烦恼。我们怎样才能让索引持久化，并且只在图书馆内容有重要变化时，比如添加了新书，才去更新索引呢？",Bt,je,Ht,Ge,Vt;return M=new Xl({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"}]}}),x=new Wl({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),C=new y({props:{title:"用 LlamaIndex 构建一个 RAG 电子书库智能助手",local:"用-llamaindex-构建一个-rag-电子书库智能助手",headingTag:"h1"}}),L=new y({props:{title:"简介",local:"简介",headingTag:"h2"}}),j=new y({props:{title:"要求",local:"要求",headingTag:"h2"}}),Z=new y({props:{title:"组件",local:"组件",headingTag:"h2"}}),W=new y({props:{title:"依赖",local:"依赖",headingTag:"h2"}}),B=new v({props:{code:"JTI1cGlwJTIwaW5zdGFsbCUyMC1xJTIwJTVDJTBBJTIwJTIwJTIwJTIwbGxhbWEtaW5kZXglMjAlNUMlMEElMjAlMjAlMjAlMjBFYm9va0xpYiUyMCU1QyUwQSUyMCUyMCUyMCUyMGh0bWwydGV4dCUyMCU1QyUwQSUyMCUyMCUyMCUyMGxsYW1hLWluZGV4LWVtYmVkZGluZ3MtaHVnZ2luZ2ZhY2UlMjAlNUMlMEElMjAlMjAlMjAlMjBsbGFtYS1pbmRleC1sbG1zLW9sbGFtYQ==",highlighted:`%pip install -q \\
    llama-index \\
    EbookLib \\
    html2text \\
    llama-index-embeddings-huggingface \\
    llama-index-llms-ollama`,wrap:!1}}),H=new v({props:{code:"IWJyZXclMjBpbnN0YWxsJTIwb2xsYW1h",highlighted:"!brew install ollama",wrap:!1}}),V=new y({props:{title:"设置测试书库",local:"设置测试书库",headingTag:"h2"}}),P=new v({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}}),q=new y({props:{title:"用 LlamaIndex 构建 RAG",local:"用-llamaindex-构建-rag",headingTag:"h2"}}),z=new y({props:{title:"加载",local:"加载",headingTag:"h3"}}),O=new v({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}}),ee=new y({props:{title:"索引",local:"索引",headingTag:"h3"}}),J=new Rl({props:{$$slots:{default:[Al]},$$scope:{ctx:T}}}),se=new v({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}}),me=new v({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}}),pe=new y({props:{title:"查询",local:"查询",headingTag:"h3"}}),de=new v({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}}),ge=new y({props:{title:"最终结果",local:"最终结果",headingTag:"h2"}}),Me=new v({props:{code:"cHJpbnQocXVlcnlfZW5naW5lLnF1ZXJ5KCUyMldoYXQlMjBhcmUlMjB0aGUlMjB0aXRsZXMlMjBvZiUyMGFsbCUyMHRoZSUyMGJvb2tzJTIwYXZhaWxhYmxlJTNGJTIwU2hvdyUyMG1lJTIwdGhlJTIwY29udGV4dCUyMHVzZWQlMjB0byUyMGRlcml2ZSUyMHlvdXIlMjBhbnN3ZXIuJTIyKSk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(query_engine.query(<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>))',wrap:!1}}),we=new v({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}}),ye=new y({props:{title:"总结和未来可能的提升",local:"总结和未来可能的提升",headingTag:"h2"}}),ve=new y({props:{title:"强制引用",local:"强制引用",headingTag:"h3"}}),Ce=new y({props:{title:"使用扩充的元数据",local:"使用扩充的元数据",headingTag:"h3"}}),Le=new y({props:{title:"高效索引",local:"高效索引",headingTag:"h3"}}),je=new Bl({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/zh-CN/rag_llamaindex_librarian.md"}}),{c(){f=i("meta"),h=a(),w=i("p"),c=a(),$(M.$$.fragment),b=a(),$(x.$$.fragment),Ze=a(),$(C.$$.fragment),Ie=a(),_=i("p"),_.innerHTML=Yt,ke=a(),$(L.$$.fragment),We=a(),U=i("p"),U.textContent=Pt,Xe=a(),$(j.$$.fragment),Be=a(),G=i("p"),G.innerHTML=qt,He=a(),$(Z.$$.fragment),Ve=a(),I=i("p"),I.textContent=St,Re=a(),k=i("ul"),k.innerHTML=Qt,Ae=a(),$(W.$$.fragment),Ye=a(),X=i("p"),X.textContent=Et,Pe=a(),$(B.$$.fragment),qe=a(),$(H.$$.fragment),Se=a(),$(V.$$.fragment),Qe=a(),R=i("p"),R.textContent=zt,Ee=a(),A=i("p"),A.innerHTML=Ft,ze=a(),Y=i("p"),Y.innerHTML=Nt,Fe=a(),$(P.$$.fragment),Ne=a(),$(q.$$.fragment),Oe=a(),S=i("p"),S.textContent=Ot,De=a(),Q=i("ol"),Q.innerHTML=Dt,Ke=a(),E=i("p"),E.innerHTML=Kt,et=a(),$(z.$$.fragment),tt=a(),F=i("p"),F.innerHTML=el,lt=a(),N=i("p"),N.innerHTML=tl,nt=a(),$(O.$$.fragment),at=a(),D=i("p"),D.innerHTML=ll,st=a(),K=i("p"),K.innerHTML=nl,it=a(),$(ee.$$.fragment),mt=a(),te=i("p"),te.innerHTML=al,pt=a(),le=i("p"),le.innerHTML=sl,ot=a(),$(J.$$.fragment),rt=a(),ne=i("p"),ne.innerHTML=il,ft=a(),ae=i("p"),ae.innerHTML=ml,$t=a(),$(se.$$.fragment),ut=a(),ie=i("p"),ie.innerHTML=pl,dt=a(),$(me.$$.fragment),gt=a(),$(pe.$$.fragment),bt=a(),oe=i("p"),oe.textContent=ol,Mt=a(),re=i("p"),re.textContent=rl,ht=a(),fe=i("p"),fe.innerHTML=fl,wt=a(),$e=i("p"),$e.innerHTML=$l,xt=a(),ue=i("p"),ue.textContent=ul,yt=a(),$(de.$$.fragment),Tt=a(),$(ge.$$.fragment),ct=a(),be=i("p"),be.textContent=dl,vt=a(),$(Me.$$.fragment),Jt=a(),he=i("pre"),he.textContent=gl,Ct=a(),$(we.$$.fragment),_t=a(),xe=i("pre"),xe.textContent=bl,Lt=a(),$(ye.$$.fragment),Ut=a(),Te=i("p"),Te.textContent=Ml,jt=a(),ce=i("p"),ce.textContent=hl,Gt=a(),$(ve.$$.fragment),Zt=a(),Je=i("p"),Je.textContent=wl,It=a(),$(Ce.$$.fragment),kt=a(),_e=i("p"),_e.innerHTML=xl,Wt=a(),$(Le.$$.fragment),Xt=a(),Ue=i("p"),Ue.textContent=yl,Bt=a(),$(je.$$.fragment),Ht=a(),Ge=i("p"),this.h()},l(e){const t=Gl("svelte-u9bgzb",document.head);f=m(t,"META",{name:!0,content:!0}),t.forEach(l),h=s(e),w=m(e,"P",{}),At(w).forEach(l),c=s(e),u(M.$$.fragment,e),b=s(e),u(x.$$.fragment,e),Ze=s(e),u(C.$$.fragment,e),Ie=s(e),_=m(e,"P",{"data-svelte-h":!0}),p(_)!=="svelte-1fxggfq"&&(_.innerHTML=Yt),ke=s(e),u(L.$$.fragment,e),We=s(e),U=m(e,"P",{"data-svelte-h":!0}),p(U)!=="svelte-t7vqnu"&&(U.textContent=Pt),Xe=s(e),u(j.$$.fragment,e),Be=s(e),G=m(e,"P",{"data-svelte-h":!0}),p(G)!=="svelte-181ybcs"&&(G.innerHTML=qt),He=s(e),u(Z.$$.fragment,e),Ve=s(e),I=m(e,"P",{"data-svelte-h":!0}),p(I)!=="svelte-31j3g1"&&(I.textContent=St),Re=s(e),k=m(e,"UL",{"data-svelte-h":!0}),p(k)!=="svelte-tc6qwv"&&(k.innerHTML=Qt),Ae=s(e),u(W.$$.fragment,e),Ye=s(e),X=m(e,"P",{"data-svelte-h":!0}),p(X)!=="svelte-1yop8fk"&&(X.textContent=Et),Pe=s(e),u(B.$$.fragment,e),qe=s(e),u(H.$$.fragment,e),Se=s(e),u(V.$$.fragment,e),Qe=s(e),R=m(e,"P",{"data-svelte-h":!0}),p(R)!=="svelte-bgqcan"&&(R.textContent=zt),Ee=s(e),A=m(e,"P",{"data-svelte-h":!0}),p(A)!=="svelte-qr3d2u"&&(A.innerHTML=Ft),ze=s(e),Y=m(e,"P",{"data-svelte-h":!0}),p(Y)!=="svelte-qsdbu3"&&(Y.innerHTML=Nt),Fe=s(e),u(P.$$.fragment,e),Ne=s(e),u(q.$$.fragment,e),Oe=s(e),S=m(e,"P",{"data-svelte-h":!0}),p(S)!=="svelte-1vf385b"&&(S.textContent=Ot),De=s(e),Q=m(e,"OL",{"data-svelte-h":!0}),p(Q)!=="svelte-13qt93n"&&(Q.innerHTML=Dt),Ke=s(e),E=m(e,"P",{"data-svelte-h":!0}),p(E)!=="svelte-1bhq17n"&&(E.innerHTML=Kt),et=s(e),u(z.$$.fragment,e),tt=s(e),F=m(e,"P",{"data-svelte-h":!0}),p(F)!=="svelte-wlzo9w"&&(F.innerHTML=el),lt=s(e),N=m(e,"P",{"data-svelte-h":!0}),p(N)!=="svelte-1pf4mk1"&&(N.innerHTML=tl),nt=s(e),u(O.$$.fragment,e),at=s(e),D=m(e,"P",{"data-svelte-h":!0}),p(D)!=="svelte-1ds1k09"&&(D.innerHTML=ll),st=s(e),K=m(e,"P",{"data-svelte-h":!0}),p(K)!=="svelte-1g3ei9p"&&(K.innerHTML=nl),it=s(e),u(ee.$$.fragment,e),mt=s(e),te=m(e,"P",{"data-svelte-h":!0}),p(te)!=="svelte-1ljw3zw"&&(te.innerHTML=al),pt=s(e),le=m(e,"P",{"data-svelte-h":!0}),p(le)!=="svelte-1277j1h"&&(le.innerHTML=sl),ot=s(e),u(J.$$.fragment,e),rt=s(e),ne=m(e,"P",{"data-svelte-h":!0}),p(ne)!=="svelte-16otklm"&&(ne.innerHTML=il),ft=s(e),ae=m(e,"P",{"data-svelte-h":!0}),p(ae)!=="svelte-m191gf"&&(ae.innerHTML=ml),$t=s(e),u(se.$$.fragment,e),ut=s(e),ie=m(e,"P",{"data-svelte-h":!0}),p(ie)!=="svelte-j2nhc9"&&(ie.innerHTML=pl),dt=s(e),u(me.$$.fragment,e),gt=s(e),u(pe.$$.fragment,e),bt=s(e),oe=m(e,"P",{"data-svelte-h":!0}),p(oe)!=="svelte-1uj4qna"&&(oe.textContent=ol),Mt=s(e),re=m(e,"P",{"data-svelte-h":!0}),p(re)!=="svelte-9fzwy5"&&(re.textContent=rl),ht=s(e),fe=m(e,"P",{"data-svelte-h":!0}),p(fe)!=="svelte-egg81c"&&(fe.innerHTML=fl),wt=s(e),$e=m(e,"P",{"data-svelte-h":!0}),p($e)!=="svelte-nrvcvb"&&($e.innerHTML=$l),xt=s(e),ue=m(e,"P",{"data-svelte-h":!0}),p(ue)!=="svelte-2yfztk"&&(ue.textContent=ul),yt=s(e),u(de.$$.fragment,e),Tt=s(e),u(ge.$$.fragment,e),ct=s(e),be=m(e,"P",{"data-svelte-h":!0}),p(be)!=="svelte-3apvjl"&&(be.textContent=dl),vt=s(e),u(Me.$$.fragment,e),Jt=s(e),he=m(e,"PRE",{"data-svelte-h":!0}),p(he)!=="svelte-czhhw9"&&(he.textContent=gl),Ct=s(e),u(we.$$.fragment,e),_t=s(e),xe=m(e,"PRE",{"data-svelte-h":!0}),p(xe)!=="svelte-13j10yu"&&(xe.textContent=bl),Lt=s(e),u(ye.$$.fragment,e),Ut=s(e),Te=m(e,"P",{"data-svelte-h":!0}),p(Te)!=="svelte-1g80xm3"&&(Te.textContent=Ml),jt=s(e),ce=m(e,"P",{"data-svelte-h":!0}),p(ce)!=="svelte-fbi3xx"&&(ce.textContent=hl),Gt=s(e),u(ve.$$.fragment,e),Zt=s(e),Je=m(e,"P",{"data-svelte-h":!0}),p(Je)!=="svelte-onk5ks"&&(Je.textContent=wl),It=s(e),u(Ce.$$.fragment,e),kt=s(e),_e=m(e,"P",{"data-svelte-h":!0}),p(_e)!=="svelte-1yn6jew"&&(_e.innerHTML=xl),Wt=s(e),u(Le.$$.fragment,e),Xt=s(e),Ue=m(e,"P",{"data-svelte-h":!0}),p(Ue)!=="svelte-tjr3o1"&&(Ue.textContent=yl),Bt=s(e),u(je.$$.fragment,e),Ht=s(e),Ge=m(e,"P",{}),At(Ge).forEach(l),this.h()},h(){Rt(f,"name","hf:doc:metadata"),Rt(f,"content",Pl)},m(e,t){Zl(document.head,f),n(e,h,t),n(e,w,t),n(e,c,t),d(M,e,t),n(e,b,t),d(x,e,t),n(e,Ze,t),d(C,e,t),n(e,Ie,t),n(e,_,t),n(e,ke,t),d(L,e,t),n(e,We,t),n(e,U,t),n(e,Xe,t),d(j,e,t),n(e,Be,t),n(e,G,t),n(e,He,t),d(Z,e,t),n(e,Ve,t),n(e,I,t),n(e,Re,t),n(e,k,t),n(e,Ae,t),d(W,e,t),n(e,Ye,t),n(e,X,t),n(e,Pe,t),d(B,e,t),n(e,qe,t),d(H,e,t),n(e,Se,t),d(V,e,t),n(e,Qe,t),n(e,R,t),n(e,Ee,t),n(e,A,t),n(e,ze,t),n(e,Y,t),n(e,Fe,t),d(P,e,t),n(e,Ne,t),d(q,e,t),n(e,Oe,t),n(e,S,t),n(e,De,t),n(e,Q,t),n(e,Ke,t),n(e,E,t),n(e,et,t),d(z,e,t),n(e,tt,t),n(e,F,t),n(e,lt,t),n(e,N,t),n(e,nt,t),d(O,e,t),n(e,at,t),n(e,D,t),n(e,st,t),n(e,K,t),n(e,it,t),d(ee,e,t),n(e,mt,t),n(e,te,t),n(e,pt,t),n(e,le,t),n(e,ot,t),d(J,e,t),n(e,rt,t),n(e,ne,t),n(e,ft,t),n(e,ae,t),n(e,$t,t),d(se,e,t),n(e,ut,t),n(e,ie,t),n(e,dt,t),d(me,e,t),n(e,gt,t),d(pe,e,t),n(e,bt,t),n(e,oe,t),n(e,Mt,t),n(e,re,t),n(e,ht,t),n(e,fe,t),n(e,wt,t),n(e,$e,t),n(e,xt,t),n(e,ue,t),n(e,yt,t),d(de,e,t),n(e,Tt,t),d(ge,e,t),n(e,ct,t),n(e,be,t),n(e,vt,t),d(Me,e,t),n(e,Jt,t),n(e,he,t),n(e,Ct,t),d(we,e,t),n(e,_t,t),n(e,xe,t),n(e,Lt,t),d(ye,e,t),n(e,Ut,t),n(e,Te,t),n(e,jt,t),n(e,ce,t),n(e,Gt,t),d(ve,e,t),n(e,Zt,t),n(e,Je,t),n(e,It,t),d(Ce,e,t),n(e,kt,t),n(e,_e,t),n(e,Wt,t),d(Le,e,t),n(e,Xt,t),n(e,Ue,t),n(e,Bt,t),d(je,e,t),n(e,Ht,t),n(e,Ge,t),Vt=!0},p(e,[t]){const Tl={};t&2&&(Tl.$$scope={dirty:t,ctx:e}),J.$set(Tl)},i(e){Vt||(o(M.$$.fragment,e),o(x.$$.fragment,e),o(C.$$.fragment,e),o(L.$$.fragment,e),o(j.$$.fragment,e),o(Z.$$.fragment,e),o(W.$$.fragment,e),o(B.$$.fragment,e),o(H.$$.fragment,e),o(V.$$.fragment,e),o(P.$$.fragment,e),o(q.$$.fragment,e),o(z.$$.fragment,e),o(O.$$.fragment,e),o(ee.$$.fragment,e),o(J.$$.fragment,e),o(se.$$.fragment,e),o(me.$$.fragment,e),o(pe.$$.fragment,e),o(de.$$.fragment,e),o(ge.$$.fragment,e),o(Me.$$.fragment,e),o(we.$$.fragment,e),o(ye.$$.fragment,e),o(ve.$$.fragment,e),o(Ce.$$.fragment,e),o(Le.$$.fragment,e),o(je.$$.fragment,e),Vt=!0)},o(e){r(M.$$.fragment,e),r(x.$$.fragment,e),r(C.$$.fragment,e),r(L.$$.fragment,e),r(j.$$.fragment,e),r(Z.$$.fragment,e),r(W.$$.fragment,e),r(B.$$.fragment,e),r(H.$$.fragment,e),r(V.$$.fragment,e),r(P.$$.fragment,e),r(q.$$.fragment,e),r(z.$$.fragment,e),r(O.$$.fragment,e),r(ee.$$.fragment,e),r(J.$$.fragment,e),r(se.$$.fragment,e),r(me.$$.fragment,e),r(pe.$$.fragment,e),r(de.$$.fragment,e),r(ge.$$.fragment,e),r(Me.$$.fragment,e),r(we.$$.fragment,e),r(ye.$$.fragment,e),r(ve.$$.fragment,e),r(Ce.$$.fragment,e),r(Le.$$.fragment,e),r(je.$$.fragment,e),Vt=!1},d(e){e&&(l(h),l(w),l(c),l(b),l(Ze),l(Ie),l(_),l(ke),l(We),l(U),l(Xe),l(Be),l(G),l(He),l(Ve),l(I),l(Re),l(k),l(Ae),l(Ye),l(X),l(Pe),l(qe),l(Se),l(Qe),l(R),l(Ee),l(A),l(ze),l(Y),l(Fe),l(Ne),l(Oe),l(S),l(De),l(Q),l(Ke),l(E),l(et),l(tt),l(F),l(lt),l(N),l(nt),l(at),l(D),l(st),l(K),l(it),l(mt),l(te),l(pt),l(le),l(ot),l(rt),l(ne),l(ft),l(ae),l($t),l(ut),l(ie),l(dt),l(gt),l(bt),l(oe),l(Mt),l(re),l(ht),l(fe),l(wt),l($e),l(xt),l(ue),l(yt),l(Tt),l(ct),l(be),l(vt),l(Jt),l(he),l(Ct),l(_t),l(xe),l(Lt),l(Ut),l(Te),l(jt),l(ce),l(Gt),l(Zt),l(Je),l(It),l(kt),l(_e),l(Wt),l(Xt),l(Ue),l(Bt),l(Ht),l(Ge)),l(f),g(M,e),g(x,e),g(C,e),g(L,e),g(j,e),g(Z,e),g(W,e),g(B,e),g(H,e),g(V,e),g(P,e),g(q,e),g(z,e),g(O,e),g(ee,e),g(J,e),g(se,e),g(me,e),g(pe,e),g(de,e),g(ge,e),g(Me,e),g(we,e),g(ye,e),g(ve,e),g(Ce,e),g(Le,e),g(je,e)}}}const Pl='{"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 ql(T){return jl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nl extends vl{constructor(f){super(),Jl(this,f,ql,Yl,cl,{})}}export{Nl as component};
