import{s as Kt,f as Pt,o as ls,n as E}from"../chunks/scheduler.37c15a92.js";import{S as ts,i as ss,g as u,s as r,r as d,A as es,h as c,f as e,c as V,j as Ct,u as w,x as C,k as b,y as ns,a as n,v as f,d as N,t as I,w as h,m as X,n as Y}from"../chunks/index.2bf4358c.js";import{T as Fl}from"../chunks/Tip.363c041f.js";import{C as S}from"../chunks/CodeBlock.4e987730.js";import{H as R}from"../chunks/Heading.8ada512a.js";import{H as yt,a as v}from"../chunks/HfOption.02c8e375.js";import{E as as}from"../chunks/index.f9c0018f.js";function is(B){let a;return{c(){a=X("您可以选择课程涵盖的任何框架实现本用例，请通过代码标签页选择偏好方案。")},l(j){a=Y(j,"您可以选择课程涵盖的任何框架实现本用例，请通过代码标签页选择偏好方案。")},m(j,p){n(j,a,p)},d(j){j&&e(a)}}}function Ms(B){let a;return{c(){a=X("实际场景可扩展数据集字段，包含饮食偏好、礼品兴趣、禁忌话题等对主持人有用的详细信息。")},l(j){a=Y(j,"实际场景可扩展数据集字段，包含饮食偏好、礼品兴趣、禁忌话题等对主持人有用的详细信息。")},m(j,p){n(j,a,p)},d(j){j&&e(a)}}}function ps(B){let a,j;return a=new S({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(p){w(a.$$.fragment,p)},m(p,J){f(a,p,J),j=!0},p:E,i(p){j||(N(a.$$.fragment,p),j=!0)},o(p){I(a.$$.fragment,p),j=!1},d(p){h(a,p)}}}function Us(B){let a,j="我们将使用 Hugging Face <code>datasets</code> 库来加载数据集并将其转换为来自 <code>llama_index.core.schema</code> 模块的 <code>Document</code> 对象列表。",p,J,o;return J=new S({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=u("p"),a.innerHTML=j,p=r(),d(J.$$.fragment)},l(i){a=c(i,"P",{"data-svelte-h":!0}),C(a)!=="svelte-1huhyoc"&&(a.innerHTML=j),p=V(i),w(J.$$.fragment,i)},m(i,s){n(i,a,s),n(i,p,s),f(J,i,s),o=!0},p:E,i(i){o||(N(J.$$.fragment,i),o=!0)},o(i){I(J.$$.fragment,i),o=!1},d(i){i&&(e(a),e(p)),h(J,i)}}}function Js(B){let a,j="我们将使用 Hugging Face <code>datasets</code> 库来加载数据集并将其转换为来自 <code>langchain.docstore.document</code> 模块的 <code>Document</code> 对象列表。",p,J,o;return J=new S({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=u("p"),a.innerHTML=j,p=r(),d(J.$$.fragment)},l(i){a=c(i,"P",{"data-svelte-h":!0}),C(a)!=="svelte-qgr523"&&(a.innerHTML=j),p=V(i),w(J.$$.fragment,i)},m(i,s){n(i,a,s),n(i,p,s),f(J,i,s),o=!0},p:E,i(i){o||(N(J.$$.fragment,i),o=!0)},o(i){I(J.$$.fragment,i),o=!1},d(i){i&&(e(a),e(p)),h(J,i)}}}function os(B){let a,j,p,J,o,i;return a=new v({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[ps]},$$scope:{ctx:B}}}),p=new v({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[Us]},$$scope:{ctx:B}}}),o=new v({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[Js]},$$scope:{ctx:B}}}),{c(){d(a.$$.fragment),j=r(),d(p.$$.fragment),J=r(),d(o.$$.fragment)},l(s){w(a.$$.fragment,s),j=V(s),w(p.$$.fragment,s),J=V(s),w(o.$$.fragment,s)},m(s,U){f(a,s,U),n(s,j,U),f(p,s,U),n(s,J,U),f(o,s,U),i=!0},p(s,U){const g={};U&2&&(g.$$scope={dirty:U,ctx:s}),a.$set(g);const y={};U&2&&(y.$$scope={dirty:U,ctx:s}),p.$set(y);const m={};U&2&&(m.$$scope={dirty:U,ctx:s}),o.$set(m)},i(s){i||(N(a.$$.fragment,s),N(p.$$.fragment,s),N(o.$$.fragment,s),i=!0)},o(s){I(a.$$.fragment,s),I(p.$$.fragment,s),I(o.$$.fragment,s),i=!1},d(s){s&&(e(j),e(J)),h(a,s),h(p,s),h(o,s)}}}function rs(B){let a,j="BM25Retriever",p,J,o="sentence-transformers",i;return{c(){a=u("code"),a.textContent=j,p=X(" 是检索的一个很好的起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如来自 "),J=u("a"),J.textContent=o,i=X(" 的检索器。"),this.h()},l(s){a=c(s,"CODE",{"data-svelte-h":!0}),C(a)!=="svelte-13pi4gc"&&(a.textContent=j),p=Y(s," 是检索的一个很好的起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如来自 "),J=c(s,"A",{href:!0,"data-svelte-h":!0}),C(J)!=="svelte-8vrx36"&&(J.textContent=o),i=Y(s," 的检索器。"),this.h()},h(){b(J,"href","https://www.sbert.net/")},m(s,U){n(s,a,U),n(s,p,U),n(s,J,U),n(s,i,U)},p:E,d(s){s&&(e(a),e(p),e(J),e(i))}}}function Vs(B){let a,j="我们将使用“langchain_community.retrievers”模块中的“BM25Retriever”来创建一个检索工具。",p,J,o,i,s,U,g="让我们逐步了解这个工具：",y,m,$="<li><code>name</code> 和 <code>description</code> 帮助智能体了解何时以及如何使用此工具</li> <li><code>inputs</code> 定义工具所需的参数（在本例中为搜索查询）</li> <li>我们使用 <code>BM25Retriever</code>，这是一种强大的文本检索算法，不需要嵌入</li> <li><code>forward</code> 方法处理查询并返回最相关的客人信息</li>",F;return J=new Fl({props:{$$slots:{default:[rs]},$$scope:{ctx:B}}}),i=new S({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=u("p"),a.textContent=j,p=r(),d(J.$$.fragment),o=r(),d(i.$$.fragment),s=r(),U=u("p"),U.textContent=g,y=r(),m=u("ul"),m.innerHTML=$},l(t){a=c(t,"P",{"data-svelte-h":!0}),C(a)!=="svelte-1h1wsbb"&&(a.textContent=j),p=V(t),w(J.$$.fragment,t),o=V(t),w(i.$$.fragment,t),s=V(t),U=c(t,"P",{"data-svelte-h":!0}),C(U)!=="svelte-1nnhcdb"&&(U.textContent=g),y=V(t),m=c(t,"UL",{"data-svelte-h":!0}),C(m)!=="svelte-uto1l5"&&(m.innerHTML=$)},m(t,T){n(t,a,T),n(t,p,T),f(J,t,T),n(t,o,T),f(i,t,T),n(t,s,T),n(t,U,T),n(t,y,T),n(t,m,T),F=!0},p(t,T){const Q={};T&2&&(Q.$$scope={dirty:T,ctx:t}),J.$set(Q)},i(t){F||(N(J.$$.fragment,t),N(i.$$.fragment,t),F=!0)},o(t){I(J.$$.fragment,t),I(i.$$.fragment,t),F=!1},d(t){t&&(e(a),e(p),e(o),e(s),e(U),e(y),e(m)),h(J,t),h(i,t)}}}function Ts(B){let a,j="BM25Retriever",p,J,o="sentence-transformers",i;return{c(){a=u("code"),a.textContent=j,p=X(" 是一个很好的检索起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如 "),J=u("a"),J.textContent=o,i=X(" 中的检索器。"),this.h()},l(s){a=c(s,"CODE",{"data-svelte-h":!0}),C(a)!=="svelte-13pi4gc"&&(a.textContent=j),p=Y(s," 是一个很好的检索起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如 "),J=c(s,"A",{href:!0,"data-svelte-h":!0}),C(J)!=="svelte-8vrx36"&&(J.textContent=o),i=Y(s," 中的检索器。"),this.h()},h(){b(J,"href","https://www.sbert.net/")},m(s,U){n(s,a,U),n(s,p,U),n(s,J,U),n(s,i,U)},p:E,d(s){s&&(e(a),e(p),e(J),e(i))}}}function js(B){let a,j="我们将使用 <code>llama_index.retrievers.bm25</code> 模块中的 <code>BM25Retriever</code> 来创建一个检索工具。",p,J,o,i,s,U,g="让我们逐步了解这个工具。",y,m,$="<li>文档字符串帮助智能体了解何时以及如何使用此工具</li> <li>类型装饰器定义了工具所需的参数（在本例中为搜索查询）</li> <li>我们使用 <code>BM25Retriever</code>，这是一种强大的文本检索算法，不需要嵌入</li> <li>该方法处理查询并返回最相关的客人信息</li>",F;return J=new Fl({props:{$$slots:{default:[Ts]},$$scope:{ctx:B}}}),i=new S({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=u("p"),a.innerHTML=j,p=r(),d(J.$$.fragment),o=r(),d(i.$$.fragment),s=r(),U=u("p"),U.textContent=g,y=r(),m=u("ul"),m.innerHTML=$},l(t){a=c(t,"P",{"data-svelte-h":!0}),C(a)!=="svelte-re9s76"&&(a.innerHTML=j),p=V(t),w(J.$$.fragment,t),o=V(t),w(i.$$.fragment,t),s=V(t),U=c(t,"P",{"data-svelte-h":!0}),C(U)!=="svelte-54z6pz"&&(U.textContent=g),y=V(t),m=c(t,"UL",{"data-svelte-h":!0}),C(m)!=="svelte-1yb6oqz"&&(m.innerHTML=$)},m(t,T){n(t,a,T),n(t,p,T),f(J,t,T),n(t,o,T),f(i,t,T),n(t,s,T),n(t,U,T),n(t,y,T),n(t,m,T),F=!0},p(t,T){const Q={};T&2&&(Q.$$scope={dirty:T,ctx:t}),J.$set(Q)},i(t){F||(N(J.$$.fragment,t),N(i.$$.fragment,t),F=!0)},o(t){I(J.$$.fragment,t),I(i.$$.fragment,t),F=!1},d(t){t&&(e(a),e(p),e(o),e(s),e(U),e(y),e(m)),h(J,t),h(i,t)}}}function ms(B){let a,j="BM25Retriever",p,J,o="sentence-transformers",i;return{c(){a=u("code"),a.textContent=j,p=X(" 是一个很好的检索起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如 "),J=u("a"),J.textContent=o,i=X(" 中的检索器。"),this.h()},l(s){a=c(s,"CODE",{"data-svelte-h":!0}),C(a)!=="svelte-13pi4gc"&&(a.textContent=j),p=Y(s," 是一个很好的检索起点，但对于更高级的语义搜索，您可以考虑使用基于嵌入的检索器，例如 "),J=c(s,"A",{href:!0,"data-svelte-h":!0}),C(J)!=="svelte-8vrx36"&&(J.textContent=o),i=Y(s," 中的检索器。"),this.h()},h(){b(J,"href","https://www.sbert.net/")},m(s,U){n(s,a,U),n(s,p,U),n(s,J,U),n(s,i,U)},p:E,d(s){s&&(e(a),e(p),e(J),e(i))}}}function us(B){let a,j="我们将使用 <code>langchain_community.retrievers</code> 模块中的 <code>BM25Retriever</code> 来创建一个检索工具。",p,J,o,i,s,U,g="让我们逐步了解这个工具。",y,m,$="<li><code>name</code> 和 <code>description</code> 帮助智能体了解何时以及如何使用此工具。</li> <li>类型装饰器定义了工具所需的参数（在本例中为搜索查询）。</li> <li>我们使用 <code>BM25Retriever</code>，这是一种强大的文本检索算法，无需嵌入。</li> <li>该方法处理查询并返回最相关的客人信息。</li>",F;return J=new Fl({props:{$$slots:{default:[ms]},$$scope:{ctx:B}}}),i=new S({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=u("p"),a.innerHTML=j,p=r(),d(J.$$.fragment),o=r(),d(i.$$.fragment),s=r(),U=u("p"),U.textContent=g,y=r(),m=u("ul"),m.innerHTML=$},l(t){a=c(t,"P",{"data-svelte-h":!0}),C(a)!=="svelte-1pj6jx5"&&(a.innerHTML=j),p=V(t),w(J.$$.fragment,t),o=V(t),w(i.$$.fragment,t),s=V(t),U=c(t,"P",{"data-svelte-h":!0}),C(U)!=="svelte-54z6pz"&&(U.textContent=g),y=V(t),m=c(t,"UL",{"data-svelte-h":!0}),C(m)!=="svelte-1evf3o1"&&(m.innerHTML=$)},m(t,T){n(t,a,T),n(t,p,T),f(J,t,T),n(t,o,T),f(i,t,T),n(t,s,T),n(t,U,T),n(t,y,T),n(t,m,T),F=!0},p(t,T){const Q={};T&2&&(Q.$$scope={dirty:T,ctx:t}),J.$set(Q)},i(t){F||(N(J.$$.fragment,t),N(i.$$.fragment,t),F=!0)},o(t){I(J.$$.fragment,t),I(i.$$.fragment,t),F=!1},d(t){t&&(e(a),e(p),e(o),e(s),e(U),e(y),e(m)),h(J,t),h(i,t)}}}function cs(B){let a,j,p,J,o,i;return a=new v({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[Vs]},$$scope:{ctx:B}}}),p=new v({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[js]},$$scope:{ctx:B}}}),o=new v({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[us]},$$scope:{ctx:B}}}),{c(){d(a.$$.fragment),j=r(),d(p.$$.fragment),J=r(),d(o.$$.fragment)},l(s){w(a.$$.fragment,s),j=V(s),w(p.$$.fragment,s),J=V(s),w(o.$$.fragment,s)},m(s,U){f(a,s,U),n(s,j,U),f(p,s,U),n(s,J,U),f(o,s,U),i=!0},p(s,U){const g={};U&2&&(g.$$scope={dirty:U,ctx:s}),a.$set(g);const y={};U&2&&(y.$$scope={dirty:U,ctx:s}),p.$set(y);const m={};U&2&&(m.$$scope={dirty:U,ctx:s}),o.$set(m)},i(s){i||(N(a.$$.fragment,s),N(p.$$.fragment,s),N(o.$$.fragment,s),i=!0)},o(s){I(a.$$.fragment,s),I(p.$$.fragment,s),I(o.$$.fragment,s),i=!1},d(s){s&&(e(j),e(J)),h(a,s),h(p,s),h(o,s)}}}function Cs(B){let a,j,p,J="预期输出：",o,i,s,U,g="这最后一步具体做了什么：",y,m,$="<li>我们使用 <code>HfApiModel</code> 类初始化 Hugging Face 模型</li> <li>我们将智能体 (Alfred) 创建为 <code>CodeAgent</code>，它可以执行 Python 代码来解决问题</li> <li>我们让 Alfred 检索一位名叫“Lady Ada Lovelace”的客人的信息</li>",F;return a=new S({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBIZkFwaU1vZGVsJTBBJTBBJTIzJTIwJUU1JTg4JTlEJUU1JUE3JThCJUU1JThDJTk2JTIwSHVnZ2luZyUyMEZhY2UlMjAlRTYlQTglQTElRTUlOUUlOEIlMEFtb2RlbCUyMCUzRCUyMEhmQXBpTW9kZWwoKSUwQSUwQSUyMyUyMCVFNCVCRCVCRiVFNyU5NCVBOCVFNSVBRSVCRSVFNSVBRSVBMiVFNCVCRiVBMSVFNiU4MSVBRiVFNSVCNyVBNSVFNSU4NSVCNyVFNSU4OCU5QiVFNSVCQiVCQSVFNiU4OCU5MSVFNCVCQiVBQyVFNyU5QSU4NCVFNiU5OSU5QSVFNCVCQyU5QSVFNiU5OSVCQSVFOCU4MyVCRCVFNCVCRCU5MyUyMEFsZnJlZCUwQWFsZnJlZCUyMCUzRCUyMENvZGVBZ2VudCh0b29scyUzRCU1Qmd1ZXN0X2luZm9fdG9vbCU1RCUyQyUyMG1vZGVsJTNEbW9kZWwpJTBBJTBBJTIzJTIwRXhhbXBsZSUyMHF1ZXJ5JTIwQWxmcmVkJTIwbWlnaHQlMjByZWNlaXZlJTIwZHVyaW5nJTIwdGhlJTIwZ2FsYSUwQXJlc3BvbnNlJTIwJTNEJTIwYWxmcmVkLnJ1biglMjJUZWxsJTIwbWUlMjBhYm91dCUyMG91ciUyMGd1ZXN0JTIwbmFtZWQlMjAnTGFkeSUyMEFkYSUyMExvdmVsYWNlJy4lMjIpJTBBJTBBcHJpbnQoJTIyJUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUyMiklMEFwcmludChyZXNwb25zZSk=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, HfApiModel

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

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