import{s as Lt,f as Ot,o as Dt,n as v}from"../chunks/scheduler.37c15a92.js";import{S as Pt,i as Kt,g as c,s as p,r as N,A as ls,h as V,f as t,c as o,j as Vt,u as f,x as m,k as S,y as ts,a as e,v as I,d as B,t as h,w as b}from"../chunks/index.2bf4358c.js";import{C as $}from"../chunks/CodeBlock.4e987730.js";import{H as R}from"../chunks/Heading.8ada512a.js";import{H as ut,a as E}from"../chunks/HfOption.02c8e375.js";import{E as ss}from"../chunks/getInferenceSnippets.0aa3753f.js";function es(g){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(){N(M.$$.fragment)},l(U){f(M.$$.fragment,U)},m(U,r){I(M,U,r),u=!0},p:v,i(U){u||(B(M.$$.fragment,U),u=!0)},o(U){h(M.$$.fragment,U),u=!1},d(U){b(M,U)}}}function ns(g){let M,u="我们将使用 Hugging Face <code>datasets</code> 库来加载数据集并将其转换为来自 <code>llama_index.core.schema</code> 模块的 <code>Document</code> 对象列表。",U,r,j;return r=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=c("p"),M.innerHTML=u,U=p(),N(r.$$.fragment)},l(J){M=V(J,"P",{"data-svelte-h":!0}),m(M)!=="svelte-1huhyoc"&&(M.innerHTML=u),U=o(J),f(r.$$.fragment,J)},m(J,s){e(J,M,s),e(J,U,s),I(r,J,s),j=!0},p:v,i(J){j||(B(r.$$.fragment,J),j=!0)},o(J){h(r.$$.fragment,J),j=!1},d(J){J&&(t(M),t(U)),b(r,J)}}}function as(g){let M,u="我们将使用 Hugging Face <code>datasets</code> 库来加载数据集并将其转换为来自 <code>langchain.docstore.document</code> 模块的 <code>Document</code> 对象列表。",U,r,j;return r=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=c("p"),M.innerHTML=u,U=p(),N(r.$$.fragment)},l(J){M=V(J,"P",{"data-svelte-h":!0}),m(M)!=="svelte-qgr523"&&(M.innerHTML=u),U=o(J),f(r.$$.fragment,J)},m(J,s){e(J,M,s),e(J,U,s),I(r,J,s),j=!0},p:v,i(J){j||(B(r.$$.fragment,J),j=!0)},o(J){h(r.$$.fragment,J),j=!1},d(J){J&&(t(M),t(U)),b(r,J)}}}function Ms(g){let M,u,U,r,j,J;return M=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[es]},$$scope:{ctx:g}}}),U=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[ns]},$$scope:{ctx:g}}}),j=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[as]},$$scope:{ctx:g}}}),{c(){N(M.$$.fragment),u=p(),N(U.$$.fragment),r=p(),N(j.$$.fragment)},l(s){f(M.$$.fragment,s),u=o(s),f(U.$$.fragment,s),r=o(s),f(j.$$.fragment,s)},m(s,T){I(M,s,T),e(s,u,T),I(U,s,T),e(s,r,T),I(j,s,T),J=!0},p(s,T){const C={};T&2&&(C.$$scope={dirty:T,ctx:s}),M.$set(C);const d={};T&2&&(d.$$scope={dirty:T,ctx:s}),U.$set(d);const y={};T&2&&(y.$$scope={dirty:T,ctx:s}),j.$set(y)},i(s){J||(B(M.$$.fragment,s),B(U.$$.fragment,s),B(j.$$.fragment,s),J=!0)},o(s){h(M.$$.fragment,s),h(U.$$.fragment,s),h(j.$$.fragment,s),J=!1},d(s){s&&(t(u),t(r)),b(M,s),b(U,s),b(j,s)}}}function is(g){let M,u="我们将使用“langchain_community.retrievers”模块中的“BM25Retriever”来创建一个检索工具。",U,r,j='<code>BM25Retriever</code> 是检索的一个很好的起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如来自 <a href="https://www.sbert.net/">sentence-transformers</a> 的检索器。',J,s,T,C,d="让我们逐步了解这个工具：",y,w,Q="<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=c("p"),M.textContent=u,U=p(),r=c("blockquote"),r.innerHTML=j,J=p(),N(s.$$.fragment),T=p(),C=c("p"),C.textContent=d,y=p(),w=c("ul"),w.innerHTML=Q,this.h()},l(n){M=V(n,"P",{"data-svelte-h":!0}),m(M)!=="svelte-1h1wsbb"&&(M.textContent=u),U=o(n),r=V(n,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(r)!=="svelte-vd3lsm"&&(r.innerHTML=j),J=o(n),f(s.$$.fragment,n),T=o(n),C=V(n,"P",{"data-svelte-h":!0}),m(C)!=="svelte-1nnhcdb"&&(C.textContent=d),y=o(n),w=V(n,"UL",{"data-svelte-h":!0}),m(w)!=="svelte-uto1l5"&&(w.innerHTML=Q),this.h()},h(){S(r,"class","tip")},m(n,F){e(n,M,F),e(n,U,F),e(n,r,F),e(n,J,F),I(s,n,F),e(n,T,F),e(n,C,F),e(n,y,F),e(n,w,F),a=!0},p:v,i(n){a||(B(s.$$.fragment,n),a=!0)},o(n){h(s.$$.fragment,n),a=!1},d(n){n&&(t(M),t(U),t(r),t(J),t(T),t(C),t(y),t(w)),b(s,n)}}}function Us(g){let M,u="我们将使用 <code>llama_index.retrievers.bm25</code> 模块中的 <code>BM25Retriever</code> 来创建一个检索工具。",U,r,j='<code>BM25Retriever</code> 是一个很好的检索起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如 <a href="https://www.sbert.net/">sentence-transformers</a> 中的检索器。',J,s,T,C,d="让我们逐步了解这个工具。",y,w,Q="<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=c("p"),M.innerHTML=u,U=p(),r=c("blockquote"),r.innerHTML=j,J=p(),N(s.$$.fragment),T=p(),C=c("p"),C.textContent=d,y=p(),w=c("ul"),w.innerHTML=Q,this.h()},l(n){M=V(n,"P",{"data-svelte-h":!0}),m(M)!=="svelte-re9s76"&&(M.innerHTML=u),U=o(n),r=V(n,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(r)!=="svelte-1xzajos"&&(r.innerHTML=j),J=o(n),f(s.$$.fragment,n),T=o(n),C=V(n,"P",{"data-svelte-h":!0}),m(C)!=="svelte-54z6pz"&&(C.textContent=d),y=o(n),w=V(n,"UL",{"data-svelte-h":!0}),m(w)!=="svelte-1yb6oqz"&&(w.innerHTML=Q),this.h()},h(){S(r,"class","tip")},m(n,F){e(n,M,F),e(n,U,F),e(n,r,F),e(n,J,F),I(s,n,F),e(n,T,F),e(n,C,F),e(n,y,F),e(n,w,F),a=!0},p:v,i(n){a||(B(s.$$.fragment,n),a=!0)},o(n){h(s.$$.fragment,n),a=!1},d(n){n&&(t(M),t(U),t(r),t(J),t(T),t(C),t(y),t(w)),b(s,n)}}}function Js(g){let M,u="我们将使用 <code>langchain_community.retrievers</code> 模块中的 <code>BM25Retriever</code> 来创建一个检索工具。",U,r,j='<code>BM25Retriever</code> 是一个很好的检索起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如 <a href="https://www.sbert.net/">sentence-transformers</a> 中的检索器。',J,s,T,C,d="让我们逐步了解这个工具。",y,w,Q="<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=c("p"),M.innerHTML=u,U=p(),r=c("blockquote"),r.innerHTML=j,J=p(),N(s.$$.fragment),T=p(),C=c("p"),C.textContent=d,y=p(),w=c("ul"),w.innerHTML=Q,this.h()},l(n){M=V(n,"P",{"data-svelte-h":!0}),m(M)!=="svelte-1pj6jx5"&&(M.innerHTML=u),U=o(n),r=V(n,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(r)!=="svelte-1xzajos"&&(r.innerHTML=j),J=o(n),f(s.$$.fragment,n),T=o(n),C=V(n,"P",{"data-svelte-h":!0}),m(C)!=="svelte-54z6pz"&&(C.textContent=d),y=o(n),w=V(n,"UL",{"data-svelte-h":!0}),m(w)!=="svelte-1evf3o1"&&(w.innerHTML=Q),this.h()},h(){S(r,"class","tip")},m(n,F){e(n,M,F),e(n,U,F),e(n,r,F),e(n,J,F),I(s,n,F),e(n,T,F),e(n,C,F),e(n,y,F),e(n,w,F),a=!0},p:v,i(n){a||(B(s.$$.fragment,n),a=!0)},o(n){h(s.$$.fragment,n),a=!1},d(n){n&&(t(M),t(U),t(r),t(J),t(T),t(C),t(y),t(w)),b(s,n)}}}function ps(g){let M,u,U,r,j,J;return M=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[is]},$$scope:{ctx:g}}}),U=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[Us]},$$scope:{ctx:g}}}),j=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[Js]},$$scope:{ctx:g}}}),{c(){N(M.$$.fragment),u=p(),N(U.$$.fragment),r=p(),N(j.$$.fragment)},l(s){f(M.$$.fragment,s),u=o(s),f(U.$$.fragment,s),r=o(s),f(j.$$.fragment,s)},m(s,T){I(M,s,T),e(s,u,T),I(U,s,T),e(s,r,T),I(j,s,T),J=!0},p(s,T){const C={};T&2&&(C.$$scope={dirty:T,ctx:s}),M.$set(C);const d={};T&2&&(d.$$scope={dirty:T,ctx:s}),U.$set(d);const y={};T&2&&(y.$$scope={dirty:T,ctx:s}),j.$set(y)},i(s){J||(B(M.$$.fragment,s),B(U.$$.fragment,s),B(j.$$.fragment,s),J=!0)},o(s){h(M.$$.fragment,s),h(U.$$.fragment,s),h(j.$$.fragment,s),J=!1},d(s){s&&(t(u),t(r)),b(M,s),b(U,s),b(j,s)}}}function os(g){let M,u,U,r="预期输出：",j,J,s,T,C="这最后一步具体做了什么：",d,y,w="<li>我们使用 <code>InferenceClientModel</code> 类初始化 Hugging Face 模型</li> <li>我们将智能体 (Alfred) 创建为 <code>CodeAgent</code>，它可以执行 Python 代码来解决问题</li> <li>我们让 Alfred 检索一位名叫“Lady Ada Lovelace”的客人的信息</li>",Q;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(){N(M.$$.fragment),u=p(),U=c("p"),U.textContent=r,j=p(),N(J.$$.fragment),s=p(),T=c("p"),T.textContent=C,d=p(),y=c("ul"),y.innerHTML=w},l(a){f(M.$$.fragment,a),u=o(a),U=V(a,"P",{"data-svelte-h":!0}),m(U)!=="svelte-vb4qji"&&(U.textContent=r),j=o(a),f(J.$$.fragment,a),s=o(a),T=V(a,"P",{"data-svelte-h":!0}),m(T)!=="svelte-155v302"&&(T.textContent=C),d=o(a),y=V(a,"UL",{"data-svelte-h":!0}),m(y)!=="svelte-1wuaj0c"&&(y.innerHTML=w)},m(a,n){I(M,a,n),e(a,u,n),e(a,U,n),e(a,j,n),I(J,a,n),e(a,s,n),e(a,T,n),e(a,d,n),e(a,y,n),Q=!0},p:v,i(a){Q||(B(M.$$.fragment,a),B(J.$$.fragment,a),Q=!0)},o(a){h(M.$$.fragment,a),h(J.$$.fragment,a),Q=!1},d(a){a&&(t(u),t(U),t(j),t(s),t(T),t(d),t(y)),b(M,a),b(J,a)}}}function Ts(g){let M,u,U,r="预期输出：",j,J,s,T,C="这最后一步具体做了什么：",d,y,w="<li>我们使用 <code>HuggingFaceInferenceAPI</code> 类初始化 Hugging Face 模型</li> <li>我们将智能体 (Alfred) 创建为 <code>AgentWorkflow</code>，其中包含我们刚刚创建的工具</li> <li>我们请求 Alfred 检索名为“Lady Ada Lovelace”的客人的信息</li>",Q;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(){N(M.$$.fragment),u=p(),U=c("p"),U.textContent=r,j=p(),N(J.$$.fragment),s=p(),T=c("p"),T.textContent=C,d=p(),y=c("ul"),y.innerHTML=w},l(a){f(M.$$.fragment,a),u=o(a),U=V(a,"P",{"data-svelte-h":!0}),m(U)!=="svelte-vb4qji"&&(U.textContent=r),j=o(a),f(J.$$.fragment,a),s=o(a),T=V(a,"P",{"data-svelte-h":!0}),m(T)!=="svelte-155v302"&&(T.textContent=C),d=o(a),y=V(a,"UL",{"data-svelte-h":!0}),m(y)!=="svelte-15zb6ce"&&(y.innerHTML=w)},m(a,n){I(M,a,n),e(a,u,n),e(a,U,n),e(a,j,n),I(J,a,n),e(a,s,n),e(a,T,n),e(a,d,n),e(a,y,n),Q=!0},p:v,i(a){Q||(B(M.$$.fragment,a),B(J.$$.fragment,a),Q=!0)},o(a){h(M.$$.fragment,a),h(J.$$.fragment,a),Q=!1},d(a){a&&(t(u),t(U),t(j),t(s),t(T),t(d),t(y)),b(M,a),b(J,a)}}}function rs(g){let M,u,U,r="预期输出：",j,J,s,T,C="这最后一步具体做了什么：",d,y,w="<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>",Q;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(){N(M.$$.fragment),u=p(),U=c("p"),U.textContent=r,j=p(),N(J.$$.fragment),s=p(),T=c("p"),T.textContent=C,d=p(),y=c("ul"),y.innerHTML=w},l(a){f(M.$$.fragment,a),u=o(a),U=V(a,"P",{"data-svelte-h":!0}),m(U)!=="svelte-vb4qji"&&(U.textContent=r),j=o(a),f(J.$$.fragment,a),s=o(a),T=V(a,"P",{"data-svelte-h":!0}),m(T)!=="svelte-155v302"&&(T.textContent=C),d=o(a),y=V(a,"UL",{"data-svelte-h":!0}),m(y)!=="svelte-1gd47hp"&&(y.innerHTML=w)},m(a,n){I(M,a,n),e(a,u,n),e(a,U,n),e(a,j,n),I(J,a,n),e(a,s,n),e(a,T,n),e(a,d,n),e(a,y,n),Q=!0},p:v,i(a){Q||(B(M.$$.fragment,a),B(J.$$.fragment,a),Q=!0)},o(a){h(M.$$.fragment,a),h(J.$$.fragment,a),Q=!1},d(a){a&&(t(u),t(U),t(j),t(s),t(T),t(d),t(y)),b(M,a),b(J,a)}}}function js(g){let M,u,U,r,j,J;return M=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[os]},$$scope:{ctx:g}}}),U=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[Ts]},$$scope:{ctx:g}}}),j=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[rs]},$$scope:{ctx:g}}}),{c(){N(M.$$.fragment),u=p(),N(U.$$.fragment),r=p(),N(j.$$.fragment)},l(s){f(M.$$.fragment,s),u=o(s),f(U.$$.fragment,s),r=o(s),f(j.$$.fragment,s)},m(s,T){I(M,s,T),e(s,u,T),I(U,s,T),e(s,r,T),I(j,s,T),J=!0},p(s,T){const C={};T&2&&(C.$$scope={dirty:T,ctx:s}),M.$set(C);const d={};T&2&&(d.$$scope={dirty:T,ctx:s}),U.$set(d);const y={};T&2&&(y.$$scope={dirty:T,ctx:s}),j.$set(y)},i(s){J||(B(M.$$.fragment,s),B(U.$$.fragment,s),B(j.$$.fragment,s),J=!0)},o(s){h(M.$$.fragment,s),h(U.$$.fragment,s),h(j.$$.fragment,s),J=!1},d(s){s&&(t(u),t(r)),b(M,s),b(U,s),b(j,s)}}}function cs(g){let M,u,U,r,j,J,s,T="您信赖的智能体 Alfred 正在筹备本世纪最盛大的晚会。为确保活动顺利进行，Alfred 需要快速获取最新宾客信息。让我们通过定制化的检索增强生成（RAG）工具（基于专属数据集）为 Alfred 赋能。",C,d,y,w,Q="试想 Alfred 在宾客间穿梭时需即时调取详细信息，传统大语言模型（LLM）可能面临以下挑战：",a,n,F="<li>宾客名单属于特定活动数据，不在模型训练范围内</li> <li>宾客信息可能频繁变更或更新</li> <li>需精确检索电子邮件地址等细节信息</li>",Bl,X,yt="这正是检索增强生成（RAG）技术的优势所在！通过结合检索系统与 LLM，Alfred 可按需获取准确、实时的宾客信息。",hl,k,mt="<p>您可以选择课程涵盖的任何框架实现本用例，请通过代码标签页选择偏好方案。</p>",bl,Y,Fl,q,Ct="我们将以 Hugging Face Space 为开发环境，采用结构化 Python 项目构建智能体。这种架构通过功能模块化实现代码整洁，更贴近实际部署场景。",gl,H,Ql,z,dt="<li><strong><code>tools.py</code></strong> – 为智能体提供辅助工具</li> <li><strong><code>retriever.py</code></strong> – 实现支持知识访问的检索功能</li> <li><strong><code>app.py</code></strong> – 整合所有组件形成完整功能智能体（将在本单元最后完成）</li>",Sl,O,wt='实操参考：<a href="https://huggingface.co/spaces/agents-course/Unit_3_Agentic_RAG" rel="nofollow">Hugging Face Space 示例</a>，该空间已部署本单元开发的智能体增强 RAG 系统，欢迎克隆体验！',$l,L,Nt="可直接测试下方智能体：",Rl,Z,ft,Zl,D,Al,P,It='数据集 <a href="https://huggingface.co/datasets/agents-course/unit3-invitees/" rel="nofollow"><code>agents-course/unit3-invitees</code></a> 包含以下字段：',El,K,Bt="<li><strong>Name</strong>: 宾客全名</li> <li><strong>Relation</strong>: 与主办方关系</li> <li><strong>Description</strong>: 简要传记或趣闻</li> <li><strong>Email Address</strong>: 邀请函发送及跟进联系方式</li>",vl,ll,ht="数据集预览：",kl,A,bt,Gl,G,Ft="<p>实际场景可扩展数据集字段，包含饮食偏好、礼品兴趣、禁忌话题等对主持人有用的详细信息。</p>",Wl,tl,xl,sl,gt="我们将创建 Alfred 在晚会期间快速检索宾客信息的定制工具，分三步实现：",_l,el,Qt="<li>加载并预处理数据集</li> <li>创建检索工具</li> <li>工具与 Alfred 集成</li>",Xl,nl,Yl,al,St="首先将原始宾客数据转换为适合检索的格式：",ql,W,Hl,Ml,$t="在上面的代码中，我们：",zl,il,Rt="<li>加载数据集</li> <li>将每条房客记录转换为包含格式化内容的 “Document” 对象</li> <li>将 “Document” 对象存储在列表中</li>",Ol,Ul,Zt="这意味着我们已经准备好所有数据，可以开始配置检索功能了。",Ll,Jl,Dl,pl,At="现在，让我们创建一个自定义工具，Alfred 可以使用它来搜索房客信息。",Pl,x,Kl,ol,lt,Tl,Et="最后，让我们创建智能体并为其配备自定义工具，将所有内容整合在一起：",tt,_,st,rl,et,jl,vt="在晚会上，对话可能像这样进行：",nt,cl,kt="<strong>你</strong>：“Alfred，那位正在和大使说话的先生是谁？”",at,Vl,Gt="<strong>Alfred</strong> <em>快速搜索嘉宾数据库</em> “先生，那是尼古拉·特斯拉博士。他是你大学时代的老朋友。他最近申请了一种新的无线能量传输系统的专利，很乐意和你讨论一下。不过别忘了，他对鸽子很感兴趣，所以这或许会成为一次很好的闲聊。”",Mt,ul,it,yl,Ut,ml,Wt="既然 Alfred 可以检索宾客信息，不妨考虑如何增强这个系统：",Jt,Cl,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>',pt,dl,_t="现在，Alfred 已经完全有能力轻松处理宾客的咨询，确保您的晚会成为本世纪最精致、最令人愉悦的盛事！",ot,wl,Xt=`<提示>
尝试扩展检索工具，使其能够根据每位宾客的兴趣或背景返回对话开场白。您将如何修改该工具来实现这一点？`,Tt,Nl,Yt=`完成后，在 <code>retriever.py</code> 文件中实现您的宾客检索工具。
&lt;/提示&gt;`,rt,fl,jt,Il,ct;return j=new R({props:{title:"创建宾客信息检索生成（RAG）工具",local:"创建宾客信息检索生成rag工具",headingTag:"h1"}}),d=new R({props:{title:"为何选择 RAG 技术？",local:"为何选择-rag-技术",headingTag:"h2"}}),Y=new R({props:{title:"应用搭建",local:"应用搭建",headingTag:"h2"}}),H=new R({props:{title:"项目结构",local:"项目结构",headingTag:"h3"}}),D=new R({props:{title:"数据集概览",local:"数据集概览",headingTag:"h2"}}),tl=new R({props:{title:"构建宾客信息工具",local:"构建宾客信息工具",headingTag:"h2"}}),nl=new R({props:{title:"步骤一：加载并预处理数据集",local:"步骤一加载并预处理数据集",headingTag:"h3"}}),W=new ut({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[Ms]},$$scope:{ctx:g}}}),Jl=new R({props:{title:"步骤 2：创建检索工具",local:"步骤-2创建检索工具",headingTag:"h3"}}),x=new ut({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[ps]},$$scope:{ctx:g}}}),ol=new R({props:{title:"步骤 3：将工具与 Alfred 集成",local:"步骤-3将工具与-alfred-集成",headingTag:"h3"}}),_=new ut({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[js]},$$scope:{ctx:g}}}),rl=new R({props:{title:"互动示例",local:"互动示例",headingTag:"h2"}}),ul=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}}),yl=new R({props:{title:"更进一步",local:"更进一步",headingTag:"h2"}}),fl=new ss({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit3/agentic-rag/invitees.mdx"}}),{c(){M=c("meta"),u=p(),U=c("p"),r=p(),N(j.$$.fragment),J=p(),s=c("p"),s.textContent=T,C=p(),N(d.$$.fragment),y=p(),w=c("p"),w.textContent=Q,a=p(),n=c("ol"),n.innerHTML=F,Bl=p(),X=c("p"),X.textContent=yt,hl=p(),k=c("blockquote"),k.innerHTML=mt,bl=p(),N(Y.$$.fragment),Fl=p(),q=c("p"),q.textContent=Ct,gl=p(),N(H.$$.fragment),Ql=p(),z=c("ul"),z.innerHTML=dt,Sl=p(),O=c("p"),O.innerHTML=wt,$l=p(),L=c("p"),L.textContent=Nt,Rl=p(),Z=c("iframe"),Zl=p(),N(D.$$.fragment),Al=p(),P=c("p"),P.innerHTML=It,El=p(),K=c("ul"),K.innerHTML=Bt,vl=p(),ll=c("p"),ll.textContent=ht,kl=p(),A=c("iframe"),Gl=p(),G=c("blockquote"),G.innerHTML=Ft,Wl=p(),N(tl.$$.fragment),xl=p(),sl=c("p"),sl.textContent=gt,_l=p(),el=c("ol"),el.innerHTML=Qt,Xl=p(),N(nl.$$.fragment),Yl=p(),al=c("p"),al.textContent=St,ql=p(),N(W.$$.fragment),Hl=p(),Ml=c("p"),Ml.textContent=$t,zl=p(),il=c("ul"),il.innerHTML=Rt,Ol=p(),Ul=c("p"),Ul.textContent=Zt,Ll=p(),N(Jl.$$.fragment),Dl=p(),pl=c("p"),pl.textContent=At,Pl=p(),N(x.$$.fragment),Kl=p(),N(ol.$$.fragment),lt=p(),Tl=c("p"),Tl.textContent=Et,tt=p(),N(_.$$.fragment),st=p(),N(rl.$$.fragment),et=p(),jl=c("p"),jl.textContent=vt,nt=p(),cl=c("p"),cl.innerHTML=kt,at=p(),Vl=c("p"),Vl.innerHTML=Gt,Mt=p(),N(ul.$$.fragment),it=p(),N(yl.$$.fragment),Ut=p(),ml=c("p"),ml.textContent=Wt,Jt=p(),Cl=c("ol"),Cl.innerHTML=xt,pt=p(),dl=c("p"),dl.textContent=_t,ot=p(),wl=c("p"),wl.textContent=Xt,Tt=p(),Nl=c("p"),Nl.innerHTML=Yt,rt=p(),N(fl.$$.fragment),jt=p(),Il=c("p"),this.h()},l(l){const i=ls("svelte-u9bgzb",document.head);M=V(i,"META",{name:!0,content:!0}),i.forEach(t),u=o(l),U=V(l,"P",{}),Vt(U).forEach(t),r=o(l),f(j.$$.fragment,l),J=o(l),s=V(l,"P",{"data-svelte-h":!0}),m(s)!=="svelte-ni58hz"&&(s.textContent=T),C=o(l),f(d.$$.fragment,l),y=o(l),w=V(l,"P",{"data-svelte-h":!0}),m(w)!=="svelte-hvkga8"&&(w.textContent=Q),a=o(l),n=V(l,"OL",{"data-svelte-h":!0}),m(n)!=="svelte-1xe6k1a"&&(n.innerHTML=F),Bl=o(l),X=V(l,"P",{"data-svelte-h":!0}),m(X)!=="svelte-18bm0pz"&&(X.textContent=yt),hl=o(l),k=V(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(k)!=="svelte-6rtiu1"&&(k.innerHTML=mt),bl=o(l),f(Y.$$.fragment,l),Fl=o(l),q=V(l,"P",{"data-svelte-h":!0}),m(q)!=="svelte-1st8m4l"&&(q.textContent=Ct),gl=o(l),f(H.$$.fragment,l),Ql=o(l),z=V(l,"UL",{"data-svelte-h":!0}),m(z)!=="svelte-1a6bges"&&(z.innerHTML=dt),Sl=o(l),O=V(l,"P",{"data-svelte-h":!0}),m(O)!=="svelte-1cdsklr"&&(O.innerHTML=wt),$l=o(l),L=V(l,"P",{"data-svelte-h":!0}),m(L)!=="svelte-qobm9m"&&(L.textContent=Nt),Rl=o(l),Z=V(l,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),Vt(Z).forEach(t),Zl=o(l),f(D.$$.fragment,l),Al=o(l),P=V(l,"P",{"data-svelte-h":!0}),m(P)!=="svelte-1ji80vr"&&(P.innerHTML=It),El=o(l),K=V(l,"UL",{"data-svelte-h":!0}),m(K)!=="svelte-5izozk"&&(K.innerHTML=Bt),vl=o(l),ll=V(l,"P",{"data-svelte-h":!0}),m(ll)!=="svelte-tqhrae"&&(ll.textContent=ht),kl=o(l),A=V(l,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),Vt(A).forEach(t),Gl=o(l),G=V(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(G)!=="svelte-3ipj5o"&&(G.innerHTML=Ft),Wl=o(l),f(tl.$$.fragment,l),xl=o(l),sl=V(l,"P",{"data-svelte-h":!0}),m(sl)!=="svelte-bmawv5"&&(sl.textContent=gt),_l=o(l),el=V(l,"OL",{"data-svelte-h":!0}),m(el)!=="svelte-9bhzxd"&&(el.innerHTML=Qt),Xl=o(l),f(nl.$$.fragment,l),Yl=o(l),al=V(l,"P",{"data-svelte-h":!0}),m(al)!=="svelte-1rgegsv"&&(al.textContent=St),ql=o(l),f(W.$$.fragment,l),Hl=o(l),Ml=V(l,"P",{"data-svelte-h":!0}),m(Ml)!=="svelte-18g0znq"&&(Ml.textContent=$t),zl=o(l),il=V(l,"UL",{"data-svelte-h":!0}),m(il)!=="svelte-uk4sjn"&&(il.innerHTML=Rt),Ol=o(l),Ul=V(l,"P",{"data-svelte-h":!0}),m(Ul)!=="svelte-19nx22w"&&(Ul.textContent=Zt),Ll=o(l),f(Jl.$$.fragment,l),Dl=o(l),pl=V(l,"P",{"data-svelte-h":!0}),m(pl)!=="svelte-1j6dp92"&&(pl.textContent=At),Pl=o(l),f(x.$$.fragment,l),Kl=o(l),f(ol.$$.fragment,l),lt=o(l),Tl=V(l,"P",{"data-svelte-h":!0}),m(Tl)!=="svelte-1txfo3m"&&(Tl.textContent=Et),tt=o(l),f(_.$$.fragment,l),st=o(l),f(rl.$$.fragment,l),et=o(l),jl=V(l,"P",{"data-svelte-h":!0}),m(jl)!=="svelte-1553i9s"&&(jl.textContent=vt),nt=o(l),cl=V(l,"P",{"data-svelte-h":!0}),m(cl)!=="svelte-1kcb56i"&&(cl.innerHTML=kt),at=o(l),Vl=V(l,"P",{"data-svelte-h":!0}),m(Vl)!=="svelte-102x9e7"&&(Vl.innerHTML=Gt),Mt=o(l),f(ul.$$.fragment,l),it=o(l),f(yl.$$.fragment,l),Ut=o(l),ml=V(l,"P",{"data-svelte-h":!0}),m(ml)!=="svelte-4mmwa5"&&(ml.textContent=Wt),Jt=o(l),Cl=V(l,"OL",{"data-svelte-h":!0}),m(Cl)!=="svelte-s48kxv"&&(Cl.innerHTML=xt),pt=o(l),dl=V(l,"P",{"data-svelte-h":!0}),m(dl)!=="svelte-1rnyu8f"&&(dl.textContent=_t),ot=o(l),wl=V(l,"P",{"data-svelte-h":!0}),m(wl)!=="svelte-1fepywm"&&(wl.textContent=Xt),Tt=o(l),Nl=V(l,"P",{"data-svelte-h":!0}),m(Nl)!=="svelte-1t5ix9x"&&(Nl.innerHTML=Yt),rt=o(l),f(fl.$$.fragment,l),jt=o(l),Il=V(l,"P",{}),Vt(Il).forEach(t),this.h()},h(){S(M,"name","hf:doc:metadata"),S(M,"content",Vs),S(k,"class","tip"),Ot(Z.src,ft="https://agents-course-unit-3-agentic-rag.hf.space")||S(Z,"src",ft),S(Z,"frameborder","0"),S(Z,"width","850"),S(Z,"height","450"),Ot(A.src,bt="https://huggingface.co/datasets/agents-course/unit3-invitees/embed/viewer/default/train")||S(A,"src",bt),S(A,"frameborder","0"),S(A,"width","100%"),S(A,"height","560px"),S(G,"class","tip")},m(l,i){ts(document.head,M),e(l,u,i),e(l,U,i),e(l,r,i),I(j,l,i),e(l,J,i),e(l,s,i),e(l,C,i),I(d,l,i),e(l,y,i),e(l,w,i),e(l,a,i),e(l,n,i),e(l,Bl,i),e(l,X,i),e(l,hl,i),e(l,k,i),e(l,bl,i),I(Y,l,i),e(l,Fl,i),e(l,q,i),e(l,gl,i),I(H,l,i),e(l,Ql,i),e(l,z,i),e(l,Sl,i),e(l,O,i),e(l,$l,i),e(l,L,i),e(l,Rl,i),e(l,Z,i),e(l,Zl,i),I(D,l,i),e(l,Al,i),e(l,P,i),e(l,El,i),e(l,K,i),e(l,vl,i),e(l,ll,i),e(l,kl,i),e(l,A,i),e(l,Gl,i),e(l,G,i),e(l,Wl,i),I(tl,l,i),e(l,xl,i),e(l,sl,i),e(l,_l,i),e(l,el,i),e(l,Xl,i),I(nl,l,i),e(l,Yl,i),e(l,al,i),e(l,ql,i),I(W,l,i),e(l,Hl,i),e(l,Ml,i),e(l,zl,i),e(l,il,i),e(l,Ol,i),e(l,Ul,i),e(l,Ll,i),I(Jl,l,i),e(l,Dl,i),e(l,pl,i),e(l,Pl,i),I(x,l,i),e(l,Kl,i),I(ol,l,i),e(l,lt,i),e(l,Tl,i),e(l,tt,i),I(_,l,i),e(l,st,i),I(rl,l,i),e(l,et,i),e(l,jl,i),e(l,nt,i),e(l,cl,i),e(l,at,i),e(l,Vl,i),e(l,Mt,i),I(ul,l,i),e(l,it,i),I(yl,l,i),e(l,Ut,i),e(l,ml,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,Tt,i),e(l,Nl,i),e(l,rt,i),I(fl,l,i),e(l,jt,i),e(l,Il,i),ct=!0},p(l,[i]){const qt={};i&2&&(qt.$$scope={dirty:i,ctx:l}),W.$set(qt);const Ht={};i&2&&(Ht.$$scope={dirty:i,ctx:l}),x.$set(Ht);const zt={};i&2&&(zt.$$scope={dirty:i,ctx:l}),_.$set(zt)},i(l){ct||(B(j.$$.fragment,l),B(d.$$.fragment,l),B(Y.$$.fragment,l),B(H.$$.fragment,l),B(D.$$.fragment,l),B(tl.$$.fragment,l),B(nl.$$.fragment,l),B(W.$$.fragment,l),B(Jl.$$.fragment,l),B(x.$$.fragment,l),B(ol.$$.fragment,l),B(_.$$.fragment,l),B(rl.$$.fragment,l),B(ul.$$.fragment,l),B(yl.$$.fragment,l),B(fl.$$.fragment,l),ct=!0)},o(l){h(j.$$.fragment,l),h(d.$$.fragment,l),h(Y.$$.fragment,l),h(H.$$.fragment,l),h(D.$$.fragment,l),h(tl.$$.fragment,l),h(nl.$$.fragment,l),h(W.$$.fragment,l),h(Jl.$$.fragment,l),h(x.$$.fragment,l),h(ol.$$.fragment,l),h(_.$$.fragment,l),h(rl.$$.fragment,l),h(ul.$$.fragment,l),h(yl.$$.fragment,l),h(fl.$$.fragment,l),ct=!1},d(l){l&&(t(u),t(U),t(r),t(J),t(s),t(C),t(y),t(w),t(a),t(n),t(Bl),t(X),t(hl),t(k),t(bl),t(Fl),t(q),t(gl),t(Ql),t(z),t(Sl),t(O),t($l),t(L),t(Rl),t(Z),t(Zl),t(Al),t(P),t(El),t(K),t(vl),t(ll),t(kl),t(A),t(Gl),t(G),t(Wl),t(xl),t(sl),t(_l),t(el),t(Xl),t(Yl),t(al),t(ql),t(Hl),t(Ml),t(zl),t(il),t(Ol),t(Ul),t(Ll),t(Dl),t(pl),t(Pl),t(Kl),t(lt),t(Tl),t(tt),t(st),t(et),t(jl),t(nt),t(cl),t(at),t(Vl),t(Mt),t(it),t(Ut),t(ml),t(Jt),t(Cl),t(pt),t(dl),t(ot),t(wl),t(Tt),t(Nl),t(rt),t(jt),t(Il)),t(M),b(j,l),b(d,l),b(Y,l),b(H,l),b(D,l),b(tl,l),b(nl,l),b(W,l),b(Jl,l),b(x,l),b(ol,l),b(_,l),b(rl,l),b(ul,l),b(yl,l),b(fl,l)}}}const Vs='{"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 us(g){return Dt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fs extends Pt{constructor(M){super(),Kt(this,M,us,cs,Lt,{})}}export{fs as component};
