import{s as Pt,a as Dt,o as Kt,n as v}from"../chunks/scheduler.505acc25.js";import{S as ls,i as ts,e as V,s as o,c as w,h as ss,a as c,d as t,b as r,f as ut,g as f,j as m,k as S,l as es,m as e,n as N,t as I,o as B,p as h}from"../chunks/index.b1175496.js";import{C as ns,H as R}from"../chunks/Heading.eda51538.js";import{C as $}from"../chunks/CodeBlock.9d480d26.js";import{H as yt,a as E}from"../chunks/HfOption.ccfd750e.js";import{E as as}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.ea377ea6.js";function is(Q){let M,u;return M=new $({props:{code:"aW1wb3J0JTIwZGF0YXNldHMlMEFmcm9tJTIwbGFuZ2NoYWluX2NvcmUuZG9jdW1lbnRzJTIwaW1wb3J0JTIwRG9jdW1lbnQlMEElMEElMjMlMjAlRTUlOEElQTAlRTglQkQlQkQlRTYlOTUlQjAlRTYlOEQlQUUlRTklOUIlODYlMEFndWVzdF9kYXRhc2V0JTIwJTNEJTIwZGF0YXNldHMubG9hZF9kYXRhc2V0KCUyMmFnZW50cy1jb3Vyc2UlMkZ1bml0My1pbnZpdGVlcyUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIpJTBBJTBBJTIzJTIwJUU4JUJEJUFDJUU2JThEJUEyJUU0JUI4JUJBJTIwRG9jdW1lbnQlMjAlRTUlQUYlQjklRTglQjElQTElMEFkb2NzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwRG9jdW1lbnQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcGFnZV9jb250ZW50JTNEJTIyJTVDbiUyMi5qb2luKCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGYlMjJOYW1lJTNBJTIwJTdCZ3Vlc3QlNUInbmFtZSclNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyUmVsYXRpb24lM0ElMjAlN0JndWVzdCU1QidyZWxhdGlvbiclNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyRGVzY3JpcHRpb24lM0ElMjAlN0JndWVzdCU1QidkZXNjcmlwdGlvbiclNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyRW1haWwlM0ElMjAlN0JndWVzdCU1QidlbWFpbCclNUQlN0QlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQpJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWV0YWRhdGElM0QlN0IlMjJuYW1lJTIyJTNBJTIwZ3Vlc3QlNUIlMjJuYW1lJTIyJTVEJTdEJTBBJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMGZvciUyMGd1ZXN0JTIwaW4lMjBndWVzdF9kYXRhc2V0JTBBJTVEJTBB",highlighted:`<span class="hljs-keyword">import</span> datasets
<span class="hljs-keyword">from</span> langchain_core.documents <span class="hljs-keyword">import</span> Document

<span class="hljs-comment"># 加载数据集</span>
guest_dataset = datasets.load_dataset(<span class="hljs-string">&quot;agents-course/unit3-invitees&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)

<span class="hljs-comment"># 转换为 Document 对象</span>
docs = [
    Document(
        page_content=<span class="hljs-string">&quot;\\n&quot;</span>.join([
            <span class="hljs-string">f&quot;Name: <span class="hljs-subst">{guest[<span class="hljs-string">&#x27;name&#x27;</span>]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Relation: <span class="hljs-subst">{guest[<span class="hljs-string">&#x27;relation&#x27;</span>]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Description: <span class="hljs-subst">{guest[<span class="hljs-string">&#x27;description&#x27;</span>]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Email: <span class="hljs-subst">{guest[<span class="hljs-string">&#x27;email&#x27;</span>]}</span>&quot;</span>
        ]),
        metadata={<span class="hljs-string">&quot;name&quot;</span>: guest[<span class="hljs-string">&quot;name&quot;</span>]}
    )
    <span class="hljs-keyword">for</span> guest <span class="hljs-keyword">in</span> guest_dataset
]
`,wrap:!1}}),{c(){w(M.$$.fragment)},l(U){f(M.$$.fragment,U)},m(U,T){N(M,U,T),u=!0},p:v,i(U){u||(I(M.$$.fragment,U),u=!0)},o(U){B(M.$$.fragment,U),u=!1},d(U){h(M,U)}}}function Ms(Q){let M,u="我们将使用 Hugging Face <code>datasets</code> 库来加载数据集并将其转换为来自 <code>llama_index.core.schema</code> 模块的 <code>Document</code> 对象列表。",U,T,j;return T=new $({props:{code:"aW1wb3J0JTIwZGF0YXNldHMlMEFmcm9tJTIwbGxhbWFfaW5kZXguY29yZS5zY2hlbWElMjBpbXBvcnQlMjBEb2N1bWVudCUwQSUwQSUyMyUyMCVFNSU4QSVBMCVFOCVCRCVCRCVFNiU5NSVCMCVFNiU4RCVBRSVFOSU5QiU4NiUwQWd1ZXN0X2RhdGFzZXQlMjAlM0QlMjBkYXRhc2V0cy5sb2FkX2RhdGFzZXQoJTIyYWdlbnRzLWNvdXJzZSUyRnVuaXQzLWludml0ZWVzJTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiUyMiklMEElMEElMjMlMjAlRTglQkQlQUMlRTYlOEQlQTIlRTQlQjglQkElMjBEb2N1bWVudCUyMCVFNSVBRiVCOSVFOCVCMSVBMSUwQWRvY3MlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjBEb2N1bWVudCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0ZXh0JTNEJTIyJTVDbiUyMi5qb2luKCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGYlMjJOYW1lJTNBJTIwJTdCZ3Vlc3RfZGF0YXNldCU1QiduYW1lJyU1RCU1QmklNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyUmVsYXRpb24lM0ElMjAlN0JndWVzdF9kYXRhc2V0JTVCJ3JlbGF0aW9uJyU1RCU1QmklNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyRGVzY3JpcHRpb24lM0ElMjAlN0JndWVzdF9kYXRhc2V0JTVCJ2Rlc2NyaXB0aW9uJyU1RCU1QmklNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyRW1haWwlM0ElMjAlN0JndWVzdF9kYXRhc2V0JTVCJ2VtYWlsJyU1RCU1QmklNUQlN0QlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQpJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWV0YWRhdGElM0QlN0IlMjJuYW1lJTIyJTNBJTIwZ3Vlc3RfZGF0YXNldCU1QiduYW1lJyU1RCU1QmklNUQlN0QlMEElMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwZm9yJTIwaSUyMGluJTIwcmFuZ2UobGVuKGd1ZXN0X2RhdGFzZXQpKSUwQSU1RA==",highlighted:`<span class="hljs-keyword">import</span> datasets
<span class="hljs-keyword">from</span> llama_index.core.schema <span class="hljs-keyword">import</span> Document

<span class="hljs-comment"># 加载数据集</span>
guest_dataset = datasets.load_dataset(<span class="hljs-string">&quot;agents-course/unit3-invitees&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)

<span class="hljs-comment"># 转换为 Document 对象</span>
docs = [
    Document(
        text=<span class="hljs-string">&quot;\\n&quot;</span>.join([
            <span class="hljs-string">f&quot;Name: <span class="hljs-subst">{guest_dataset[<span class="hljs-string">&#x27;name&#x27;</span>][i]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Relation: <span class="hljs-subst">{guest_dataset[<span class="hljs-string">&#x27;relation&#x27;</span>][i]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Description: <span class="hljs-subst">{guest_dataset[<span class="hljs-string">&#x27;description&#x27;</span>][i]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Email: <span class="hljs-subst">{guest_dataset[<span class="hljs-string">&#x27;email&#x27;</span>][i]}</span>&quot;</span>
        ]),
        metadata={<span class="hljs-string">&quot;name&quot;</span>: guest_dataset[<span class="hljs-string">&#x27;name&#x27;</span>][i]}
    )
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(guest_dataset))
]`,wrap:!1}}),{c(){M=V("p"),M.innerHTML=u,U=o(),w(T.$$.fragment)},l(J){M=c(J,"P",{"data-svelte-h":!0}),m(M)!=="svelte-1huhyoc"&&(M.innerHTML=u),U=r(J),f(T.$$.fragment,J)},m(J,s){e(J,M,s),e(J,U,s),N(T,J,s),j=!0},p:v,i(J){j||(I(T.$$.fragment,J),j=!0)},o(J){B(T.$$.fragment,J),j=!1},d(J){J&&(t(M),t(U)),h(T,J)}}}function Us(Q){let M,u="我们将使用 Hugging Face <code>datasets</code> 库来加载数据集并将其转换为来自 <code>langchain.docstore.document</code> 模块的 <code>Document</code> 对象列表。",U,T,j;return T=new $({props:{code:"aW1wb3J0JTIwZGF0YXNldHMlMEFmcm9tJTIwbGFuZ2NoYWluX2NvcmUuZG9jdW1lbnRzJTIwaW1wb3J0JTIwRG9jdW1lbnQlMEElMEElMjMlMjAlRTUlOEElQTAlRTglQkQlQkQlRTYlOTUlQjAlRTYlOEQlQUUlRTklOUIlODYlMEFndWVzdF9kYXRhc2V0JTIwJTNEJTIwZGF0YXNldHMubG9hZF9kYXRhc2V0KCUyMmFnZW50cy1jb3Vyc2UlMkZ1bml0My1pbnZpdGVlcyUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIpJTBBJTBBJTIzJTIwJUU4JUJEJUFDJUU2JThEJUEyJUU0JUI4JUJBJTIwRG9jdW1lbnQlMjAlRTUlQUYlQjklRTglQjElQTElMEFkb2NzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwRG9jdW1lbnQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcGFnZV9jb250ZW50JTNEJTIyJTVDbiUyMi5qb2luKCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGYlMjJOYW1lJTNBJTIwJTdCZ3Vlc3QlNUInbmFtZSclNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyUmVsYXRpb24lM0ElMjAlN0JndWVzdCU1QidyZWxhdGlvbiclNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyRGVzY3JpcHRpb24lM0ElMjAlN0JndWVzdCU1QidkZXNjcmlwdGlvbiclNUQlN0QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyRW1haWwlM0ElMjAlN0JndWVzdCU1QidlbWFpbCclNUQlN0QlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQpJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWV0YWRhdGElM0QlN0IlMjJuYW1lJTIyJTNBJTIwZ3Vlc3QlNUIlMjJuYW1lJTIyJTVEJTdEJTBBJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMGZvciUyMGd1ZXN0JTIwaW4lMjBndWVzdF9kYXRhc2V0JTBBJTVE",highlighted:`<span class="hljs-keyword">import</span> datasets
<span class="hljs-keyword">from</span> langchain_core.documents <span class="hljs-keyword">import</span> Document

<span class="hljs-comment"># 加载数据集</span>
guest_dataset = datasets.load_dataset(<span class="hljs-string">&quot;agents-course/unit3-invitees&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)

<span class="hljs-comment"># 转换为 Document 对象</span>
docs = [
    Document(
        page_content=<span class="hljs-string">&quot;\\n&quot;</span>.join([
            <span class="hljs-string">f&quot;Name: <span class="hljs-subst">{guest[<span class="hljs-string">&#x27;name&#x27;</span>]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Relation: <span class="hljs-subst">{guest[<span class="hljs-string">&#x27;relation&#x27;</span>]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Description: <span class="hljs-subst">{guest[<span class="hljs-string">&#x27;description&#x27;</span>]}</span>&quot;</span>,
            <span class="hljs-string">f&quot;Email: <span class="hljs-subst">{guest[<span class="hljs-string">&#x27;email&#x27;</span>]}</span>&quot;</span>
        ]),
        metadata={<span class="hljs-string">&quot;name&quot;</span>: guest[<span class="hljs-string">&quot;name&quot;</span>]}
    )
    <span class="hljs-keyword">for</span> guest <span class="hljs-keyword">in</span> guest_dataset
]`,wrap:!1}}),{c(){M=V("p"),M.innerHTML=u,U=o(),w(T.$$.fragment)},l(J){M=c(J,"P",{"data-svelte-h":!0}),m(M)!=="svelte-qgr523"&&(M.innerHTML=u),U=r(J),f(T.$$.fragment,J)},m(J,s){e(J,M,s),e(J,U,s),N(T,J,s),j=!0},p:v,i(J){j||(I(T.$$.fragment,J),j=!0)},o(J){B(T.$$.fragment,J),j=!1},d(J){J&&(t(M),t(U)),h(T,J)}}}function Js(Q){let M,u,U,T,j,J;return M=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[is]},$$scope:{ctx:Q}}}),U=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[Ms]},$$scope:{ctx:Q}}}),j=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[Us]},$$scope:{ctx:Q}}}),{c(){w(M.$$.fragment),u=o(),w(U.$$.fragment),T=o(),w(j.$$.fragment)},l(s){f(M.$$.fragment,s),u=r(s),f(U.$$.fragment,s),T=r(s),f(j.$$.fragment,s)},m(s,p){N(M,s,p),e(s,u,p),N(U,s,p),e(s,T,p),N(j,s,p),J=!0},p(s,p){const C={};p&2&&(C.$$scope={dirty:p,ctx:s}),M.$set(C);const b={};p&2&&(b.$$scope={dirty:p,ctx:s}),U.$set(b);const y={};p&2&&(y.$$scope={dirty:p,ctx:s}),j.$set(y)},i(s){J||(I(M.$$.fragment,s),I(U.$$.fragment,s),I(j.$$.fragment,s),J=!0)},o(s){B(M.$$.fragment,s),B(U.$$.fragment,s),B(j.$$.fragment,s),J=!1},d(s){s&&(t(u),t(T)),h(M,s),h(U,s),h(j,s)}}}function ps(Q){let M,u="我们将使用“langchain_community.retrievers”模块中的“BM25Retriever”来创建一个检索工具。",U,T,j='<code>BM25Retriever</code> 是检索的一个很好的起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如来自 <a href="https://www.sbert.net/">sentence-transformers</a> 的检索器。',J,s,p,C,b="让我们逐步了解这个工具：",y,d,F="<li><code>name</code> 和 <code>description</code> 帮助智能体了解何时以及如何使用此工具</li> <li><code>inputs</code> 定义工具所需的参数（在本例中为搜索查询）</li> <li>我们使用 <code>BM25Retriever</code>，这是一种强大的文本检索算法，不需要嵌入</li> <li><code>forward</code> 方法处理查询并返回最相关的客人信息</li>",a;return s=new $({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBUb29sJTBBZnJvbSUyMGxhbmdjaGFpbl9jb21tdW5pdHkucmV0cmlldmVycyUyMGltcG9ydCUyMEJNMjVSZXRyaWV2ZXIlMEElMEFjbGFzcyUyMEd1ZXN0SW5mb1JldHJpZXZlclRvb2woVG9vbCklM0ElMEElMjAlMjAlMjAlMjBuYW1lJTIwJTNEJTIwJTIyZ3Vlc3RfaW5mb19yZXRyaWV2ZXIlMjIlMEElMjAlMjAlMjAlMjBkZXNjcmlwdGlvbiUyMCUzRCUyMCUyMlJldHJpZXZlcyUyMGRldGFpbGVkJTIwaW5mb3JtYXRpb24lMjBhYm91dCUyMGdhbGElMjBndWVzdHMlMjBiYXNlZCUyMG9uJTIwdGhlaXIlMjBuYW1lJTIwb3IlMjByZWxhdGlvbi4lMjIlMEElMjAlMjAlMjAlMjBpbnB1dHMlMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJxdWVyeSUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnR5cGUlMjIlM0ElMjAlMjJzdHJpbmclMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJkZXNjcmlwdGlvbiUyMiUzQSUyMCUyMlRoZSUyMG5hbWUlMjBvciUyMHJlbGF0aW9uJTIwb2YlMjB0aGUlMjBndWVzdCUyMHlvdSUyMHdhbnQlMjBpbmZvcm1hdGlvbiUyMGFib3V0LiUyMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMG91dHB1dF90eXBlJTIwJTNEJTIwJTIyc3RyaW5nJTIyJTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwX19pbml0X18oc2VsZiUyQyUyMGRvY3MpJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2VsZi5pc19pbml0aWFsaXplZCUyMCUzRCUyMEZhbHNlJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2VsZi5yZXRyaWV2ZXIlMjAlM0QlMjBCTTI1UmV0cmlldmVyLmZyb21fZG9jdW1lbnRzKGRvY3MpJTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwZm9yd2FyZChzZWxmJTJDJTIwcXVlcnklM0ElMjBzdHIpJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVzdWx0cyUyMCUzRCUyMHNlbGYucmV0cmlldmVyLmdldF9yZWxldmFudF9kb2N1bWVudHMocXVlcnkpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWYlMjByZXN1bHRzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyJTVDbiU1Q24lMjIuam9pbiglNUJkb2MucGFnZV9jb250ZW50JTIwZm9yJTIwZG9jJTIwaW4lMjByZXN1bHRzJTVCJTNBMyU1RCU1RCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBlbHNlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyTm8lMjBtYXRjaGluZyUyMGd1ZXN0JTIwaW5mb3JtYXRpb24lMjBmb3VuZC4lMjIlMEElMEElMjMlMjAlRTUlODglOUQlRTUlQTclOEIlRTUlOEMlOTYlRTUlQjclQTUlRTUlODUlQjclMEFndWVzdF9pbmZvX3Rvb2wlMjAlM0QlMjBHdWVzdEluZm9SZXRyaWV2ZXJUb29sKGRvY3Mp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> Tool
<span class="hljs-keyword">from</span> langchain_community.retrievers <span class="hljs-keyword">import</span> BM25Retriever

<span class="hljs-keyword">class</span> <span class="hljs-title class_">GuestInfoRetrieverTool</span>(<span class="hljs-title class_ inherited__">Tool</span>):
    name = <span class="hljs-string">&quot;guest_info_retriever&quot;</span>
    description = <span class="hljs-string">&quot;Retrieves detailed information about gala guests based on their name or relation.&quot;</span>
    inputs = {
        <span class="hljs-string">&quot;query&quot;</span>: {
            <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
            <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;The name or relation of the guest you want information about.&quot;</span>
        }
    }
    output_type = <span class="hljs-string">&quot;string&quot;</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, docs</span>):
        self.is_initialized = <span class="hljs-literal">False</span>
        self.retriever = BM25Retriever.from_documents(docs)

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, query: <span class="hljs-built_in">str</span></span>):
        results = self.retriever.get_relevant_documents(query)
        <span class="hljs-keyword">if</span> results:
            <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;\\n\\n&quot;</span>.join([doc.page_content <span class="hljs-keyword">for</span> doc <span class="hljs-keyword">in</span> results[:<span class="hljs-number">3</span>]])
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;No matching guest information found.&quot;</span>

<span class="hljs-comment"># 初始化工具</span>
guest_info_tool = GuestInfoRetrieverTool(docs)`,wrap:!1}}),{c(){M=V("p"),M.textContent=u,U=o(),T=V("blockquote"),T.innerHTML=j,J=o(),w(s.$$.fragment),p=o(),C=V("p"),C.textContent=b,y=o(),d=V("ul"),d.innerHTML=F,this.h()},l(n){M=c(n,"P",{"data-svelte-h":!0}),m(M)!=="svelte-1h1wsbb"&&(M.textContent=u),U=r(n),T=c(n,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(T)!=="svelte-vd3lsm"&&(T.innerHTML=j),J=r(n),f(s.$$.fragment,n),p=r(n),C=c(n,"P",{"data-svelte-h":!0}),m(C)!=="svelte-1nnhcdb"&&(C.textContent=b),y=r(n),d=c(n,"UL",{"data-svelte-h":!0}),m(d)!=="svelte-uto1l5"&&(d.innerHTML=F),this.h()},h(){S(T,"class","tip")},m(n,g){e(n,M,g),e(n,U,g),e(n,T,g),e(n,J,g),N(s,n,g),e(n,p,g),e(n,C,g),e(n,y,g),e(n,d,g),a=!0},p:v,i(n){a||(I(s.$$.fragment,n),a=!0)},o(n){B(s.$$.fragment,n),a=!1},d(n){n&&(t(M),t(U),t(T),t(J),t(p),t(C),t(y),t(d)),h(s,n)}}}function os(Q){let M,u="我们将使用 <code>llama_index.retrievers.bm25</code> 模块中的 <code>BM25Retriever</code> 来创建一个检索工具。",U,T,j='<code>BM25Retriever</code> 是一个很好的检索起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如 <a href="https://www.sbert.net/">sentence-transformers</a> 中的检索器。',J,s,p,C,b="让我们逐步了解这个工具。",y,d,F="<li>文档字符串帮助智能体了解何时以及如何使用此工具</li> <li>类型装饰器定义了工具所需的参数（在本例中为搜索查询）</li> <li>我们使用 <code>BM25Retriever</code>，这是一种强大的文本检索算法，不需要嵌入</li> <li>该方法处理查询并返回最相关的客人信息</li>",a;return s=new $({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUudG9vbHMlMjBpbXBvcnQlMjBGdW5jdGlvblRvb2wlMEFmcm9tJTIwbGxhbWFfaW5kZXgucmV0cmlldmVycy5ibTI1JTIwaW1wb3J0JTIwQk0yNVJldHJpZXZlciUwQSUwQWJtMjVfcmV0cmlldmVyJTIwJTNEJTIwQk0yNVJldHJpZXZlci5mcm9tX2RlZmF1bHRzKG5vZGVzJTNEZG9jcyklMEElMEFkZWYlMjBnZXRfZ3Vlc3RfaW5mb19yZXRyaWV2ZXIocXVlcnklM0ElMjBzdHIpJTIwLSUzRSUyMHN0ciUzQSUwQSUyMCUyMCUyMCUyMCUyMiUyMiUyMlJldHJpZXZlcyUyMGRldGFpbGVkJTIwaW5mb3JtYXRpb24lMjBhYm91dCUyMGdhbGElMjBndWVzdHMlMjBiYXNlZCUyMG9uJTIwdGhlaXIlMjBuYW1lJTIwb3IlMjByZWxhdGlvbi4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjByZXN1bHRzJTIwJTNEJTIwYm0yNV9yZXRyaWV2ZXIucmV0cmlldmUocXVlcnkpJTBBJTIwJTIwJTIwJTIwaWYlMjByZXN1bHRzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyJTVDbiU1Q24lMjIuam9pbiglNUJkb2MudGV4dCUyMGZvciUyMGRvYyUyMGluJTIwcmVzdWx0cyU1QiUzQTMlNUQlNUQpJTBBJTIwJTIwJTIwJTIwZWxzZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMCUyMk5vJTIwbWF0Y2hpbmclMjBndWVzdCUyMGluZm9ybWF0aW9uJTIwZm91bmQuJTIyJTBBJTBBJTIzJTIwJUU1JTg4JTlEJUU1JUE3JThCJUU1JThDJTk2JUU1JUI3JUE1JUU1JTg1JUI3JTBBZ3Vlc3RfaW5mb190b29sJTIwJTNEJTIwRnVuY3Rpb25Ub29sLmZyb21fZGVmYXVsdHMoZ2V0X2d1ZXN0X2luZm9fcmV0cmlldmVyKQ==",highlighted:`<span class="hljs-keyword">from</span> llama_index.core.tools <span class="hljs-keyword">import</span> FunctionTool
<span class="hljs-keyword">from</span> llama_index.retrievers.bm25 <span class="hljs-keyword">import</span> BM25Retriever

bm25_retriever = BM25Retriever.from_defaults(nodes=docs)

<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_guest_info_retriever</span>(<span class="hljs-params">query: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;Retrieves detailed information about gala guests based on their name or relation.&quot;&quot;&quot;</span>
    results = bm25_retriever.retrieve(query)
    <span class="hljs-keyword">if</span> results:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;\\n\\n&quot;</span>.join([doc.text <span class="hljs-keyword">for</span> doc <span class="hljs-keyword">in</span> results[:<span class="hljs-number">3</span>]])
    <span class="hljs-keyword">else</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;No matching guest information found.&quot;</span>

<span class="hljs-comment"># 初始化工具</span>
guest_info_tool = FunctionTool.from_defaults(get_guest_info_retriever)`,wrap:!1}}),{c(){M=V("p"),M.innerHTML=u,U=o(),T=V("blockquote"),T.innerHTML=j,J=o(),w(s.$$.fragment),p=o(),C=V("p"),C.textContent=b,y=o(),d=V("ul"),d.innerHTML=F,this.h()},l(n){M=c(n,"P",{"data-svelte-h":!0}),m(M)!=="svelte-re9s76"&&(M.innerHTML=u),U=r(n),T=c(n,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(T)!=="svelte-1xzajos"&&(T.innerHTML=j),J=r(n),f(s.$$.fragment,n),p=r(n),C=c(n,"P",{"data-svelte-h":!0}),m(C)!=="svelte-54z6pz"&&(C.textContent=b),y=r(n),d=c(n,"UL",{"data-svelte-h":!0}),m(d)!=="svelte-1yb6oqz"&&(d.innerHTML=F),this.h()},h(){S(T,"class","tip")},m(n,g){e(n,M,g),e(n,U,g),e(n,T,g),e(n,J,g),N(s,n,g),e(n,p,g),e(n,C,g),e(n,y,g),e(n,d,g),a=!0},p:v,i(n){a||(I(s.$$.fragment,n),a=!0)},o(n){B(s.$$.fragment,n),a=!1},d(n){n&&(t(M),t(U),t(T),t(J),t(p),t(C),t(y),t(d)),h(s,n)}}}function rs(Q){let M,u="我们将使用 <code>langchain_community.retrievers</code> 模块中的 <code>BM25Retriever</code> 来创建一个检索工具。",U,T,j='<code>BM25Retriever</code> 是一个很好的检索起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如 <a href="https://www.sbert.net/">sentence-transformers</a> 中的检索器。',J,s,p,C,b="让我们逐步了解这个工具。",y,d,F="<li><code>name</code> 和 <code>description</code> 帮助智能体了解何时以及如何使用此工具。</li> <li>类型装饰器定义了工具所需的参数（在本例中为搜索查询）。</li> <li>我们使用 <code>BM25Retriever</code>，这是一种强大的文本检索算法，无需嵌入。</li> <li>该方法处理查询并返回最相关的客人信息。</li>",a;return s=new $({props:{code:"ZnJvbSUyMGxhbmdjaGFpbl9jb21tdW5pdHkucmV0cmlldmVycyUyMGltcG9ydCUyMEJNMjVSZXRyaWV2ZXIlMEFmcm9tJTIwbGFuZ2NoYWluLnRvb2xzJTIwaW1wb3J0JTIwVG9vbCUwQSUwQWJtMjVfcmV0cmlldmVyJTIwJTNEJTIwQk0yNVJldHJpZXZlci5mcm9tX2RvY3VtZW50cyhkb2NzKSUwQSUwQWRlZiUyMGV4dHJhY3RfdGV4dChxdWVyeSUzQSUyMHN0ciklMjAtJTNFJTIwc3RyJTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyUmV0cmlldmVzJTIwZGV0YWlsZWQlMjBpbmZvcm1hdGlvbiUyMGFib3V0JTIwZ2FsYSUyMGd1ZXN0cyUyMGJhc2VkJTIwb24lMjB0aGVpciUyMG5hbWUlMjBvciUyMHJlbGF0aW9uLiUyMiUyMiUyMiUwQSUyMCUyMCUyMCUyMHJlc3VsdHMlMjAlM0QlMjBibTI1X3JldHJpZXZlci5pbnZva2UocXVlcnkpJTBBJTIwJTIwJTIwJTIwaWYlMjByZXN1bHRzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyJTVDbiU1Q24lMjIuam9pbiglNUJkb2MucGFnZV9jb250ZW50JTIwZm9yJTIwZG9jJTIwaW4lMjByZXN1bHRzJTVCJTNBMyU1RCU1RCklMEElMjAlMjAlMjAlMjBlbHNlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyTm8lMjBtYXRjaGluZyUyMGd1ZXN0JTIwaW5mb3JtYXRpb24lMjBmb3VuZC4lMjIlMEElMEFndWVzdF9pbmZvX3Rvb2wlMjAlM0QlMjBUb29sKCUwQSUyMCUyMCUyMCUyMG5hbWUlM0QlMjJndWVzdF9pbmZvX3JldHJpZXZlciUyMiUyQyUwQSUyMCUyMCUyMCUyMGZ1bmMlM0RleHRyYWN0X3RleHQlMkMlMEElMjAlMjAlMjAlMjBkZXNjcmlwdGlvbiUzRCUyMlJldHJpZXZlcyUyMGRldGFpbGVkJTIwaW5mb3JtYXRpb24lMjBhYm91dCUyMGdhbGElMjBndWVzdHMlMjBiYXNlZCUyMG9uJTIwdGhlaXIlMjBuYW1lJTIwb3IlMjByZWxhdGlvbi4lMjIlMEEp",highlighted:`<span class="hljs-keyword">from</span> langchain_community.retrievers <span class="hljs-keyword">import</span> BM25Retriever
<span class="hljs-keyword">from</span> langchain.tools <span class="hljs-keyword">import</span> Tool

bm25_retriever = BM25Retriever.from_documents(docs)

<span class="hljs-keyword">def</span> <span class="hljs-title function_">extract_text</span>(<span class="hljs-params">query: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;Retrieves detailed information about gala guests based on their name or relation.&quot;&quot;&quot;</span>
    results = bm25_retriever.invoke(query)
    <span class="hljs-keyword">if</span> results:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;\\n\\n&quot;</span>.join([doc.page_content <span class="hljs-keyword">for</span> doc <span class="hljs-keyword">in</span> results[:<span class="hljs-number">3</span>]])
    <span class="hljs-keyword">else</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;No matching guest information found.&quot;</span>

guest_info_tool = Tool(
    name=<span class="hljs-string">&quot;guest_info_retriever&quot;</span>,
    func=extract_text,
    description=<span class="hljs-string">&quot;Retrieves detailed information about gala guests based on their name or relation.&quot;</span>
)`,wrap:!1}}),{c(){M=V("p"),M.innerHTML=u,U=o(),T=V("blockquote"),T.innerHTML=j,J=o(),w(s.$$.fragment),p=o(),C=V("p"),C.textContent=b,y=o(),d=V("ul"),d.innerHTML=F,this.h()},l(n){M=c(n,"P",{"data-svelte-h":!0}),m(M)!=="svelte-1pj6jx5"&&(M.innerHTML=u),U=r(n),T=c(n,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(T)!=="svelte-1xzajos"&&(T.innerHTML=j),J=r(n),f(s.$$.fragment,n),p=r(n),C=c(n,"P",{"data-svelte-h":!0}),m(C)!=="svelte-54z6pz"&&(C.textContent=b),y=r(n),d=c(n,"UL",{"data-svelte-h":!0}),m(d)!=="svelte-1evf3o1"&&(d.innerHTML=F),this.h()},h(){S(T,"class","tip")},m(n,g){e(n,M,g),e(n,U,g),e(n,T,g),e(n,J,g),N(s,n,g),e(n,p,g),e(n,C,g),e(n,y,g),e(n,d,g),a=!0},p:v,i(n){a||(I(s.$$.fragment,n),a=!0)},o(n){B(s.$$.fragment,n),a=!1},d(n){n&&(t(M),t(U),t(T),t(J),t(p),t(C),t(y),t(d)),h(s,n)}}}function Ts(Q){let M,u,U,T,j,J;return M=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[ps]},$$scope:{ctx:Q}}}),U=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[os]},$$scope:{ctx:Q}}}),j=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[rs]},$$scope:{ctx:Q}}}),{c(){w(M.$$.fragment),u=o(),w(U.$$.fragment),T=o(),w(j.$$.fragment)},l(s){f(M.$$.fragment,s),u=r(s),f(U.$$.fragment,s),T=r(s),f(j.$$.fragment,s)},m(s,p){N(M,s,p),e(s,u,p),N(U,s,p),e(s,T,p),N(j,s,p),J=!0},p(s,p){const C={};p&2&&(C.$$scope={dirty:p,ctx:s}),M.$set(C);const b={};p&2&&(b.$$scope={dirty:p,ctx:s}),U.$set(b);const y={};p&2&&(y.$$scope={dirty:p,ctx:s}),j.$set(y)},i(s){J||(I(M.$$.fragment,s),I(U.$$.fragment,s),I(j.$$.fragment,s),J=!0)},o(s){B(M.$$.fragment,s),B(U.$$.fragment,s),B(j.$$.fragment,s),J=!1},d(s){s&&(t(u),t(T)),h(M,s),h(U,s),h(j,s)}}}function js(Q){let M,u,U,T="预期输出：",j,J,s,p,C="这最后一步具体做了什么：",b,y,d="<li>我们使用 <code>InferenceClientModel</code> 类初始化 Hugging Face 模型</li> <li>我们将智能体 (Alfred) 创建为 <code>CodeAgent</code>，它可以执行 Python 代码来解决问题</li> <li>我们让 Alfred 检索一位名叫“Lady Ada Lovelace”的客人的信息</li>",F;return M=new $({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiUyMEh1Z2dpbmclMjBGYWNlJTIwJUU2JUE4JUExJUU1JTlFJThCJTBBbW9kZWwlMjAlM0QlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCgpJTBBJTBBJTIzJTIwJUU0JUJEJUJGJUU3JTk0JUE4JUU1JUFFJUJFJUU1JUFFJUEyJUU0JUJGJUExJUU2JTgxJUFGJUU1JUI3JUE1JUU1JTg1JUI3JUU1JTg4JTlCJUU1JUJCJUJBJUU2JTg4JTkxJUU0JUJCJUFDJUU3JTlBJTg0JUU2JTk5JTlBJUU0JUJDJTlBJUU2JTk5JUJBJUU4JTgzJUJEJUU0JUJEJTkzJTIwQWxmcmVkJTBBYWxmcmVkJTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCZ3Vlc3RfaW5mb190b29sJTVEJTJDJTIwbW9kZWwlM0Rtb2RlbCklMEElMEElMjMlMjBFeGFtcGxlJTIwcXVlcnklMjBBbGZyZWQlMjBtaWdodCUyMHJlY2VpdmUlMjBkdXJpbmclMjB0aGUlMjBnYWxhJTBBcmVzcG9uc2UlMjAlM0QlMjBhbGZyZWQucnVuKCUyMlRlbGwlMjBtZSUyMGFib3V0JTIwb3VyJTIwZ3Vlc3QlMjBuYW1lZCUyMCdMYWR5JTIwQWRhJTIwTG92ZWxhY2UnLiUyMiklMEElMEFwcmludCglMjIlRjAlOUYlOEUlQTklMjBBbGZyZWQncyUyMFJlc3BvbnNlJTNBJTIyKSUwQXByaW50KHJlc3BvbnNlKQ==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, InferenceClientModel

<span class="hljs-comment"># 初始化 Hugging Face 模型</span>
model = InferenceClientModel()

<span class="hljs-comment"># 使用宾客信息工具创建我们的晚会智能体 Alfred</span>
alfred = CodeAgent(tools=[guest_info_tool], model=model)

<span class="hljs-comment"># Example query Alfred might receive during the gala</span>
response = alfred.run(<span class="hljs-string">&quot;Tell me about our guest named &#x27;Lady Ada Lovelace&#x27;.&quot;</span>)

<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;🎩 Alfred&#x27;s Response:&quot;</span>)
<span class="hljs-built_in">print</span>(response)`,wrap:!1}}),J=new $({props:{code:"JUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUwQSVFNiVBMCVCOSVFNiU4RCVBRSVFNiU4OCU5MSVFNiVBMyU4MCVFNyVCNCVBMiVFNSU4OCVCMCVFNyU5QSU4NCVFNCVCRiVBMSVFNiU4MSVBRiVFRiVCQyU4QyVFOCU4OSVCRSVFOCVCRSVCRSVDMiVCNyVFNiVCNCU5QiVFNSVBNCVBQiVFOCU4RSVCMSVFNiU5NiVBRiVFNSVBNCVBQiVFNCVCQSVCQSVFNiU5OCVBRiVFNCVCOCU4MCVFNCVCRCU4RCVFNSU4RiU5NyVFNCVCQSVCQSVFNSVCMCU4QSVFNiU5NSVBQyVFNyU5QSU4NCVFNiU5NSVCMCVFNSVBRCVBNiVFNSVBRSVCNiVFNSU5MiU4QyVFNiU5QyU4QiVFNSU4RiU4QiVFMyU4MCU4MiVFNSVBNSVCOSVFNSU5QiVBMCVFNSU4NSVCNiVFNSU5QyVBOCVFNiU5NSVCMCVFNSVBRCVBNiVFNSU5MiU4QyVFOCVBRSVBMSVFNyVBRSU5NyVFNiU5QyVCQSVFOSVBMiU4NiVFNSU5RiU5RiVFNyU5QSU4NCVFNSVCQyU4MCVFNSU4OCU5QiVFNiU4MCVBNyVFNSVCNyVBNSVFNCVCRCU5QyVFOCU4MCU4QyVFOSU5NyVCQiVFNSU5MCU4RCVFRiVCQyU4QyVFNSVCOSVCNiVFNSU5QiVBMCVFNSU4NSVCNiVFNSU5QyVBOCVFNiU5RiVBNSVFNSVCMCU5NCVFNiU5NiVBRiVDMiVCNyVFNSVCNyVCNCVFOCVCNCU5RCVFNSVBNSU4NyVFNyU5QSU4NCVFNSU4OCU4NiVFNiU5RSU5MCVFNiU5QyVCQSVFNiU5NiVCOSVFOSU5RCVBMiVFNyU5QSU4NCVFOCVCNCVBMSVFNyU4QyVBRSVFOCU4MCU4QyVFOCVBMiVBQiVFOCVBQSU4OSVFNCVCOCVCQSVFNyVBQyVBQyVFNCVCOCU4MCVFNCVCRCU4RCVFOCVBRSVBMSVFNyVBRSU5NyVFNiU5QyVCQSVFNyVBOCU4QiVFNSVCQSU4RiVFNSU5MSU5OCVFMyU4MCU4MiVFNSVBNSVCOSVFNyU5QSU4NCVFNyU5NCVCNSVFNSVBRCU5MCVFOSU4MiVBRSVFNCVCQiVCNiVFNSU5QyVCMCVFNSU5RCU4MCVFNiU5OCVBRiUyMGFkYS5sb3ZlbGFjZSU0MGV4YW1wbGUuY29tJUUzJTgwJTgy",highlighted:`🎩 Alfred<span class="hljs-symbol">&#x27;s</span> Response:
根据我检索到的信息，艾达·洛夫莱斯夫人是一位受人尊敬的数学家和朋友。她因其在数学和计算机领域的开创性工作而闻名，并因其在查尔斯·巴贝奇的分析机方面的贡献而被誉为第一位计算机程序员。她的电子邮件地址是 ada.lovelace@example.com。`,wrap:!1}}),{c(){w(M.$$.fragment),u=o(),U=V("p"),U.textContent=T,j=o(),w(J.$$.fragment),s=o(),p=V("p"),p.textContent=C,b=o(),y=V("ul"),y.innerHTML=d},l(a){f(M.$$.fragment,a),u=r(a),U=c(a,"P",{"data-svelte-h":!0}),m(U)!=="svelte-vb4qji"&&(U.textContent=T),j=r(a),f(J.$$.fragment,a),s=r(a),p=c(a,"P",{"data-svelte-h":!0}),m(p)!=="svelte-155v302"&&(p.textContent=C),b=r(a),y=c(a,"UL",{"data-svelte-h":!0}),m(y)!=="svelte-1wuaj0c"&&(y.innerHTML=d)},m(a,n){N(M,a,n),e(a,u,n),e(a,U,n),e(a,j,n),N(J,a,n),e(a,s,n),e(a,p,n),e(a,b,n),e(a,y,n),F=!0},p:v,i(a){F||(I(M.$$.fragment,a),I(J.$$.fragment,a),F=!0)},o(a){B(M.$$.fragment,a),B(J.$$.fragment,a),F=!1},d(a){a&&(t(u),t(U),t(j),t(s),t(p),t(b),t(y)),h(M,a),h(J,a)}}}function Vs(Q){let M,u,U,T="预期输出：",j,J,s,p,C="这最后一步具体做了什么：",b,y,d="<li>我们使用 <code>HuggingFaceInferenceAPI</code> 类初始化 Hugging Face 模型</li> <li>我们将智能体 (Alfred) 创建为 <code>AgentWorkflow</code>，其中包含我们刚刚创建的工具</li> <li>我们请求 Alfred 检索名为“Lady Ada Lovelace”的客人的信息</li>",F;return M=new $({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUuYWdlbnQud29ya2Zsb3clMjBpbXBvcnQlMjBBZ2VudFdvcmtmbG93JTBBZnJvbSUyMGxsYW1hX2luZGV4LmxsbXMuaHVnZ2luZ2ZhY2VfYXBpJTIwaW1wb3J0JTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUEklMEElMEElMjMlMjAlRTUlODglOUQlRTUlQTclOEIlRTUlOEMlOTYlMjBIdWdnaW5nJTIwRmFjZSUyMCVFNiVBOCVBMSVFNSU5RSU4QiUwQWxsbSUyMCUzRCUyMEh1Z2dpbmdGYWNlSW5mZXJlbmNlQVBJKG1vZGVsX25hbWUlM0QlMjJRd2VuJTJGUXdlbjIuNS1Db2Rlci0zMkItSW5zdHJ1Y3QlMjIpJTBBJTBBJTIzJTIwJUU0JUJEJUJGJUU3JTk0JUE4JUU1JUFFJUJFJUU1JUFFJUEyJUU0JUJGJUExJUU2JTgxJUFGJUU1JUI3JUE1JUU1JTg1JUI3JUU1JTg4JTlCJUU1JUJCJUJBJUU2JTg4JTkxJUU0JUJCJUFDJUU3JTlBJTg0JUU2JTk5JTlBJUU0JUJDJTlBJUU2JTk5JUJBJUU4JTgzJUJEJUU0JUJEJTkzJTIwQWxmcmVkJTBBYWxmcmVkJTIwJTNEJTIwQWdlbnRXb3JrZmxvdy5mcm9tX3Rvb2xzX29yX2Z1bmN0aW9ucyglMEElMjAlMjAlMjAlMjAlNUJndWVzdF9pbmZvX3Rvb2wlNUQlMkMlMEElMjAlMjAlMjAlMjBsbG0lM0RsbG0lMkMlMEEpJTBBJTBBJTIzJTIwRXhhbXBsZSUyMHF1ZXJ5JTIwQWxmcmVkJTIwbWlnaHQlMjByZWNlaXZlJTIwZHVyaW5nJTIwdGhlJTIwZ2FsYSUwQXJlc3BvbnNlJTIwJTNEJTIwYXdhaXQlMjBhbGZyZWQucnVuKCUyMlRlbGwlMjBtZSUyMGFib3V0JTIwb3VyJTIwZ3Vlc3QlMjBuYW1lZCUyMCdMYWR5JTIwQWRhJTIwTG92ZWxhY2UnLiUyMiklMEElMEFwcmludCglMjIlRjAlOUYlOEUlQTklMjBBbGZyZWQncyUyMFJlc3BvbnNlJTNBJTIyKSUwQXByaW50KHJlc3BvbnNlKQ==",highlighted:`<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.llms.huggingface_api <span class="hljs-keyword">import</span> HuggingFaceInferenceAPI

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

<span class="hljs-comment"># 使用宾客信息工具创建我们的晚会智能体 Alfred</span>
alfred = AgentWorkflow.from_tools_or_functions(
    [guest_info_tool],
    llm=llm,
)

<span class="hljs-comment"># Example query Alfred might receive during the gala</span>
response = <span class="hljs-keyword">await</span> alfred.run(<span class="hljs-string">&quot;Tell me about our guest named &#x27;Lady Ada Lovelace&#x27;.&quot;</span>)

<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;🎩 Alfred&#x27;s Response:&quot;</span>)
<span class="hljs-built_in">print</span>(response)`,wrap:!1}}),J=new $({props:{code:"JUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUwQUxhZHklMjBBZGElMjBMb3ZlbGFjZSUyMCVFNiU5OCVBRiVFNCVCOCU4MCVFNCVCRCU4RCVFNSU4RiU5NyVFNCVCQSVCQSVFNSVCMCU4QSVFNiU5NSVBQyVFNyU5QSU4NCVFNiU5NSVCMCVFNSVBRCVBNiVFNSVBRSVCNiVFNSU5MiU4QyVFNiU5QyU4QiVFNSU4RiU4QiVFRiVCQyU4QyVFNSU5QiVBMCVFNSU4NSVCNiVFNSU5QyVBOCVFNiU5NSVCMCVFNSVBRCVBNiVFNSU5MiU4QyVFOCVBRSVBMSVFNyVBRSU5NyVFOSVBMiU4NiVFNSU5RiU5RiVFNyU5QSU4NCVFNSVCQyU4MCVFNSU4OCU5QiVFNiU4MCVBNyVFNSVCNyVBNSVFNCVCRCU5QyVFOCU4MCU4QyVFOSU5NyVCQiVFNSU5MCU4RCVFMyU4MCU4MiVFNSVBNSVCOSVFNSU5QiVBMCVFNSU4RiU4MiVFNCVCOCU4RSVFNiU5RiVBNSVFNSVCMCU5NCVFNiU5NiVBRiVDMiVCNyVFNSVCNyVCNCVFOCVCNCU5RCVFNSVBNSU4NyVFNyU5QSU4NCVFNSU4OCU4NiVFNiU5RSU5MCVFNiU5QyVCQSVFNyVBMCU5NCVFNyVBOSVCNiVFOCU4MCU4QyVFOCVBMiVBQiVFOCVBQSU4OSVFNCVCOCVCQSVFNyVBQyVBQyVFNCVCOCU4MCVFNCVCRCU4RCVFOCVBRSVBMSVFNyVBRSU5NyVFNiU5QyVCQSVFNyVBOCU4QiVFNSVCQSU4RiVFNSU5MSU5OCVFMyU4MCU4MiVFNSVBNSVCOSVFNyU5QSU4NCVFOSU4MiVBRSVFNyVBRSVCMSVFNiU5OCVBRiUyMGFkYS5sb3ZlbGFjZSU0MGV4YW1wbGUuY29tJUUzJTgwJTgy",highlighted:`🎩 Alfred<span class="hljs-symbol">&#x27;s</span> Response:
Lady Ada Lovelace 是一位受人尊敬的数学家和朋友，因其在数学和计算领域的开创性工作而闻名。她因参与查尔斯·巴贝奇的分析机研究而被誉为第一位计算机程序员。她的邮箱是 ada.lovelace@example.com。`,wrap:!1}}),{c(){w(M.$$.fragment),u=o(),U=V("p"),U.textContent=T,j=o(),w(J.$$.fragment),s=o(),p=V("p"),p.textContent=C,b=o(),y=V("ul"),y.innerHTML=d},l(a){f(M.$$.fragment,a),u=r(a),U=c(a,"P",{"data-svelte-h":!0}),m(U)!=="svelte-vb4qji"&&(U.textContent=T),j=r(a),f(J.$$.fragment,a),s=r(a),p=c(a,"P",{"data-svelte-h":!0}),m(p)!=="svelte-155v302"&&(p.textContent=C),b=r(a),y=c(a,"UL",{"data-svelte-h":!0}),m(y)!=="svelte-15zb6ce"&&(y.innerHTML=d)},m(a,n){N(M,a,n),e(a,u,n),e(a,U,n),e(a,j,n),N(J,a,n),e(a,s,n),e(a,p,n),e(a,b,n),e(a,y,n),F=!0},p:v,i(a){F||(I(M.$$.fragment,a),I(J.$$.fragment,a),F=!0)},o(a){B(M.$$.fragment,a),B(J.$$.fragment,a),F=!1},d(a){a&&(t(u),t(U),t(j),t(s),t(p),t(b),t(y)),h(M,a),h(J,a)}}}function cs(Q){let M,u,U,T="预期输出：",j,J,s,p,C="这最后一步具体做了什么：",b,y,d="<li>我们使用 <code>HuggingFaceEndpoint</code> 类初始化 Hugging Face 模型。我们还生成了一个聊天界面并附加了工具。</li> <li>我们将智能体 (Alfred) 创建为一个 <code>StateGraph</code>，它使用一条边连接两个节点（<code>Assistant</code> 和 <code>tools</code>）。</li> <li>我们让 Alfred 检索一位名叫“Lady Ada Lovelace”的客人的信息。</li>",F;return M=new $({props:{code:"ZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyMFR5cGVkRGljdCUyQyUyMEFubm90YXRlZCUwQWZyb20lMjBsYW5nZ3JhcGguZ3JhcGgubWVzc2FnZSUyMGltcG9ydCUyMGFkZF9tZXNzYWdlcyUwQWZyb20lMjBsYW5nY2hhaW5fY29yZS5tZXNzYWdlcyUyMGltcG9ydCUyMEFueU1lc3NhZ2UlMkMlMjBIdW1hbk1lc3NhZ2UlMkMlMjBBSU1lc3NhZ2UlMEFmcm9tJTIwbGFuZ2dyYXBoLnByZWJ1aWx0JTIwaW1wb3J0JTIwVG9vbE5vZGUlMEFmcm9tJTIwbGFuZ2dyYXBoLmdyYXBoJTIwaW1wb3J0JTIwU1RBUlQlMkMlMjBTdGF0ZUdyYXBoJTBBZnJvbSUyMGxhbmdncmFwaC5wcmVidWlsdCUyMGltcG9ydCUyMHRvb2xzX2NvbmRpdGlvbiUwQWZyb20lMjBsYW5nY2hhaW5faHVnZ2luZ2ZhY2UlMjBpbXBvcnQlMjBIdWdnaW5nRmFjZUVuZHBvaW50JTJDJTIwQ2hhdEh1Z2dpbmdGYWNlJTBBJTBBJTIzJTIwJUU3JTk0JTlGJUU2JTg4JTkwJUU4JTgxJThBJUU1JUE0JUE5JUU3JTk1JThDJUU5JTlEJUEyJUVGJUJDJThDJUU1JThDJTg1JUU2JThCJUFDJUU1JUI3JUE1JUU1JTg1JUI3JTBBbGxtJTIwJTNEJTIwSHVnZ2luZ0ZhY2VFbmRwb2ludCglMEElMjAlMjAlMjAlMjByZXBvX2lkJTNEJTIyUXdlbiUyRlF3ZW4yLjUtQ29kZXItMzJCLUluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwaHVnZ2luZ2ZhY2VodWJfYXBpX3Rva2VuJTNESFVHR0lOR0ZBQ0VIVUJfQVBJX1RPS0VOJTJDJTBBKSUwQSUwQWNoYXQlMjAlM0QlMjBDaGF0SHVnZ2luZ0ZhY2UobGxtJTNEbGxtJTJDJTIwdmVyYm9zZSUzRFRydWUpJTBBdG9vbHMlMjAlM0QlMjAlNUJndWVzdF9pbmZvX3Rvb2wlNUQlMEFjaGF0X3dpdGhfdG9vbHMlMjAlM0QlMjBjaGF0LmJpbmRfdG9vbHModG9vbHMpJTBBJTBBJTIzJTIwJUU3JTk0JTlGJUU2JTg4JTkwJTIwQWdlbnRTdGF0ZSUyMCVFNSU5MiU4QyUyMEFnZW50JTIwJUU1JTlCJUJFJTBBY2xhc3MlMjBBZ2VudFN0YXRlKFR5cGVkRGljdCklM0ElMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUzQSUyMEFubm90YXRlZCU1Qmxpc3QlNUJBbnlNZXNzYWdlJTVEJTJDJTIwYWRkX21lc3NhZ2VzJTVEJTBBJTBBZGVmJTIwYXNzaXN0YW50KHN0YXRlJTNBJTIwQWdlbnRTdGF0ZSklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJtZXNzYWdlcyUyMiUzQSUyMCU1QmNoYXRfd2l0aF90b29scy5pbnZva2Uoc3RhdGUlNUIlMjJtZXNzYWdlcyUyMiU1RCklNUQlMkMlMEElMjAlMjAlMjAlMjAlN0QlMEElMEElMjMlMjMlMjAlRTYlOUUlODQlRTUlQkIlQkElRTYlQjUlODElRTclQTglOEIlRTUlOUIlQkUlMEFidWlsZGVyJTIwJTNEJTIwU3RhdGVHcmFwaChBZ2VudFN0YXRlKSUwQSUwQSUyMyUyMCVFNSVBRSU5QSVFNCVCOSU4OSVFOCU4QSU4MiVFNyU4MiVCOSVFRiVCQyU5QSVFOCVCRiU5OSVFNCVCQSU5QiVFOCU4QSU4MiVFNyU4MiVCOSVFNSVBRSU4QyVFNiU4OCU5MCVFNSVCNyVBNSVFNCVCRCU5QyUwQWJ1aWxkZXIuYWRkX25vZGUoJTIyYXNzaXN0YW50JTIyJTJDJTIwYXNzaXN0YW50KSUwQWJ1aWxkZXIuYWRkX25vZGUoJTIydG9vbHMlMjIlMkMlMjBUb29sTm9kZSh0b29scykpJTBBJTBBJTIzJTIwJUU1JUFFJTlBJUU0JUI5JTg5JUU4JUJFJUI5JUVGJUJDJTlBJUU4JUJGJTk5JUU0JUJBJTlCJUU1JTg2JUIzJUU1JUFFJTlBJUU0JUJBJTg2JUU2JThFJUE3JUU1JTg4JUI2JUU2JUI1JTgxJUU1JUE2JTgyJUU0JUJEJTk1JUU3JUE3JUJCJUU1JThBJUE4JTBBYnVpbGRlci5hZGRfZWRnZShTVEFSVCUyQyUyMCUyMmFzc2lzdGFudCUyMiklMEFidWlsZGVyLmFkZF9jb25kaXRpb25hbF9lZGdlcyglMEElMjAlMjAlMjAlMjAlMjJhc3Npc3RhbnQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjMlMjBJZiUyMHRoZSUyMGxhdGVzdCUyMG1lc3NhZ2UlMjByZXF1aXJlcyUyMGElMjB0b29sJTJDJTIwcm91dGUlMjB0byUyMHRvb2xzJTBBJTIwJTIwJTIwJTIwJTIzJTIwT3RoZXJ3aXNlJTJDJTIwcHJvdmlkZSUyMGElMjBkaXJlY3QlMjByZXNwb25zZSUwQSUyMCUyMCUyMCUyMHRvb2xzX2NvbmRpdGlvbiUyQyUwQSklMEFidWlsZGVyLmFkZF9lZGdlKCUyMnRvb2xzJTIyJTJDJTIwJTIyYXNzaXN0YW50JTIyKSUwQWFsZnJlZCUyMCUzRCUyMGJ1aWxkZXIuY29tcGlsZSgpJTBBJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUJIdW1hbk1lc3NhZ2UoY29udGVudCUzRCUyMlRlbGwlMjBtZSUyMGFib3V0JTIwb3VyJTIwZ3Vlc3QlMjBuYW1lZCUyMCdMYWR5JTIwQWRhJTIwTG92ZWxhY2UnLiUyMiklNUQlMEFyZXNwb25zZSUyMCUzRCUyMGFsZnJlZC5pbnZva2UoJTdCJTIybWVzc2FnZXMlMjIlM0ElMjBtZXNzYWdlcyU3RCklMEElMEFwcmludCglMjIlRjAlOUYlOEUlQTklMjBBbGZyZWQncyUyMFJlc3BvbnNlJTNBJTIyKSUwQXByaW50KHJlc3BvbnNlJTVCJ21lc3NhZ2VzJyU1RCU1Qi0xJTVELmNvbnRlbnQp",highlighted:`<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> TypedDict, Annotated
<span class="hljs-keyword">from</span> langgraph.graph.message <span class="hljs-keyword">import</span> add_messages
<span class="hljs-keyword">from</span> langchain_core.messages <span class="hljs-keyword">import</span> AnyMessage, HumanMessage, AIMessage
<span class="hljs-keyword">from</span> langgraph.prebuilt <span class="hljs-keyword">import</span> ToolNode
<span class="hljs-keyword">from</span> langgraph.graph <span class="hljs-keyword">import</span> START, StateGraph
<span class="hljs-keyword">from</span> langgraph.prebuilt <span class="hljs-keyword">import</span> tools_condition
<span class="hljs-keyword">from</span> langchain_huggingface <span class="hljs-keyword">import</span> HuggingFaceEndpoint, ChatHuggingFace

<span class="hljs-comment"># 生成聊天界面，包括工具</span>
llm = HuggingFaceEndpoint(
    repo_id=<span class="hljs-string">&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</span>,
    huggingfacehub_api_token=HUGGINGFACEHUB_API_TOKEN,
)

chat = ChatHuggingFace(llm=llm, verbose=<span class="hljs-literal">True</span>)
tools = [guest_info_tool]
chat_with_tools = chat.bind_tools(tools)

<span class="hljs-comment"># 生成 AgentState 和 Agent 图</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">AgentState</span>(<span class="hljs-title class_ inherited__">TypedDict</span>):
    messages: Annotated[<span class="hljs-built_in">list</span>[AnyMessage], add_messages]

<span class="hljs-keyword">def</span> <span class="hljs-title function_">assistant</span>(<span class="hljs-params">state: AgentState</span>):
    <span class="hljs-keyword">return</span> {
        <span class="hljs-string">&quot;messages&quot;</span>: [chat_with_tools.invoke(state[<span class="hljs-string">&quot;messages&quot;</span>])],
    }

<span class="hljs-comment">## 构建流程图</span>
builder = StateGraph(AgentState)

<span class="hljs-comment"># 定义节点：这些节点完成工作</span>
builder.add_node(<span class="hljs-string">&quot;assistant&quot;</span>, assistant)
builder.add_node(<span class="hljs-string">&quot;tools&quot;</span>, ToolNode(tools))

<span class="hljs-comment"># 定义边：这些决定了控制流如何移动</span>
builder.add_edge(START, <span class="hljs-string">&quot;assistant&quot;</span>)
builder.add_conditional_edges(
    <span class="hljs-string">&quot;assistant&quot;</span>,
    <span class="hljs-comment"># If the latest message requires a tool, route to tools</span>
    <span class="hljs-comment"># Otherwise, provide a direct response</span>
    tools_condition,
)
builder.add_edge(<span class="hljs-string">&quot;tools&quot;</span>, <span class="hljs-string">&quot;assistant&quot;</span>)
alfred = builder.<span class="hljs-built_in">compile</span>()

messages = [HumanMessage(content=<span class="hljs-string">&quot;Tell me about our guest named &#x27;Lady Ada Lovelace&#x27;.&quot;</span>)]
response = alfred.invoke({<span class="hljs-string">&quot;messages&quot;</span>: messages})

<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;🎩 Alfred&#x27;s Response:&quot;</span>)
<span class="hljs-built_in">print</span>(response[<span class="hljs-string">&#x27;messages&#x27;</span>][-<span class="hljs-number">1</span>].content)`,wrap:!1}}),J=new $({props:{code:"JUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUwQUxhZHklMjBBZGElMjBMb3ZlbGFjZSUyMCVFNiU5OCVBRiVFNCVCOCU4MCVFNCVCRCU4RCVFNSU4RiU5NyVFNCVCQSVCQSVFNSVCMCU4QSVFNiU5NSVBQyVFNyU5QSU4NCVFNiU5NSVCMCVFNSVBRCVBNiVFNSVBRSVCNiVFNSU5MiU4QyVFOCVBRSVBMSVFNyVBRSU5NyVFNiU5QyVCQSVFOSVBMiU4NiVFNSU5RiU5RiVFNyU5QSU4NCVFNSU4NSU4OCVFOSVBOSVCMSVFRiVCQyU4QyVFNyU5NCVCMSVFNCVCQSU4RSVFNSVBNSVCOSVFNSU5QyVBOCVFNiU5RiVBNSVFNSVCMCU5NCVFNiU5NiVBRiVDMiVCNyVFNSVCNyVCNCVFOCVCNCU5RCVFNSVBNSU4NyVFNyU5QSU4NCVFNSU4OCU4NiVFNiU5RSU5MCVFNiU5QyVCQSVFNCVCOCU4QSVFNiU4OSU4MCVFNSU4MSU5QSVFNyU5QSU4NCVFNSVCNyVBNSVFNCVCRCU5QyVFRiVCQyU4QyVFNSVBNSVCOSVFNyVCQiU4RiVFNSVCOCVCOCVFOCVBMiVBQiVFOCVBQSU4OSVFNCVCOCVCQSVFNyVBQyVBQyVFNCVCOCU4MCVFNCVCRCU4RCVFOCVBRSVBMSVFNyVBRSU5NyVFNiU5QyVCQSVFNyVBOCU4QiVFNSVCQSU4RiVFNSU5MSU5OCVFMyU4MCU4Mg==",highlighted:`🎩 Alfred<span class="hljs-symbol">&#x27;s</span> Response:
Lady Ada Lovelace 是一位受人尊敬的数学家和计算机领域的先驱，由于她在查尔斯·巴贝奇的分析机上所做的工作，她经常被誉为第一位计算机程序员。`,wrap:!1}}),{c(){w(M.$$.fragment),u=o(),U=V("p"),U.textContent=T,j=o(),w(J.$$.fragment),s=o(),p=V("p"),p.textContent=C,b=o(),y=V("ul"),y.innerHTML=d},l(a){f(M.$$.fragment,a),u=r(a),U=c(a,"P",{"data-svelte-h":!0}),m(U)!=="svelte-vb4qji"&&(U.textContent=T),j=r(a),f(J.$$.fragment,a),s=r(a),p=c(a,"P",{"data-svelte-h":!0}),m(p)!=="svelte-155v302"&&(p.textContent=C),b=r(a),y=c(a,"UL",{"data-svelte-h":!0}),m(y)!=="svelte-1gd47hp"&&(y.innerHTML=d)},m(a,n){N(M,a,n),e(a,u,n),e(a,U,n),e(a,j,n),N(J,a,n),e(a,s,n),e(a,p,n),e(a,b,n),e(a,y,n),F=!0},p:v,i(a){F||(I(M.$$.fragment,a),I(J.$$.fragment,a),F=!0)},o(a){B(M.$$.fragment,a),B(J.$$.fragment,a),F=!1},d(a){a&&(t(u),t(U),t(j),t(s),t(p),t(b),t(y)),h(M,a),h(J,a)}}}function us(Q){let M,u,U,T,j,J;return M=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[js]},$$scope:{ctx:Q}}}),U=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[Vs]},$$scope:{ctx:Q}}}),j=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[cs]},$$scope:{ctx:Q}}}),{c(){w(M.$$.fragment),u=o(),w(U.$$.fragment),T=o(),w(j.$$.fragment)},l(s){f(M.$$.fragment,s),u=r(s),f(U.$$.fragment,s),T=r(s),f(j.$$.fragment,s)},m(s,p){N(M,s,p),e(s,u,p),N(U,s,p),e(s,T,p),N(j,s,p),J=!0},p(s,p){const C={};p&2&&(C.$$scope={dirty:p,ctx:s}),M.$set(C);const b={};p&2&&(b.$$scope={dirty:p,ctx:s}),U.$set(b);const y={};p&2&&(y.$$scope={dirty:p,ctx:s}),j.$set(y)},i(s){J||(I(M.$$.fragment,s),I(U.$$.fragment,s),I(j.$$.fragment,s),J=!0)},o(s){B(M.$$.fragment,s),B(U.$$.fragment,s),B(j.$$.fragment,s),J=!1},d(s){s&&(t(u),t(T)),h(M,s),h(U,s),h(j,s)}}}function ys(Q){let M,u,U,T,j,J,s,p,C,b="您信赖的智能体 Alfred 正在筹备本世纪最盛大的晚会。为确保活动顺利进行，Alfred 需要快速获取最新宾客信息。让我们通过定制化的检索增强生成（RAG）工具（基于专属数据集）为 Alfred 赋能。",y,d,F,a,n="试想 Alfred 在宾客间穿梭时需即时调取详细信息，传统大语言模型（LLM）可能面临以下挑战：",g,X,mt="<li>宾客名单属于特定活动数据，不在模型训练范围内</li> <li>宾客信息可能频繁变更或更新</li> <li>需精确检索电子邮件地址等细节信息</li>",hl,Y,Ct="这正是检索增强生成（RAG）技术的优势所在！通过结合检索系统与 LLM，Alfred 可按需获取准确、实时的宾客信息。",bl,k,dt="<p>您可以选择课程涵盖的任何框架实现本用例，请通过代码标签页选择偏好方案。</p>",gl,q,Fl,H,wt="我们将以 Hugging Face Space 为开发环境，采用结构化 Python 项目构建智能体。这种架构通过功能模块化实现代码整洁，更贴近实际部署场景。",Ql,z,Sl,O,ft="<li><strong><code>tools.py</code></strong> – 为智能体提供辅助工具</li> <li><strong><code>retriever.py</code></strong> – 实现支持知识访问的检索功能</li> <li><strong><code>app.py</code></strong> – 整合所有组件形成完整功能智能体（将在本单元最后完成）</li>",$l,L,Nt='实操参考：<a href="https://huggingface.co/spaces/agents-course/Unit_3_Agentic_RAG" rel="nofollow">Hugging Face Space 示例</a>，该空间已部署本单元开发的智能体增强 RAG 系统，欢迎克隆体验！',Rl,D,It="可直接测试下方智能体：",Zl,Z,Bt,Al,P,El,K,ht='数据集 <a href="https://huggingface.co/datasets/agents-course/unit3-invitees/" rel="nofollow"><code>agents-course/unit3-invitees</code></a> 包含以下字段：',vl,ll,bt="<li><strong>Name</strong>: 宾客全名</li> <li><strong>Relation</strong>: 与主办方关系</li> <li><strong>Description</strong>: 简要传记或趣闻</li> <li><strong>Email Address</strong>: 邀请函发送及跟进联系方式</li>",kl,tl,gt="数据集预览：",Gl,A,Ft,Wl,G,Qt="<p>实际场景可扩展数据集字段，包含饮食偏好、礼品兴趣、禁忌话题等对主持人有用的详细信息。</p>",xl,sl,_l,el,St="我们将创建 Alfred 在晚会期间快速检索宾客信息的定制工具，分三步实现：",Xl,nl,$t="<li>加载并预处理数据集</li> <li>创建检索工具</li> <li>工具与 Alfred 集成</li>",Yl,al,ql,il,Rt="首先将原始宾客数据转换为适合检索的格式：",Hl,W,zl,Ml,Zt="在上面的代码中，我们：",Ol,Ul,At="<li>加载数据集</li> <li>将每条房客记录转换为包含格式化内容的 “Document” 对象</li> <li>将 “Document” 对象存储在列表中</li>",Ll,Jl,Et="这意味着我们已经准备好所有数据，可以开始配置检索功能了。",Dl,pl,Pl,ol,vt="现在，让我们创建一个自定义工具，Alfred 可以使用它来搜索房客信息。",Kl,x,lt,rl,tt,Tl,kt="最后，让我们创建智能体并为其配备自定义工具，将所有内容整合在一起：",st,_,et,jl,nt,Vl,Gt="在晚会上，对话可能像这样进行：",at,cl,Wt="<strong>你</strong>：“Alfred，那位正在和大使说话的先生是谁？”",it,ul,xt="<strong>Alfred</strong> <em>快速搜索嘉宾数据库</em> “先生，那是尼古拉·特斯拉博士。他是你大学时代的老朋友。他最近申请了一种新的无线能量传输系统的专利，很乐意和你讨论一下。不过别忘了，他对鸽子很感兴趣，所以这或许会成为一次很好的闲聊。”",Mt,yl,Ut,ml,Jt,Cl,_t="既然 Alfred 可以检索宾客信息，不妨考虑如何增强这个系统：",pt,dl,Xt='<li><strong>改进检索器</strong>，使用更复杂的算法，例如 <a href="https://www.sbert.net/" rel="nofollow">sentence-transformers</a></li> <li><strong>实现对话记忆</strong>，让 Alfred 记住之前的互动</li> <li><strong>结合网页搜索</strong>，获取陌生宾客的最新信息</li> <li><strong>整合多个索引</strong>，从经过验证的来源获取更完整的信息</li>',ot,wl,Yt="现在，Alfred 已经完全有能力轻松处理宾客的咨询，确保您的晚会成为本世纪最精致、最令人愉悦的盛事！",rt,fl,qt=`<提示>
尝试扩展检索工具，使其能够根据每位宾客的兴趣或背景返回对话开场白。您将如何修改该工具来实现这一点？`,Tt,Nl,Ht=`完成后，在 <code>retriever.py</code> 文件中实现您的宾客检索工具。
&lt;/提示&gt;`,jt,Il,Vt,Bl,ct;return j=new ns({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),s=new R({props:{title:"创建宾客信息检索生成（RAG）工具",local:"创建宾客信息检索生成rag工具",headingTag:"h1"}}),d=new R({props:{title:"为何选择 RAG 技术？",local:"为何选择-rag-技术",headingTag:"h2"}}),q=new R({props:{title:"应用搭建",local:"应用搭建",headingTag:"h2"}}),z=new R({props:{title:"项目结构",local:"项目结构",headingTag:"h3"}}),P=new R({props:{title:"数据集概览",local:"数据集概览",headingTag:"h2"}}),sl=new R({props:{title:"构建宾客信息工具",local:"构建宾客信息工具",headingTag:"h2"}}),al=new R({props:{title:"步骤一：加载并预处理数据集",local:"步骤一加载并预处理数据集",headingTag:"h3"}}),W=new yt({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[Js]},$$scope:{ctx:Q}}}),pl=new R({props:{title:"步骤 2：创建检索工具",local:"步骤-2创建检索工具",headingTag:"h3"}}),x=new yt({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[Ts]},$$scope:{ctx:Q}}}),rl=new R({props:{title:"步骤 3：将工具与 Alfred 集成",local:"步骤-3将工具与-alfred-集成",headingTag:"h3"}}),_=new yt({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[us]},$$scope:{ctx:Q}}}),jl=new R({props:{title:"互动示例",local:"互动示例",headingTag:"h2"}}),yl=new $({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIybmFtZSUyMiUzQSUyMCUyMkRyLiUyME5pa29sYSUyMFRlc2xhJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIycmVsYXRpb24lMjIlM0ElMjAlMjJvbGQlMjBmcmllbmQlMjBmcm9tJTIwdW5pdmVyc2l0eSUyMGRheXMlMjIlMkMlMjAlMjAlMEElMjAlMjAlMjAlMjAlMjJkZXNjcmlwdGlvbiUyMiUzQSUyMCUyMkRyLiUyME5pa29sYSUyMFRlc2xhJTIwaXMlMjBhbiUyMG9sZCUyMGZyaWVuZCUyMGZyb20lMjB5b3VyJTIwdW5pdmVyc2l0eSUyMGRheXMuJTIwSGUncyUyMHJlY2VudGx5JTIwcGF0ZW50ZWQlMjBhJTIwbmV3JTIwd2lyZWxlc3MlMjBlbmVyZ3klMjB0cmFuc21pc3Npb24lMjBzeXN0ZW0lMjBhbmQlMjB3b3VsZCUyMGJlJTIwZGVsaWdodGVkJTIwdG8lMjBkaXNjdXNzJTIwaXQlMjB3aXRoJTIweW91LiUyMEp1c3QlMjByZW1lbWJlciUyMGhlJ3MlMjBwYXNzaW9uYXRlJTIwYWJvdXQlMjBwaWdlb25zJTJDJTIwc28lMjB0aGF0JTIwbWlnaHQlMjBtYWtlJTIwZm9yJTIwZ29vZCUyMHNtYWxsJTIwdGFsay4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJlbWFpbCUyMiUzQSUyMCUyMm5pa29sYS50ZXNsYSU0MGdtYWlsLmNvbSUyMiUwQSU3RA==",highlighted:`<span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;name&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Dr. Nikola Tesla&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;relation&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;old friend from university days&quot;</span><span class="hljs-punctuation">,</span>  
    <span class="hljs-attr">&quot;description&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Dr. Nikola Tesla is an old friend from your university days. He&#x27;s recently patented a new wireless energy transmission system and would be delighted to discuss it with you. Just remember he&#x27;s passionate about pigeons, so that might make for good small talk.&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;email&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;nikola.tesla@gmail.com&quot;</span>
<span class="hljs-punctuation">}</span>`,wrap:!1}}),ml=new R({props:{title:"更进一步",local:"更进一步",headingTag:"h2"}}),Il=new as({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit3/agentic-rag/invitees.mdx"}}),{c(){M=V("meta"),u=o(),U=V("p"),T=o(),w(j.$$.fragment),J=o(),w(s.$$.fragment),p=o(),C=V("p"),C.textContent=b,y=o(),w(d.$$.fragment),F=o(),a=V("p"),a.textContent=n,g=o(),X=V("ol"),X.innerHTML=mt,hl=o(),Y=V("p"),Y.textContent=Ct,bl=o(),k=V("blockquote"),k.innerHTML=dt,gl=o(),w(q.$$.fragment),Fl=o(),H=V("p"),H.textContent=wt,Ql=o(),w(z.$$.fragment),Sl=o(),O=V("ul"),O.innerHTML=ft,$l=o(),L=V("p"),L.innerHTML=Nt,Rl=o(),D=V("p"),D.textContent=It,Zl=o(),Z=V("iframe"),Al=o(),w(P.$$.fragment),El=o(),K=V("p"),K.innerHTML=ht,vl=o(),ll=V("ul"),ll.innerHTML=bt,kl=o(),tl=V("p"),tl.textContent=gt,Gl=o(),A=V("iframe"),Wl=o(),G=V("blockquote"),G.innerHTML=Qt,xl=o(),w(sl.$$.fragment),_l=o(),el=V("p"),el.textContent=St,Xl=o(),nl=V("ol"),nl.innerHTML=$t,Yl=o(),w(al.$$.fragment),ql=o(),il=V("p"),il.textContent=Rt,Hl=o(),w(W.$$.fragment),zl=o(),Ml=V("p"),Ml.textContent=Zt,Ol=o(),Ul=V("ul"),Ul.innerHTML=At,Ll=o(),Jl=V("p"),Jl.textContent=Et,Dl=o(),w(pl.$$.fragment),Pl=o(),ol=V("p"),ol.textContent=vt,Kl=o(),w(x.$$.fragment),lt=o(),w(rl.$$.fragment),tt=o(),Tl=V("p"),Tl.textContent=kt,st=o(),w(_.$$.fragment),et=o(),w(jl.$$.fragment),nt=o(),Vl=V("p"),Vl.textContent=Gt,at=o(),cl=V("p"),cl.innerHTML=Wt,it=o(),ul=V("p"),ul.innerHTML=xt,Mt=o(),w(yl.$$.fragment),Ut=o(),w(ml.$$.fragment),Jt=o(),Cl=V("p"),Cl.textContent=_t,pt=o(),dl=V("ol"),dl.innerHTML=Xt,ot=o(),wl=V("p"),wl.textContent=Yt,rt=o(),fl=V("p"),fl.textContent=qt,Tt=o(),Nl=V("p"),Nl.innerHTML=Ht,jt=o(),w(Il.$$.fragment),Vt=o(),Bl=V("p"),this.h()},l(l){const i=ss("svelte-u9bgzb",document.head);M=c(i,"META",{name:!0,content:!0}),i.forEach(t),u=r(l),U=c(l,"P",{}),ut(U).forEach(t),T=r(l),f(j.$$.fragment,l),J=r(l),f(s.$$.fragment,l),p=r(l),C=c(l,"P",{"data-svelte-h":!0}),m(C)!=="svelte-ni58hz"&&(C.textContent=b),y=r(l),f(d.$$.fragment,l),F=r(l),a=c(l,"P",{"data-svelte-h":!0}),m(a)!=="svelte-hvkga8"&&(a.textContent=n),g=r(l),X=c(l,"OL",{"data-svelte-h":!0}),m(X)!=="svelte-1xe6k1a"&&(X.innerHTML=mt),hl=r(l),Y=c(l,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-18bm0pz"&&(Y.textContent=Ct),bl=r(l),k=c(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(k)!=="svelte-6rtiu1"&&(k.innerHTML=dt),gl=r(l),f(q.$$.fragment,l),Fl=r(l),H=c(l,"P",{"data-svelte-h":!0}),m(H)!=="svelte-1st8m4l"&&(H.textContent=wt),Ql=r(l),f(z.$$.fragment,l),Sl=r(l),O=c(l,"UL",{"data-svelte-h":!0}),m(O)!=="svelte-1a6bges"&&(O.innerHTML=ft),$l=r(l),L=c(l,"P",{"data-svelte-h":!0}),m(L)!=="svelte-1cdsklr"&&(L.innerHTML=Nt),Rl=r(l),D=c(l,"P",{"data-svelte-h":!0}),m(D)!=="svelte-qobm9m"&&(D.textContent=It),Zl=r(l),Z=c(l,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),ut(Z).forEach(t),Al=r(l),f(P.$$.fragment,l),El=r(l),K=c(l,"P",{"data-svelte-h":!0}),m(K)!=="svelte-1ji80vr"&&(K.innerHTML=ht),vl=r(l),ll=c(l,"UL",{"data-svelte-h":!0}),m(ll)!=="svelte-5izozk"&&(ll.innerHTML=bt),kl=r(l),tl=c(l,"P",{"data-svelte-h":!0}),m(tl)!=="svelte-tqhrae"&&(tl.textContent=gt),Gl=r(l),A=c(l,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),ut(A).forEach(t),Wl=r(l),G=c(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(G)!=="svelte-3ipj5o"&&(G.innerHTML=Qt),xl=r(l),f(sl.$$.fragment,l),_l=r(l),el=c(l,"P",{"data-svelte-h":!0}),m(el)!=="svelte-bmawv5"&&(el.textContent=St),Xl=r(l),nl=c(l,"OL",{"data-svelte-h":!0}),m(nl)!=="svelte-9bhzxd"&&(nl.innerHTML=$t),Yl=r(l),f(al.$$.fragment,l),ql=r(l),il=c(l,"P",{"data-svelte-h":!0}),m(il)!=="svelte-1rgegsv"&&(il.textContent=Rt),Hl=r(l),f(W.$$.fragment,l),zl=r(l),Ml=c(l,"P",{"data-svelte-h":!0}),m(Ml)!=="svelte-18g0znq"&&(Ml.textContent=Zt),Ol=r(l),Ul=c(l,"UL",{"data-svelte-h":!0}),m(Ul)!=="svelte-uk4sjn"&&(Ul.innerHTML=At),Ll=r(l),Jl=c(l,"P",{"data-svelte-h":!0}),m(Jl)!=="svelte-19nx22w"&&(Jl.textContent=Et),Dl=r(l),f(pl.$$.fragment,l),Pl=r(l),ol=c(l,"P",{"data-svelte-h":!0}),m(ol)!=="svelte-1j6dp92"&&(ol.textContent=vt),Kl=r(l),f(x.$$.fragment,l),lt=r(l),f(rl.$$.fragment,l),tt=r(l),Tl=c(l,"P",{"data-svelte-h":!0}),m(Tl)!=="svelte-1txfo3m"&&(Tl.textContent=kt),st=r(l),f(_.$$.fragment,l),et=r(l),f(jl.$$.fragment,l),nt=r(l),Vl=c(l,"P",{"data-svelte-h":!0}),m(Vl)!=="svelte-1553i9s"&&(Vl.textContent=Gt),at=r(l),cl=c(l,"P",{"data-svelte-h":!0}),m(cl)!=="svelte-1kcb56i"&&(cl.innerHTML=Wt),it=r(l),ul=c(l,"P",{"data-svelte-h":!0}),m(ul)!=="svelte-102x9e7"&&(ul.innerHTML=xt),Mt=r(l),f(yl.$$.fragment,l),Ut=r(l),f(ml.$$.fragment,l),Jt=r(l),Cl=c(l,"P",{"data-svelte-h":!0}),m(Cl)!=="svelte-4mmwa5"&&(Cl.textContent=_t),pt=r(l),dl=c(l,"OL",{"data-svelte-h":!0}),m(dl)!=="svelte-s48kxv"&&(dl.innerHTML=Xt),ot=r(l),wl=c(l,"P",{"data-svelte-h":!0}),m(wl)!=="svelte-1rnyu8f"&&(wl.textContent=Yt),rt=r(l),fl=c(l,"P",{"data-svelte-h":!0}),m(fl)!=="svelte-1fepywm"&&(fl.textContent=qt),Tt=r(l),Nl=c(l,"P",{"data-svelte-h":!0}),m(Nl)!=="svelte-1t5ix9x"&&(Nl.innerHTML=Ht),jt=r(l),f(Il.$$.fragment,l),Vt=r(l),Bl=c(l,"P",{}),ut(Bl).forEach(t),this.h()},h(){S(M,"name","hf:doc:metadata"),S(M,"content",ms),S(k,"class","tip"),Dt(Z.src,Bt="https://agents-course-unit-3-agentic-rag.hf.space")||S(Z,"src",Bt),S(Z,"frameborder","0"),S(Z,"width","850"),S(Z,"height","450"),Dt(A.src,Ft="https://huggingface.co/datasets/agents-course/unit3-invitees/embed/viewer/default/train")||S(A,"src",Ft),S(A,"frameborder","0"),S(A,"width","100%"),S(A,"height","560px"),S(G,"class","tip")},m(l,i){es(document.head,M),e(l,u,i),e(l,U,i),e(l,T,i),N(j,l,i),e(l,J,i),N(s,l,i),e(l,p,i),e(l,C,i),e(l,y,i),N(d,l,i),e(l,F,i),e(l,a,i),e(l,g,i),e(l,X,i),e(l,hl,i),e(l,Y,i),e(l,bl,i),e(l,k,i),e(l,gl,i),N(q,l,i),e(l,Fl,i),e(l,H,i),e(l,Ql,i),N(z,l,i),e(l,Sl,i),e(l,O,i),e(l,$l,i),e(l,L,i),e(l,Rl,i),e(l,D,i),e(l,Zl,i),e(l,Z,i),e(l,Al,i),N(P,l,i),e(l,El,i),e(l,K,i),e(l,vl,i),e(l,ll,i),e(l,kl,i),e(l,tl,i),e(l,Gl,i),e(l,A,i),e(l,Wl,i),e(l,G,i),e(l,xl,i),N(sl,l,i),e(l,_l,i),e(l,el,i),e(l,Xl,i),e(l,nl,i),e(l,Yl,i),N(al,l,i),e(l,ql,i),e(l,il,i),e(l,Hl,i),N(W,l,i),e(l,zl,i),e(l,Ml,i),e(l,Ol,i),e(l,Ul,i),e(l,Ll,i),e(l,Jl,i),e(l,Dl,i),N(pl,l,i),e(l,Pl,i),e(l,ol,i),e(l,Kl,i),N(x,l,i),e(l,lt,i),N(rl,l,i),e(l,tt,i),e(l,Tl,i),e(l,st,i),N(_,l,i),e(l,et,i),N(jl,l,i),e(l,nt,i),e(l,Vl,i),e(l,at,i),e(l,cl,i),e(l,it,i),e(l,ul,i),e(l,Mt,i),N(yl,l,i),e(l,Ut,i),N(ml,l,i),e(l,Jt,i),e(l,Cl,i),e(l,pt,i),e(l,dl,i),e(l,ot,i),e(l,wl,i),e(l,rt,i),e(l,fl,i),e(l,Tt,i),e(l,Nl,i),e(l,jt,i),N(Il,l,i),e(l,Vt,i),e(l,Bl,i),ct=!0},p(l,[i]){const zt={};i&2&&(zt.$$scope={dirty:i,ctx:l}),W.$set(zt);const Ot={};i&2&&(Ot.$$scope={dirty:i,ctx:l}),x.$set(Ot);const Lt={};i&2&&(Lt.$$scope={dirty:i,ctx:l}),_.$set(Lt)},i(l){ct||(I(j.$$.fragment,l),I(s.$$.fragment,l),I(d.$$.fragment,l),I(q.$$.fragment,l),I(z.$$.fragment,l),I(P.$$.fragment,l),I(sl.$$.fragment,l),I(al.$$.fragment,l),I(W.$$.fragment,l),I(pl.$$.fragment,l),I(x.$$.fragment,l),I(rl.$$.fragment,l),I(_.$$.fragment,l),I(jl.$$.fragment,l),I(yl.$$.fragment,l),I(ml.$$.fragment,l),I(Il.$$.fragment,l),ct=!0)},o(l){B(j.$$.fragment,l),B(s.$$.fragment,l),B(d.$$.fragment,l),B(q.$$.fragment,l),B(z.$$.fragment,l),B(P.$$.fragment,l),B(sl.$$.fragment,l),B(al.$$.fragment,l),B(W.$$.fragment,l),B(pl.$$.fragment,l),B(x.$$.fragment,l),B(rl.$$.fragment,l),B(_.$$.fragment,l),B(jl.$$.fragment,l),B(yl.$$.fragment,l),B(ml.$$.fragment,l),B(Il.$$.fragment,l),ct=!1},d(l){l&&(t(u),t(U),t(T),t(J),t(p),t(C),t(y),t(F),t(a),t(g),t(X),t(hl),t(Y),t(bl),t(k),t(gl),t(Fl),t(H),t(Ql),t(Sl),t(O),t($l),t(L),t(Rl),t(D),t(Zl),t(Z),t(Al),t(El),t(K),t(vl),t(ll),t(kl),t(tl),t(Gl),t(A),t(Wl),t(G),t(xl),t(_l),t(el),t(Xl),t(nl),t(Yl),t(ql),t(il),t(Hl),t(zl),t(Ml),t(Ol),t(Ul),t(Ll),t(Jl),t(Dl),t(Pl),t(ol),t(Kl),t(lt),t(tt),t(Tl),t(st),t(et),t(nt),t(Vl),t(at),t(cl),t(it),t(ul),t(Mt),t(Ut),t(Jt),t(Cl),t(pt),t(dl),t(ot),t(wl),t(rt),t(fl),t(Tt),t(Nl),t(jt),t(Vt),t(Bl)),t(M),h(j,l),h(s,l),h(d,l),h(q,l),h(z,l),h(P,l),h(sl,l),h(al,l),h(W,l),h(pl,l),h(x,l),h(rl,l),h(_,l),h(jl,l),h(yl,l),h(ml,l),h(Il,l)}}}const ms='{"title":"创建宾客信息检索生成（RAG）工具","local":"创建宾客信息检索生成rag工具","sections":[{"title":"为何选择 RAG 技术？","local":"为何选择-rag-技术","sections":[],"depth":2},{"title":"应用搭建","local":"应用搭建","sections":[{"title":"项目结构","local":"项目结构","sections":[],"depth":3}],"depth":2},{"title":"数据集概览","local":"数据集概览","sections":[],"depth":2},{"title":"构建宾客信息工具","local":"构建宾客信息工具","sections":[{"title":"步骤一：加载并预处理数据集","local":"步骤一加载并预处理数据集","sections":[],"depth":3},{"title":"步骤 2：创建检索工具","local":"步骤-2创建检索工具","sections":[],"depth":3},{"title":"步骤 3：将工具与 Alfred 集成","local":"步骤-3将工具与-alfred-集成","sections":[],"depth":3}],"depth":2},{"title":"互动示例","local":"互动示例","sections":[],"depth":2},{"title":"更进一步","local":"更进一步","sections":[],"depth":2}],"depth":1}';function Cs(Q){return Kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class hs extends ls{constructor(M){super(),ts(this,M,Cs,ys,Pt,{})}}export{hs as component};
