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