import{s as Yl,o as Sl,n as E}from"../chunks/scheduler.505acc25.js";import{S as Wl,i as Ol,e as I,s as c,c as r,h as _l,a as b,d as M,b as i,f as Nl,g as y,j as Q,k as dl,l as vl,m as T,n as m,t as w,o as h,p as u}from"../chunks/index.b1175496.js";import{C as Xl,H as K}from"../chunks/Heading.eda51538.js";import{C as f}from"../chunks/CodeBlock.9d480d26.js";import{H as Il,a as R}from"../chunks/HfOption.ccfd750e.js";import{E as xl}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.ea377ea6.js";function zl(d){let a,e,J,j="预期输出:",n,U,s;return a=new f({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBEdWNrRHVja0dvU2VhcmNoVG9vbCUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiUyMER1Y2tEdWNrR28lMjAlRTYlOTAlOUMlRTclQjQlQTIlRTUlQjclQTUlRTUlODUlQjclMEFzZWFyY2hfdG9vbCUyMCUzRCUyMER1Y2tEdWNrR29TZWFyY2hUb29sKCklMEElMEElMjMlMjAlRTclQTQlQkElRTQlQkUlOEIlRTclOTQlQTglRTYlQjMlOTUlMEFyZXN1bHRzJTIwJTNEJTIwc2VhcmNoX3Rvb2woJTIyV2hvJ3MlMjB0aGUlMjBjdXJyZW50JTIwUHJlc2lkZW50JTIwb2YlMjBGcmFuY2UlM0YlMjIpJTBBcHJpbnQocmVzdWx0cyk=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> DuckDuckGoSearchTool

<span class="hljs-comment"># 初始化 DuckDuckGo 搜索工具</span>
search_tool = DuckDuckGoSearchTool()

<span class="hljs-comment"># 示例用法</span>
results = search_tool(<span class="hljs-string">&quot;Who&#x27;s the current President of France?&quot;</span>)
<span class="hljs-built_in">print</span>(results)`,wrap:!1}}),U=new f({props:{code:"JUU2JUIzJTk1JUU1JTlCJUJEJUU3JThFJUIwJUU0JUJCJUJCJUU2JTgwJUJCJUU3JUJCJTlGJUU0JUI4JUJBJTIwRW1tYW51ZWwlMjBNYWNyb24lRTMlODAlODI=",highlighted:"法国现任总统为 Emmanuel Macron。",wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1w2r872"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(l,J,p),T(l,n,p),m(U,l,p),s=!0},p:E,i(l){s||(w(a.$$.fragment,l),w(U.$$.fragment,l),s=!0)},o(l){h(a.$$.fragment,l),h(U.$$.fragment,l),s=!1},d(l){l&&(M(e),M(J),M(n)),u(a,l),u(U,l)}}}function ql(d){let a,e,J,j="预期输出:",n,U,s;return a=new f({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LnRvb2xzLmR1Y2tkdWNrZ28lMjBpbXBvcnQlMjBEdWNrRHVja0dvU2VhcmNoVG9vbFNwZWMlMEFmcm9tJTIwbGxhbWFfaW5kZXguY29yZS50b29scyUyMGltcG9ydCUyMEZ1bmN0aW9uVG9vbCUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiUyMER1Y2tEdWNrR28lMjAlRTYlOTAlOUMlRTclQjQlQTIlRTUlQjclQTUlRTUlODUlQjclMEF0b29sX3NwZWMlMjAlM0QlMjBEdWNrRHVja0dvU2VhcmNoVG9vbFNwZWMoKSUwQSUwQXNlYXJjaF90b29sJTIwJTNEJTIwRnVuY3Rpb25Ub29sLmZyb21fZGVmYXVsdHModG9vbF9zcGVjLmR1Y2tkdWNrZ29fZnVsbF9zZWFyY2gpJTBBJTIzJTIwJUU3JUE0JUJBJUU0JUJFJThCJUU3JTk0JUE4JUU2JUIzJTk1JTBBcmVzcG9uc2UlMjAlM0QlMjBzZWFyY2hfdG9vbCglMjJXaG8ncyUyMHRoZSUyMGN1cnJlbnQlMjBQcmVzaWRlbnQlMjBvZiUyMEZyYW5jZSUzRiUyMiklMEFwcmludChyZXNwb25zZS5yYXdfb3V0cHV0JTVCLTElNUQlNUInYm9keSclNUQp",highlighted:`<span class="hljs-keyword">from</span> llama_index.tools.duckduckgo <span class="hljs-keyword">import</span> DuckDuckGoSearchToolSpec
<span class="hljs-keyword">from</span> llama_index.core.tools <span class="hljs-keyword">import</span> FunctionTool

<span class="hljs-comment"># 初始化 DuckDuckGo 搜索工具</span>
tool_spec = DuckDuckGoSearchToolSpec()

search_tool = FunctionTool.from_defaults(tool_spec.duckduckgo_full_search)
<span class="hljs-comment"># 示例用法</span>
response = search_tool(<span class="hljs-string">&quot;Who&#x27;s the current President of France?&quot;</span>)
<span class="hljs-built_in">print</span>(response.raw_output[-<span class="hljs-number">1</span>][<span class="hljs-string">&#x27;body&#x27;</span>])`,wrap:!1}}),U=new f({props:{code:"JUU2JUIzJTk1JUU1JTg1JUIwJUU4JUE1JUJGJUU1JTg1JUIxJUU1JTkyJThDJUU1JTlCJUJEJUU2JTgwJUJCJUU3JUJCJTlGJUU2JTk4JUFGJUU2JUIzJTk1JUU1JTlCJUJEJUU3JTlBJTg0JUU1JTlCJUJEJUU1JUFFJUI2JUU1JTg1JTgzJUU5JUE2JTk2JUUzJTgwJTgyJUU3JThFJUIwJUU0JUJCJUJCJUU2JTgwJUJCJUU3JUJCJTlGJUU2JTk4JUFGJTIwRW1tYW51ZWwlMjBNYWNyb24lRUYlQkMlOEMlRTQlQkElOEUyMDE3JUU1JUI5JUI0NSVFNiU5QyU4ODE0JUU2JTk3JUE1JUU1JUIwJUIxJUU0JUJCJUJCJUVGJUJDJThDJUU1JUI5JUI2JUU1JTlDJUE4MjAxNyVFNSVCOSVCNDUlRTYlOUMlODg3JUU2JTk3JUE1JUU0JUI4JUJFJUU4JUExJThDJUU3JTlBJTg0JUU2JTgwJUJCJUU3JUJCJTlGJUU5JTgwJTg5JUU0JUI4JUJFJUU3JUFDJUFDJUU0JUJBJThDJUU4JUJEJUFFJUU0JUI4JUFEJUU1JTg3JUJCJUU4JUI0JUE1JTIwTWFyaW5lJTIwTGUlMjBQZW4lRTMlODAlODIlRTYlQjMlOTUlRTUlOUIlQkQlRTclQUMlQUMlRTQlQkElOTQlRTUlODUlQjElRTUlOTIlOEMlRTUlOUIlQkQlRTYlODAlQkIlRTclQkIlOUYlRTUlOTAlOEQlRTUlOEQlOTUlMjAlRTclQkMlOTYlRTUlOEYlQjclMjAlRTglODIlOTYlRTUlODMlOEYlMjAlRTUlQTclOTMlRTUlOTAlOEQlMjAuLi4=",highlighted:'法兰西共和国总统是法国的国家元首。现任总统是 Emmanuel Macron，于<span class="hljs-number">2017年5月14</span>日就任，并在<span class="hljs-number">2017年5月7</span>日举行的总统选举第二轮中击败 Marine Le Pen。法国第五共和国总统名单 编号 肖像 姓名 ...',wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1w2r872"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(l,J,p),T(l,n,p),m(U,l,p),s=!0},p:E,i(l){s||(w(a.$$.fragment,l),w(U.$$.fragment,l),s=!0)},o(l){h(a.$$.fragment,l),h(U.$$.fragment,l),s=!1},d(l){l&&(M(e),M(J),M(n)),u(a,l),u(U,l)}}}function Hl(d){let a,e,J,j="预期输出:",n,U,s;return a=new f({props:{code:"ZnJvbSUyMGxhbmdjaGFpbl9jb21tdW5pdHkudG9vbHMlMjBpbXBvcnQlMjBEdWNrRHVja0dvU2VhcmNoUnVuJTBBJTBBc2VhcmNoX3Rvb2wlMjAlM0QlMjBEdWNrRHVja0dvU2VhcmNoUnVuKCklMEFyZXN1bHRzJTIwJTNEJTIwc2VhcmNoX3Rvb2wuaW52b2tlKCUyMldobydzJTIwdGhlJTIwY3VycmVudCUyMFByZXNpZGVudCUyMG9mJTIwRnJhbmNlJTNGJTIyKSUwQXByaW50KHJlc3VsdHMp",highlighted:`<span class="hljs-keyword">from</span> langchain_community.tools <span class="hljs-keyword">import</span> DuckDuckGoSearchRun

search_tool = DuckDuckGoSearchRun()
results = search_tool.invoke(<span class="hljs-string">&quot;Who&#x27;s the current President of France?&quot;</span>)
<span class="hljs-built_in">print</span>(results)`,wrap:!1}}),U=new f({props:{code:"RW1tYW51ZWwlMjBNYWNyb24lMjAlRUYlQkMlODgxOTc3JUU1JUI5JUI0MTIlRTYlOUMlODgyMSVFNiU5NyVBNSVFNyU5NCU5RiVFNCVCQSU4RSVFNCVCQSU5QSVFNyU5QyVBMCVFRiVCQyU4OSVFNiVCMyU5NSVFNSU5QiVCRCVFNiU5NCVCRiVFNiVCMiVCQiVFNSVBRSVCNiVFRiVCQyU4QzIwMTclRTUlQjklQjQlRTUlQkQlOTMlRTklODAlODklRTYlODAlQkIlRTclQkIlOUYuLi4=",highlighted:'<span class="hljs-attribute">Emmanuel</span> Macron （<span class="hljs-number">1977</span>年<span class="hljs-number">12</span>月<span class="hljs-number">21</span>日生于亚眠）法国政治家，<span class="hljs-number">2017</span>年当选总统...',wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1w2r872"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(l,J,p),T(l,n,p),m(U,l,p),s=!0},p:E,i(l){s||(w(a.$$.fragment,l),w(U.$$.fragment,l),s=!0)},o(l){h(a.$$.fragment,l),h(U.$$.fragment,l),s=!1},d(l){l&&(M(e),M(J),M(n)),u(a,l),u(U,l)}}}function Dl(d){let a,e,J,j,n,U;return a=new R({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[zl]},$$scope:{ctx:d}}}),J=new R({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[ql]},$$scope:{ctx:d}}}),n=new R({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[Hl]},$$scope:{ctx:d}}}),{c(){r(a.$$.fragment),e=c(),r(J.$$.fragment),j=c(),r(n.$$.fragment)},l(s){y(a.$$.fragment,s),e=i(s),y(J.$$.fragment,s),j=i(s),y(n.$$.fragment,s)},m(s,l){m(a,s,l),T(s,e,l),m(J,s,l),T(s,j,l),m(n,s,l),U=!0},p(s,l){const p={};l&2&&(p.$$scope={dirty:l,ctx:s}),a.$set(p);const C={};l&2&&(C.$$scope={dirty:l,ctx:s}),J.$set(C);const g={};l&2&&(g.$$scope={dirty:l,ctx:s}),n.$set(g)},i(s){U||(w(a.$$.fragment,s),w(J.$$.fragment,s),w(n.$$.fragment,s),U=!0)},o(s){h(a.$$.fragment,s),h(J.$$.fragment,s),h(n.$$.fragment,s),U=!1},d(s){s&&(M(e),M(j)),u(a,s),u(J,s),u(n,s)}}}function Kl(d){let a,e;return a=new f({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBUb29sJTBBaW1wb3J0JTIwcmFuZG9tJTBBJTBBY2xhc3MlMjBXZWF0aGVySW5mb1Rvb2woVG9vbCklM0ElMEElMjAlMjAlMjAlMjBuYW1lJTIwJTNEJTIwJTIyd2VhdGhlcl9pbmZvJTIyJTBBJTIwJTIwJTIwJTIwZGVzY3JpcHRpb24lMjAlM0QlMjAlMjJGZXRjaGVzJTIwZHVtbXklMjB3ZWF0aGVyJTIwaW5mb3JtYXRpb24lMjBmb3IlMjBhJTIwZ2l2ZW4lMjBsb2NhdGlvbi4lMjIlMEElMjAlMjAlMjAlMjBpbnB1dHMlMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJsb2NhdGlvbiUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC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0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjAlRTklOUElOEYlRTYlOUMlQkElRTklODAlODklRTYlOEIlQTklRTQlQjglODAlRTclQTclOEQlRTUlQTQlQTklRTYlQjAlOTQlRTclOEElQjYlRTUlODYlQjUlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBkYXRhJTIwJTNEJTIwcmFuZG9tLmNob2ljZSh3ZWF0aGVyX2NvbmRpdGlvbnMpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwZiUyMldlYXRoZXIlMjBpbiUyMCU3QmxvY2F0aW9uJTdEJTNBJTIwJTdCZGF0YSU1Qidjb25kaXRpb24nJTVEJTdEJTJDJTIwJTdCZGF0YSU1Qid0ZW1wX2MnJTVEJTdEJUMyJUIwQyUyMiUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiVFNSVCNyVBNSVFNSU4NSVCNyUwQXdlYXRoZXJfaW5mb190b29sJTIwJTNEJTIwV2VhdGhlckluZm9Ub29sKCk=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> Tool
<span class="hljs-keyword">import</span> random

<span class="hljs-keyword">class</span> <span class="hljs-title class_">WeatherInfoTool</span>(<span class="hljs-title class_ inherited__">Tool</span>):
    name = <span class="hljs-string">&quot;weather_info&quot;</span>
    description = <span class="hljs-string">&quot;Fetches dummy weather information for a given location.&quot;</span>
    inputs = {
        <span class="hljs-string">&quot;location&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 location to get weather information for.&quot;</span>
        }
    }
    output_type = <span class="hljs-string">&quot;string&quot;</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, location: <span class="hljs-built_in">str</span></span>):
        <span class="hljs-comment"># 虚拟天气数据</span>
        weather_conditions = [
            {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Rainy&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">15</span>},
            {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Clear&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">25</span>},
            {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Windy&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">20</span>}
        ]
        <span class="hljs-comment"># 随机选择一种天气状况</span>
        data = random.choice(weather_conditions)
        <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;Weather in <span class="hljs-subst">{location}</span>: <span class="hljs-subst">{data[<span class="hljs-string">&#x27;condition&#x27;</span>]}</span>, <span class="hljs-subst">{data[<span class="hljs-string">&#x27;temp_c&#x27;</span>]}</span>°C&quot;</span>

<span class="hljs-comment"># 初始化工具</span>
weather_info_tool = WeatherInfoTool()`,wrap:!1}}),{c(){r(a.$$.fragment)},l(J){y(a.$$.fragment,J)},m(J,j){m(a,J,j),e=!0},p:E,i(J){e||(w(a.$$.fragment,J),e=!0)},o(J){h(a.$$.fragment,J),e=!1},d(J){u(a,J)}}}function Ll(d){let a,e;return a=new f({props:{code:"aW1wb3J0JTIwcmFuZG9tJTBBZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUudG9vbHMlMjBpbXBvcnQlMjBGdW5jdGlvblRvb2wlMEElMEFkZWYlMjBnZXRfd2VhdGhlcl9pbmZvKGxvY2F0aW9uJTNBJTIwc3RyKSUyMC0lM0UlMjBzdHIlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjJGZXRjaGVzJTIwZHVtbXklMjB3ZWF0aGVyJTIwaW5mb3JtYXRpb24lMjBmb3IlMjBhJTIwZ2l2ZW4lMjBsb2Nh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UwQXdlYXRoZXJfaW5mb190b29sJTIwJTNEJTIwRnVuY3Rpb25Ub29sLmZyb21fZGVmYXVsdHMoZ2V0X3dlYXRoZXJfaW5mbyk=",highlighted:`<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">from</span> llama_index.core.tools <span class="hljs-keyword">import</span> FunctionTool

<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_weather_info</span>(<span class="hljs-params">location: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;Fetches dummy weather information for a given location.&quot;&quot;&quot;</span>
    <span class="hljs-comment"># 虚拟天气数据</span>
    weather_conditions = [
        {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Rainy&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">15</span>},
        {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Clear&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">25</span>},
        {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Windy&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">20</span>}
    ]
    <span class="hljs-comment"># 随机选择一种天气状况</span>
    data = random.choice(weather_conditions)
    <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;Weather in <span class="hljs-subst">{location}</span>: <span class="hljs-subst">{data[<span class="hljs-string">&#x27;condition&#x27;</span>]}</span>, <span class="hljs-subst">{data[<span class="hljs-string">&#x27;temp_c&#x27;</span>]}</span>°C&quot;</span>

<span class="hljs-comment"># 初始化工具</span>
weather_info_tool = FunctionTool.from_defaults(get_weather_info)`,wrap:!1}}),{c(){r(a.$$.fragment)},l(J){y(a.$$.fragment,J)},m(J,j){m(a,J,j),e=!0},p:E,i(J){e||(w(a.$$.fragment,J),e=!0)},o(J){h(a.$$.fragment,J),e=!1},d(J){u(a,J)}}}function Pl(d){let a,e;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Nob2ljZSh3ZWF0aGVyX2NvbmRpdGlvbnMpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwZiUyMldlYXRoZXIlMjBpbiUyMCU3QmxvY2F0aW9uJTdEJTNBJTIwJTdCZGF0YSU1Qidjb25kaXRpb24nJTVEJTdEJTJDJTIwJTdCZGF0YSU1Qid0ZW1wX2MnJTVEJTdEJUMyJUIwQyUyMiUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiVFNSVCNyVBNSVFNSU4NSVCNyUwQXdlYXRoZXJfaW5mb190b29sJTIwJTNEJTIwVG9vbCglMEElMjAlMjAlMjAlMjBuYW1lJTNEJTIyZ2V0X3dlYXRoZXJfaW5mbyUyMiUyQyUwQSUyMCUyMCUyMCUyMGZ1bmMlM0RnZXRfd2VhdGhlcl9pbmZvJTJDJTBBJTIwJTIwJTIwJTIwZGVzY3JpcHRpb24lM0QlMjJGZXRjaGVzJTIwZHVtbXklMjB3ZWF0aGVyJTIwaW5mb3JtYXRpb24lMjBmb3IlMjBhJTIwZ2l2ZW4lMjBsb2NhdGlvbi4lMjIlMEEp",highlighted:`<span class="hljs-keyword">from</span> langchain.tools <span class="hljs-keyword">import</span> Tool
<span class="hljs-keyword">import</span> random

<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_weather_info</span>(<span class="hljs-params">location: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;Fetches dummy weather information for a given location.&quot;&quot;&quot;</span>
    <span class="hljs-comment"># 虚拟天气数据</span>
    weather_conditions = [
        {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Rainy&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">15</span>},
        {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Clear&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">25</span>},
        {<span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Windy&quot;</span>, <span class="hljs-string">&quot;temp_c&quot;</span>: <span class="hljs-number">20</span>}
    ]
    <span class="hljs-comment"># 随机选择一种天气状况</span>
    data = random.choice(weather_conditions)
    <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;Weather in <span class="hljs-subst">{location}</span>: <span class="hljs-subst">{data[<span class="hljs-string">&#x27;condition&#x27;</span>]}</span>, <span class="hljs-subst">{data[<span class="hljs-string">&#x27;temp_c&#x27;</span>]}</span>°C&quot;</span>

<span class="hljs-comment"># 初始化工具</span>
weather_info_tool = Tool(
    name=<span class="hljs-string">&quot;get_weather_info&quot;</span>,
    func=get_weather_info,
    description=<span class="hljs-string">&quot;Fetches dummy weather information for a given location.&quot;</span>
)`,wrap:!1}}),{c(){r(a.$$.fragment)},l(J){y(a.$$.fragment,J)},m(J,j){m(a,J,j),e=!0},p:E,i(J){e||(w(a.$$.fragment,J),e=!0)},o(J){h(a.$$.fragment,J),e=!1},d(J){u(a,J)}}}function ls(d){let a,e,J,j,n,U;return a=new R({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[Kl]},$$scope:{ctx:d}}}),J=new R({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[Ll]},$$scope:{ctx:d}}}),n=new R({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[Pl]},$$scope:{ctx:d}}}),{c(){r(a.$$.fragment),e=c(),r(J.$$.fragment),j=c(),r(n.$$.fragment)},l(s){y(a.$$.fragment,s),e=i(s),y(J.$$.fragment,s),j=i(s),y(n.$$.fragment,s)},m(s,l){m(a,s,l),T(s,e,l),m(J,s,l),T(s,j,l),m(n,s,l),U=!0},p(s,l){const p={};l&2&&(p.$$scope={dirty:l,ctx:s}),a.$set(p);const C={};l&2&&(C.$$scope={dirty:l,ctx:s}),J.$set(C);const g={};l&2&&(g.$$scope={dirty:l,ctx:s}),n.$set(g)},i(s){U||(w(a.$$.fragment,s),w(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ZWwuaWQlN0QlMjB3aXRoJTIwJTdCbW9kZWwuZG93bmxvYWRzJTNBJTJDJTdEJTIwZG93bmxvYWRzLiUyMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGVsc2UlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBmJTIyTm8lMjBtb2RlbHMlMjBmb3VuZCUyMGZvciUyMGF1dGhvciUyMCU3QmF1dGhvciU3RC4lMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBleGNlcHQlMjBFeGNlcHRpb24lMjBhcyUyMGUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBmJTIyRXJyb3IlMjBmZXRjaGluZyUyMG1vZGVscyUyMGZvciUyMCU3QmF1dGhvciU3RCUzQSUyMCU3QnN0cihlKSU3RCUyMiUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiVFNSVCNyVBNSVFNSU4NSVCNyUwQWh1Yl9zdGF0c190b29sJTIwJTNEJTIwSHViU3RhdHNUb29sKCklMEElMEElMjMlMjAlRTclQTQlQkElRTQlQkUlOEIlRTclOTQlQTglRTYlQjMlOTUlMEFwcmludChodWJfc3RhdHNfdG9vbCglMjJmYWNlYm9vayUyMikpJTIwJTIzJTIwRXhhbXBsZSUzQSUyMEdldCUyMHRoZSUyMG1vc3QlMjBkb3dubG9hZGVkJTIwbW9kZWwlMjBieSUyMEZhY2Vib29r",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> Tool
<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> list_models

<span class="hljs-keyword">class</span> <span class="hljs-title class_">HubStatsTool</span>(<span class="hljs-title class_ inherited__">Tool</span>):
    name = <span class="hljs-string">&quot;hub_stats&quot;</span>
    description = <span class="hljs-string">&quot;Fetches the most downloaded model from a specific author on the Hugging Face Hub.&quot;</span>
    inputs = {
        <span class="hljs-string">&quot;author&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 username of the model author/organization to find models from.&quot;</span>
        }
    }
    output_type = <span class="hljs-string">&quot;string&quot;</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, author: <span class="hljs-built_in">str</span></span>):
        <span class="hljs-keyword">try</span>:
            <span class="hljs-comment"># 列出指定作者的模型，按下载次数排序</span>
            models = <span class="hljs-built_in">list</span>(list_models(author=author, sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>, limit=<span class="hljs-number">1</span>))
            
            <span class="hljs-keyword">if</span> models:
                model = models[<span class="hljs-number">0</span>]
                <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;The most downloaded model by <span class="hljs-subst">{author}</span> is <span class="hljs-subst">{model.<span class="hljs-built_in">id</span>}</span> with <span class="hljs-subst">{model.downloads:,}</span> downloads.&quot;</span>
            <span class="hljs-keyword">else</span>:
                <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;No models found for author <span class="hljs-subst">{author}</span>.&quot;</span>
        <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
            <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;Error fetching models for <span class="hljs-subst">{author}</span>: <span class="hljs-subst">{<span class="hljs-built_in">str</span>(e)}</span>&quot;</span>

<span class="hljs-comment"># 初始化工具</span>
hub_stats_tool = HubStatsTool()

<span class="hljs-comment"># 示例用法</span>
<span class="hljs-built_in">print</span>(hub_stats_tool(<span class="hljs-string">&quot;facebook&quot;</span>)) <span class="hljs-comment"># Example: Get the most downloaded model by Facebook</span>`,wrap:!1}}),U=new f({props:{code:"RmFjZWJvb2slMjAlRTQlQjglOEIlRTglQkQlQkQlRTYlQUMlQTElRTYlOTUlQjAlRTYlOUMlODAlRTUlQTQlOUElRTclOUElODQlRTYlQTglQTElRTUlOUUlOEIlRTYlOTglQUYlMjBmYWNlYm9vayUyRmVzbWZvbGRfdjElRUYlQkMlOEMlRTQlQjglOEIlRTglQkQlQkQlRTYlQUMlQTElRTYlOTUlQjAlRTQlQjglQkElMjAxMiUyQzU0NCUyQzU1MCUyMCVFNiVBQyVBMSVFMyU4MCU4Mg==",highlighted:'<span class="hljs-attribute">Facebook</span> 下载次数最多的模型是 facebook/esmfold_v1，下载次数为 <span class="hljs-number">12</span>,<span class="hljs-number">544</span>,<span class="hljs-number">550</span> 次。',wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1w2r872"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(l,J,p),T(l,n,p),m(U,l,p),s=!0},p:E,i(l){s||(w(a.$$.fragment,l),w(U.$$.fragment,l),s=!0)},o(l){h(a.$$.fragment,l),h(U.$$.fragment,l),s=!1},d(l){l&&(M(e),M(J),M(n)),u(a,l),u(U,l)}}}function ts(d){let a,e,J,j="预期输出:",n,U,s;return a=new f({props:{code:"aW1wb3J0JTIwcmFuZG9tJTBBZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUudG9vbHMlMjBpbXBvcnQlMjBGdW5jdGlvblRvb2wlMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwbGlzdF9tb2RlbHMlMEElMEFkZWYlMjBnZXRfaHViX3N0YXRzKGF1dGhvciUzQSUyMHN0ciklMjAtJTNFJTIwc3RyJTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyRmV0Y2hlcyUyMHRoZSUyMG1vc3QlMjBkb3dubG9hZGVk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UyMGYlMjJObyUyMG1vZGVscyUyMGZvdW5kJTIwZm9yJTIwYXV0aG9yJTIwJTdCYXV0aG9yJTdELiUyMiUwQSUyMCUyMCUyMCUyMGV4Y2VwdCUyMEV4Y2VwdGlvbiUyMGFzJTIwZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMGYlMjJFcnJvciUyMGZldGNoaW5nJTIwbW9kZWxzJTIwZm9yJTIwJTdCYXV0aG9yJTdEJTNBJTIwJTdCc3RyKGUpJTdEJTIyJTBBJTBBJTIzJTIwJUU1JTg4JTlEJUU1JUE3JThCJUU1JThDJTk2JUU1JUI3JUE1JUU1JTg1JUI3JTBBaHViX3N0YXRzX3Rvb2wlMjAlM0QlMjBGdW5jdGlvblRvb2wuZnJvbV9kZWZhdWx0cyhnZXRfaHViX3N0YXRzKSUwQSUwQSUyMyUyMCVFNyVBNCVCQSVFNCVCRSU4QiVFNyU5NCVBOCVFNiVCMyU5NSUwQXByaW50KGh1Yl9zdGF0c190b29sKCUyMmZhY2Vib29rJTIyKSklMjAlMjMlMjBFeGFtcGxlJTNBJTIwR2V0JTIwdGhlJTIwbW9zdCUyMGRvd25sb2FkZWQlMjBtb2RlbCUyMGJ5JTIwRmFjZWJvb2s=",highlighted:`<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">from</span> llama_index.core.tools <span class="hljs-keyword">import</span> FunctionTool
<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> list_models

<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_hub_stats</span>(<span class="hljs-params">author: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;Fetches the most downloaded model from a specific author on the Hugging Face Hub.&quot;&quot;&quot;</span>
    <span class="hljs-keyword">try</span>:
        <span class="hljs-comment"># 列出指定作者的模型，按下载次数排序</span>
        models = <span class="hljs-built_in">list</span>(list_models(author=author, sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>, limit=<span class="hljs-number">1</span>))

        <span class="hljs-keyword">if</span> models:
            model = models[<span class="hljs-number">0</span>]
            <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;The most downloaded model by <span class="hljs-subst">{author}</span> is <span class="hljs-subst">{model.<span class="hljs-built_in">id</span>}</span> with <span class="hljs-subst">{model.downloads:,}</span> downloads.&quot;</span>
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;No models found for author <span class="hljs-subst">{author}</span>.&quot;</span>
    <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
        <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;Error fetching models for <span class="hljs-subst">{author}</span>: <span class="hljs-subst">{<span class="hljs-built_in">str</span>(e)}</span>&quot;</span>

<span class="hljs-comment"># 初始化工具</span>
hub_stats_tool = FunctionTool.from_defaults(get_hub_stats)

<span class="hljs-comment"># 示例用法</span>
<span class="hljs-built_in">print</span>(hub_stats_tool(<span class="hljs-string">&quot;facebook&quot;</span>)) <span class="hljs-comment"># Example: Get the most downloaded model by Facebook</span>`,wrap:!1}}),U=new f({props:{code:"RmFjZWJvb2slMjAlRTQlQjglOEIlRTglQkQlQkQlRTYlQUMlQTElRTYlOTUlQjAlRTYlOUMlODAlRTUlQTQlOUElRTclOUElODQlRTYlQTglQTElRTUlOUUlOEIlRTYlOTglQUYlMjBmYWNlYm9vayUyRmVzbWZvbGRfdjElRUYlQkMlOEMlRTQlQjglOEIlRTglQkQlQkQlRTYlQUMlQTElRTYlOTUlQjAlRTQlQjglQkElMjAxMiUyQzU0NCUyQzU1MCUyMCVFNiVBQyVBMSVFMyU4MCU4Mg==",highlighted:'<span class="hljs-attribute">Facebook</span> 下载次数最多的模型是 facebook/esmfold_v1，下载次数为 <span class="hljs-number">12</span>,<span class="hljs-number">544</span>,<span class="hljs-number">550</span> 次。',wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1w2r872"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(l,J,p),T(l,n,p),m(U,l,p),s=!0},p:E,i(l){s||(w(a.$$.fragment,l),w(U.$$.fragment,l),s=!0)},o(l){h(a.$$.fragment,l),h(U.$$.fragment,l),s=!1},d(l){l&&(M(e),M(J),M(n)),u(a,l),u(U,l)}}}function Js(d){let a,e,J,j="预期输出:",n,U,s;return a=new f({props:{code:"ZnJvbSUyMGxhbmdjaGFpbi50b29scyUyMGltcG9ydCUyMFRvb2wlMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwbGlzdF9tb2RlbHMlMEElMEFkZWYlMjBnZXRfaHViX3N0YXRzKGF1dGhvciUzQSUyMHN0ciklMjAtJTNFJTIwc3RyJTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyRmV0Y2hlcyUyMHRoZSUyMG1vc3QlMjBkb3dubG9hZGVkJTIwbW9kZWwlMjBmcm9tJTIwYSUyMHNwZWNpZmljJTIwYXV0aG9yJTIwb24lMjB0aGUlMjBIdWdnaW5nJTIwRmFjZSUyMEh1Yi4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjB0cnklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjAlRTUlODglOTclRTUlODclQkElRTYlOEMlODclRTUlQUUlOUElRTQlQkQlOUMlRTglODAlODUlRTclOUElODQlRTYlQTglQTElRTUlOUUlOEIlRUYlQkMlOEMlRTYlOEMlODklRTQlQjglOEIlRTglQkQlQkQlRTYlQUMlQTElRTYlOTUlQjAlRTYlOEUlOTIlRTUlQkElOEYlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtb2RlbHMlMjAlM0QlMjBsaXN0KGxpc3Rf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RfaHViX3N0YXRzJTIyJTJDJTBBJTIwJTIwJTIwJTIwZnVuYyUzRGdldF9odWJfc3RhdHMlMkMlMEElMjAlMjAlMjAlMjBkZXNjcmlwdGlvbiUzRCUyMkZldGNoZXMlMjB0aGUlMjBtb3N0JTIwZG93bmxvYWRlZCUyMG1vZGVsJTIwZnJvbSUyMGElMjBzcGVjaWZpYyUyMGF1dGhvciUyMG9uJTIwdGhlJTIwSHVnZ2luZyUyMEZhY2UlMjBIdWIuJTIyJTBBKSUwQSUwQSUyMyUyMCVFNyVBNCVCQSVFNCVCRSU4QiVFNyU5NCVBOCVFNiVCMyU5NSUwQXByaW50KGh1Yl9zdGF0c190b29sLmludm9rZSglMjJmYWNlYm9vayUyMikpJTIwJTIzJTIwRXhhbXBsZSUzQSUyMEdldCUyMHRoZSUyMG1vc3QlMjBkb3dubG9hZGVkJTIwbW9kZWwlMjBieSUyMEZhY2Vib29r",highlighted:`<span class="hljs-keyword">from</span> langchain.tools <span class="hljs-keyword">import</span> Tool
<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> list_models

<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_hub_stats</span>(<span class="hljs-params">author: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;Fetches the most downloaded model from a specific author on the Hugging Face Hub.&quot;&quot;&quot;</span>
    <span class="hljs-keyword">try</span>:
        <span class="hljs-comment"># 列出指定作者的模型，按下载次数排序</span>
        models = <span class="hljs-built_in">list</span>(list_models(author=author, sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>, limit=<span class="hljs-number">1</span>))

        <span class="hljs-keyword">if</span> models:
            model = models[<span class="hljs-number">0</span>]
            <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;The most downloaded model by <span class="hljs-subst">{author}</span> is <span class="hljs-subst">{model.<span class="hljs-built_in">id</span>}</span> with <span class="hljs-subst">{model.downloads:,}</span> downloads.&quot;</span>
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;No models found for author <span class="hljs-subst">{author}</span>.&quot;</span>
    <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
        <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;Error fetching models for <span class="hljs-subst">{author}</span>: <span class="hljs-subst">{<span class="hljs-built_in">str</span>(e)}</span>&quot;</span>

<span class="hljs-comment"># 初始化工具</span>
hub_stats_tool = Tool(
    name=<span class="hljs-string">&quot;get_hub_stats&quot;</span>,
    func=get_hub_stats,
    description=<span class="hljs-string">&quot;Fetches the most downloaded model from a specific author on the Hugging Face Hub.&quot;</span>
)

<span class="hljs-comment"># 示例用法</span>
<span class="hljs-built_in">print</span>(hub_stats_tool.invoke(<span class="hljs-string">&quot;facebook&quot;</span>)) <span class="hljs-comment"># Example: Get the most downloaded model by Facebook</span>`,wrap:!1}}),U=new f({props:{code:"RmFjZWJvb2slMjAlRTQlQjglOEIlRTglQkQlQkQlRTYlQUMlQTElRTYlOTUlQjAlRTYlOUMlODAlRTUlQTQlOUElRTclOUElODQlRTYlQTglQTElRTUlOUUlOEIlRTYlOTglQUYlMjBmYWNlYm9vayUyRmVzbWZvbGRfdjElRUYlQkMlOEMlRTQlQjglOEIlRTglQkQlQkQlRTYlQUMlQTElRTYlOTUlQjAlRTQlQjglQkElMjAxMyUyQzEwOSUyQzg2MSUyMCVFNiVBQyVBMSVFMyU4MCU4Mg==",highlighted:'<span class="hljs-attribute">Facebook</span> 下载次数最多的模型是 facebook/esmfold_v1，下载次数为 <span class="hljs-number">13</span>,<span class="hljs-number">109</span>,<span class="hljs-number">861</span> 次。',wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1w2r872"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(l,J,p),T(l,n,p),m(U,l,p),s=!0},p:E,i(l){s||(w(a.$$.fragment,l),w(U.$$.fragment,l),s=!0)},o(l){h(a.$$.fragment,l),h(U.$$.fragment,l),s=!1},d(l){l&&(M(e),M(J),M(n)),u(a,l),u(U,l)}}}function as(d){let a,e,J,j,n,U;return a=new R({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[ss]},$$scope:{ctx:d}}}),J=new R({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[ts]},$$scope:{ctx:d}}}),n=new R({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[Js]},$$scope:{ctx:d}}}),{c(){r(a.$$.fragment),e=c(),r(J.$$.fragment),j=c(),r(n.$$.fragment)},l(s){y(a.$$.fragment,s),e=i(s),y(J.$$.fragment,s),j=i(s),y(n.$$.fragment,s)},m(s,l){m(a,s,l),T(s,e,l),m(J,s,l),T(s,j,l),m(n,s,l),U=!0},p(s,l){const p={};l&2&&(p.$$scope={dirty:l,ctx:s}),a.$set(p);const C={};l&2&&(C.$$scope={dirty:l,ctx:s}),J.$set(C);const g={};l&2&&(g.$$scope={dirty:l,ctx:s}),n.$set(g)},i(s){U||(w(a.$$.fragment,s),w(J.$$.fragment,s),w(n.$$.fragment,s),U=!0)},o(s){h(a.$$.fragment,s),h(J.$$.fragment,s),h(n.$$.fragment,s),U=!1},d(s){s&&(M(e),M(j)),u(a,s),u(J,s),u(n,s)}}}function Us(d){let a,e,J,j="预期输出:",n,U,s;return a=new f({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiUyMEh1Z2dpbmclMjBGYWNlJTIwJUU2JUE4JUExJUU1JTlFJThCJTBBbW9kZWwlMjAlM0QlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCgpJTBBJTBBJTIzJTIwJUU0JUJEJUJGJUU3JTk0JUE4JUU2JTg5JTgwJUU2JTlDJTg5JUU1JUI3JUE1JUU1JTg1JUI3JUU1JTg4JTlCJUU1JUJCJUJBJTIwQWxmcmVkJTBBYWxmcmVkJTIwJTNEJTIwQ29kZUFnZW50KCUwQSUyMCUyMCUyMCUyMHRvb2xzJTNEJTVCc2VhcmNoX3Rvb2wlMkMlMjB3ZWF0aGVyX2luZm9fdG9vbCUyQyUyMGh1Yl9zdGF0c190b29sJTVEJTJDJTIwJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUwQSklMEElMEElMjMlMjBBbGZyZWQlMjAlRTUlOUMlQTglRTUlQkElODYlRTUlODUlQjglRTYlOUMlOUYlRTklOTclQjQlRTUlOEYlQUYlRTglODMlQkQlRTQlQkMlOUElRTYlOTQlQjYlRTUlODglQjAlRTclOUElODQlRTclQTQlQkElRTQlQkUlOEIlRTYlOUYlQTUlRTglQUYlQTIlMEFyZXNwb25zZSUyMCUzRCUyMGFsZnJlZC5ydW4oJTIyV2hhdCUyMGlzJTIwRmFjZWJvb2slMjBhbmQlMjB3aGF0J3MlMjB0aGVpciUyMG1vc3QlMjBwb3B1bGFyJTIwbW9kZWwlM0YlMjIpJTBBJTBBcHJpbnQoJTIyJUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUyMiklMEFwcmludChyZXNwb25zZSk=",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=[search_tool, weather_info_tool, hub_stats_tool], 
    model=model
)

<span class="hljs-comment"># Alfred 在庆典期间可能会收到的示例查询</span>
response = alfred.run(<span class="hljs-string">&quot;What is Facebook and what&#x27;s their most popular model?&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}}),U=new f({props:{code:"JUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUwQUZhY2Vib29rJTIwJUU2JTk4JUFGJUU0JUI4JTgwJUU0JUI4JUFBJUU3JUE0JUJFJUU0JUJBJUE0JUU3JUJEJTkxJUU3JUFCJTk5JUVGJUJDJThDJUU3JTk0JUE4JUU2JTg4JUI3JUU1JThGJUFGJUU0JUJCJUE1JUU1JTlDJUE4JUU4JUJGJTk5JUU5JTg3JThDJUU0JUJBJTkyJUU3JTlCJUI4JUU4JTgxJTk0JUU3JUIzJUJCJUUzJTgwJTgxJUU1JTg4JTg2JUU0JUJBJUFCJUU0JUJGJUExJUU2JTgxJUFGJUU1JUI5JUI2JUU0JUJBJTkyJUU1JThBJUE4JUUzJTgwJTgyRmFjZWJvb2slMjAlRTUlOUMlQTglMjBIdWdnaW5nJTIwRmFjZSUyMEh1YiUyMCVFNCVCOCU4QSVFNCVCOCU4QiVFOCVCRCVCRCVFNiVBQyVBMSVFNiU5NSVCMCVFNiU5QyU4MCVFNSVBNCU5QSVFNyU5QSU4NCVFNiVBOCVBMSVFNSU5RSU4QiVFNiU5OCVBRiUyMEVTTUZvbGRfdjElRTMlODAlODI=",highlighted:`🎩 Alfred<span class="hljs-symbol">&#x27;s</span> Response:
Facebook 是一个社交网站，用户可以在这里互相联系、分享信息并互动。Facebook 在 Hugging Face Hub 上下载次数最多的模型是 ESMFold_v1。`,wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1uwcr0q"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(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zJUJEJUU0JUJDJTlBJUU2JTk0JUI2JUU1JTg4JUIwJUU3JTlBJTg0JUU3JUE0JUJBJUU0JUJFJThCJUU2JTlGJUE1JUU4JUFGJUEyJTBBcmVzcG9uc2UlMjAlM0QlMjBhd2FpdCUyMGFsZnJlZC5ydW4oJTIyV2hhdCUyMGlzJTIwRmFjZWJvb2slMjBhbmQlMjB3aGF0J3MlMjB0aGVpciUyMG1vc3QlMjBwb3B1bGFyJTIwbW9kZWwlM0YlMjIpJTBBJTBBcHJpbnQoJTIyJUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUyMiklMEFwcmludChyZXNwb25zZSk=",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(
    [search_tool, weather_info_tool, hub_stats_tool],
    llm=llm
)

<span class="hljs-comment"># Alfred 在庆典期间可能会收到的示例查询</span>
response = <span class="hljs-keyword">await</span> alfred.run(<span class="hljs-string">&quot;What is Facebook and what&#x27;s their most popular model?&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}}),U=new f({props:{code:"JUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUwQUZhY2Vib29rJTIwJUU2JTk4JUFGJUU0JUI4JTgwJUU1JUFFJUI2JUU2JTgwJUJCJUU5JTgzJUE4JUU0JUJEJThEJUU0JUJBJThFJUU1JThBJUEwJUU1JT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NiU5OCVBRiVFMiU4MCU5Q2ZhY2Vib29rJTJGZXNtZm9sZF92MSVFMiU4MCU5RCVFRiVCQyU4QyVFNCVCOCU4QiVFOCVCRCVCRCVFOSU4NyU4RiVFOCVCRSVCRSUyMDEzJTJDMTA5JTJDODYxJTIwJUU2JUFDJUExJUUzJTgwJTgy",highlighted:`🎩 Alfred<span class="hljs-symbol">&#x27;s</span> Response:
Facebook 是一家总部位于加利福尼亚州门洛帕克的社交网络服务和科技公司。它由马克·扎克伯格创立，允许用户创建个人资料、与亲朋好友联系、分享照片和视频，以及加入基于共同兴趣的群组。Facebook 在 Hugging Face Hub 上最受欢迎的模型是“facebook/esmfold_v1”，下载量达 <span class="hljs-number">13</span>,<span class="hljs-number">109</span>,<span class="hljs-number">861</span> 次。`,wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1uwcr0q"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(l,J,p),T(l,n,p),m(U,l,p),s=!0},p:E,i(l){s||(w(a.$$.fragment,l),w(U.$$.fragment,l),s=!0)},o(l){h(a.$$.fragment,l),h(U.$$.fragment,l),s=!1},d(l){l&&(M(e),M(J),M(n)),u(a,l),u(U,l)}}}function es(d){let a,e,J,j="预期输出:",n,U,s;return a=new f({props:{code:"ZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyMFR5cGVkRGljdCUyQyUyMEFubm90YXRlZCUwQWZyb20lMjBsYW5nZ3JhcGguZ3JhcGgubWVzc2FnZSUyMGltcG9ydCUyMGFkZF9tZXNzYWdlcyUwQWZyb20lMjBsYW5nY2hhaW5fY29yZS5tZXNzYWdlcyUyMGltcG9ydCUyMEFueU1lc3NhZ2UlMkMlMjBIdW1hbk1lc3NhZ2UlMkMlMjBBSU1lc3NhZ2UlMEFmcm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JUU0JUJEJTk1JUU3JUE3JUJCJUU1JThBJUE4JTBBYnVpbGRlci5hZGRfZWRnZShTVEFSVCUyQyUyMCUyMmFzc2lzdGFudCUyMiklMEFidWlsZGVyLmFkZF9jb25kaXRpb25hbF9lZGdlcyglMEElMjAlMjAlMjAlMjAlMjJhc3Npc3RhbnQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjMlMjBJZiUyMHRoZSUyMGxhdGVzdCUyMG1lc3NhZ2UlMjByZXF1aXJlcyUyMGElMjB0b29sJTJDJTIwcm91dGUlMjB0byUyMHRvb2xzJTBBJTIwJTIwJTIwJTIwJTIzJTIwT3RoZXJ3aXNlJTJDJTIwcHJvdmlkZSUyMGElMjBkaXJlY3QlMjByZXNwb25zZSUwQSUyMCUyMCUyMCUyMHRvb2xzX2NvbmRpdGlvbiUyQyUwQSklMEFidWlsZGVyLmFkZF9lZGdlKCUyMnRvb2xzJTIyJTJDJTIwJTIyYXNzaXN0YW50JTIyKSUwQWFsZnJlZCUyMCUzRCUyMGJ1aWxkZXIuY29tcGlsZSgpJTBBJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUJIdW1hbk1lc3NhZ2UoY29udGVudCUzRCUyMldobyUyMGlzJTIwRmFjZWJvb2slMjBhbmQlMjB3aGF0J3MlMjB0aGVpciUyMG1vc3QlMjBwb3B1bGFyJTIwbW9kZWwlM0YlMjIpJTVEJTBBcmVzcG9uc2UlMjAlM0QlMjBhbGZyZWQuaW52b2tlKCU3QiUyMm1lc3NhZ2VzJTIyJTNBJTIwbWVzc2FnZXMlN0QpJTBBJTBBcHJpbnQoJTIyJUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUyMiklMEFwcmludChyZXNwb25zZSU1QidtZXNzYWdlcyclNUQlNUItMSU1RC5jb250ZW50KQ==",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 = [search_tool, weather_info_tool, hub_stats_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;Who is Facebook and what&#x27;s their most popular model?&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}}),U=new f({props:{code:"JUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUwQUZhY2Vib29rJTIwJUU2JTk4JUFGJUU0JUI4JTgwJUU1JUFFJUI2JUU3JUE0JUJFJUU0JUJBJUE0JUU1JUFBJTkyJUU0JUJEJTkzJUU1JTg1JUFDJUU1JThGJUI4JUVGJUJDJThDJUU0JUJCJUE1JUU1JTg1JUI2JUU3JUE0JUJFJUU0JUJBJUE0JUU3JUJEJTkxJUU3JUFCJTk5JTIwRmFjZWJvb2slMjAlRTQlQkIlQTUlRTUlOEYlOEElMjBJbnN0YWdyYW0lMjAlRTUlOTIlOEMlMjBXaGF0c0FwcCUyMCVFNyVBRCU4OSVFNSU4NSVCNiVFNCVCQiU5NiVFNiU5QyU4RCVFNSU4QSVBMSVFOCU4MCU4QyVFOSU5NyVCQiVFNSU5MCU4RCVFMyU4MCU4MkZhY2Vib29rJTIwJUU1JTlDJUE4JTIwSHVnZ2luZyUyMEZhY2UlMjBIdWIlMjAlRTQlQjglOEElRTQlQjglOEIlRTglQkQlQkQlRTYlQUMlQTElRTYlOTUlQjAlRTYlOUMlODAlRTUlQTQlOUElRTclOUElODQlRTYlQTglQTElRTUlOUUlOEIlRTYlOTglQUYlMjBmYWNlYm9vayUyRmVzbWZvbGRfdjElRUYlQkMlOEMlRTQlQjglOEIlRTglQkQlQkQlRTklODclOEYlRTglQkUlQkUlMjAxMyUyQzIwMiUyQzMyMSUyMCVFNiVBQyVBMSVFMyU4MCU4Mg==",highlighted:`🎩 Alfred<span class="hljs-symbol">&#x27;s</span> Response:
Facebook 是一家社交媒体公司，以其社交网站 Facebook 以及 Instagram 和 WhatsApp 等其他服务而闻名。Facebook 在 Hugging Face Hub 上下载次数最多的模型是 facebook/esmfold_v1，下载量达 <span class="hljs-number">13</span>,<span class="hljs-number">202</span>,<span class="hljs-number">321</span> 次。`,wrap:!1}}),{c(){r(a.$$.fragment),e=c(),J=I("p"),J.textContent=j,n=c(),r(U.$$.fragment)},l(l){y(a.$$.fragment,l),e=i(l),J=b(l,"P",{"data-svelte-h":!0}),Q(J)!=="svelte-1w2r872"&&(J.textContent=j),n=i(l),y(U.$$.fragment,l)},m(l,p){m(a,l,p),T(l,e,p),T(l,J,p),T(l,n,p),m(U,l,p),s=!0},p:E,i(l){s||(w(a.$$.fragment,l),w(U.$$.fragment,l),s=!0)},o(l){h(a.$$.fragment,l),h(U.$$.fragment,l),s=!1},d(l){l&&(M(e),M(J),M(n)),u(a,l),u(U,l)}}}function Ms(d){let a,e,J,j,n,U;return a=new R({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[Us]},$$scope:{ctx:d}}}),J=new R({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[ns]},$$scope:{ctx:d}}}),n=new R({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[es]},$$scope:{ctx:d}}}),{c(){r(a.$$.fragment),e=c(),r(J.$$.fragment),j=c(),r(n.$$.fragment)},l(s){y(a.$$.fragment,s),e=i(s),y(J.$$.fragment,s),j=i(s),y(n.$$.fragment,s)},m(s,l){m(a,s,l),T(s,e,l),m(J,s,l),T(s,j,l),m(n,s,l),U=!0},p(s,l){const p={};l&2&&(p.$$scope={dirty:l,ctx:s}),a.$set(p);const C={};l&2&&(C.$$scope={dirty:l,ctx:s}),J.$set(C);const g={};l&2&&(g.$$scope={dirty:l,ctx:s}),n.$set(g)},i(s){U||(w(a.$$.fragment,s),w(J.$$.fragment,s),w(n.$$.fragment,s),U=!0)},o(s){h(a.$$.fragment,s),h(J.$$.fragment,s),h(n.$$.fragment,s),U=!1},d(s){s&&(M(e),M(j)),u(a,s),u(J,s),u(n,s)}}}function Ts(d){let a,e,J,j,n,U,s,l,p,C=`节将为 Alfred 赋予网络访问能力，使其能够获取实时新闻与全球资讯。
同时还将集成天气数据和 Hugging Face Hub 模型下载统计功能，帮助其进行时效性话题交流。`,g,Z,P,F,bl="请记住，我们希望 Alfred 能够展现出一位真正的文艺复兴主持人的风采，并对世界有着深刻的了解。",ll,N,Ql="为此，我们需要确保 Alfred 能够获取有关世界的最新新闻和信息。",sl,Y,fl="让我们从为 Alfred 创建一个网络搜索工具开始吧！",tl,B,Jl,S,al,W,gl="完美的庆典应该在晴朗的天空下燃放烟花，我们需要确保烟花不会因为恶劣天气而取消。",Ul,O,Cl="让我们创建一个自定义工具，用于调用外部天气 API 并获取指定位置的天气信息。",nl,k,Rl='<p>为了简单起见，我们在本例中使用了一个虚拟的天气 API。如果您想使用真实的天气 API，您可以实现一个使用 OpenWeatherMap API 的天气工具，就像<a href="../../unit1/tutorial">Unit 1</a>中提到的那样。</p>',el,A,Ml,_,Tl,v,El="出席此次盛会的都是 AI 开发者的精英。Alfred 希望通过讨论他们最受欢迎的模型、数据集和空间来给他们留下深刻印象。我们将创建一个工具，根据用户名从 Hugging Face Hub 获取模型统计数据。",pl,$,ol,X,Bl="借助 Hub Stats 工具，Alfred 现在可以通过讨论他们最受欢迎的模型来打动有影响力的 AI 开发者。",jl,x,cl,z,kl="现在我们已经拥有了所有工具，让我们将它们集成到 Alfred 的智能体中：",il,V,rl,q,yl,H,Al="通过集成这些工具，Alfred 现在可以处理各种任务，从网页搜索到天气更新和模型统计。这确保他始终是晚会上最了解情况、最有魅力的主持人。",ml,G,$l="<p>尝试实现一个可用于获取特定主题最新消息的工具。</p> <p>完成后，在 <code>tools.py</code> 文件中实现您的自定义工具。</p>",wl,D,hl,L,ul;return n=new Xl({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),s=new K({props:{title:"构建并集成智能体工具",local:"构建并集成智能体工具",headingTag:"h1"}}),Z=new K({props:{title:"赋予智能体网络访问能力",local:"赋予智能体网络访问能力",headingTag:"h2"}}),B=new Il({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[Dl]},$$scope:{ctx:d}}}),S=new K({props:{title:"创建天气信息工具（烟花调度）",local:"创建天气信息工具烟花调度",headingTag:"h2"}}),A=new Il({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[ls]},$$scope:{ctx:d}}}),_=new K({props:{title:"为有影响力的 AI 开发者创建 Hub 统计工具",local:"为有影响力的-ai-开发者创建-hub-统计工具",headingTag:"h2"}}),$=new Il({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[as]},$$scope:{ctx:d}}}),x=new K({props:{title:"将工具与 Alfred 集成",local:"将工具与-alfred-集成",headingTag:"h2"}}),V=new Il({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[Ms]},$$scope:{ctx:d}}}),q=new K({props:{title:"结论",local:"结论",headingTag:"h2"}}),D=new xl({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit3/agentic-rag/tools.mdx"}}),{c(){a=I("meta"),e=c(),J=I("p"),j=c(),r(n.$$.fragment),U=c(),r(s.$$.fragment),l=c(),p=I("p"),p.textContent=C,g=c(),r(Z.$$.fragment),P=c(),F=I("p"),F.textContent=bl,ll=c(),N=I("p"),N.textContent=Ql,sl=c(),Y=I("p"),Y.textContent=fl,tl=c(),r(B.$$.fragment),Jl=c(),r(S.$$.fragment),al=c(),W=I("p"),W.textContent=gl,Ul=c(),O=I("p"),O.textContent=Cl,nl=c(),k=I("blockquote"),k.innerHTML=Rl,el=c(),r(A.$$.fragment),Ml=c(),r(_.$$.fragment),Tl=c(),v=I("p"),v.textContent=El,pl=c(),r($.$$.fragment),ol=c(),X=I("p"),X.textContent=Bl,jl=c(),r(x.$$.fragment),cl=c(),z=I("p"),z.textContent=kl,il=c(),r(V.$$.fragment),rl=c(),r(q.$$.fragment),yl=c(),H=I("p"),H.textContent=Al,ml=c(),G=I("blockquote"),G.innerHTML=$l,wl=c(),r(D.$$.fragment),hl=c(),L=I("p"),this.h()},l(t){const o=_l("svelte-u9bgzb",document.head);a=b(o,"META",{name:!0,content:!0}),o.forEach(M),e=i(t),J=b(t,"P",{}),Nl(J).forEach(M),j=i(t),y(n.$$.fragment,t),U=i(t),y(s.$$.fragment,t),l=i(t),p=b(t,"P",{"data-svelte-h":!0}),Q(p)!=="svelte-1nkflu3"&&(p.textContent=C),g=i(t),y(Z.$$.fragment,t),P=i(t),F=b(t,"P",{"data-svelte-h":!0}),Q(F)!=="svelte-1kj3kiq"&&(F.textContent=bl),ll=i(t),N=b(t,"P",{"data-svelte-h":!0}),Q(N)!=="svelte-ymlpr"&&(N.textContent=Ql),sl=i(t),Y=b(t,"P",{"data-svelte-h":!0}),Q(Y)!=="svelte-6e7otf"&&(Y.textContent=fl),tl=i(t),y(B.$$.fragment,t),Jl=i(t),y(S.$$.fragment,t),al=i(t),W=b(t,"P",{"data-svelte-h":!0}),Q(W)!=="svelte-13ixisj"&&(W.textContent=gl),Ul=i(t),O=b(t,"P",{"data-svelte-h":!0}),Q(O)!=="svelte-1849wv6"&&(O.textContent=Cl),nl=i(t),k=b(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),Q(k)!=="svelte-nbgfmt"&&(k.innerHTML=Rl),el=i(t),y(A.$$.fragment,t),Ml=i(t),y(_.$$.fragment,t),Tl=i(t),v=b(t,"P",{"data-svelte-h":!0}),Q(v)!=="svelte-fst0pw"&&(v.textContent=El),pl=i(t),y($.$$.fragment,t),ol=i(t),X=b(t,"P",{"data-svelte-h":!0}),Q(X)!=="svelte-1p4zbyi"&&(X.textContent=Bl),jl=i(t),y(x.$$.fragment,t),cl=i(t),z=b(t,"P",{"data-svelte-h":!0}),Q(z)!=="svelte-11f3253"&&(z.textContent=kl),il=i(t),y(V.$$.fragment,t),rl=i(t),y(q.$$.fragment,t),yl=i(t),H=b(t,"P",{"data-svelte-h":!0}),Q(H)!=="svelte-5llu0c"&&(H.textContent=Al),ml=i(t),G=b(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),Q(G)!=="svelte-ayi50n"&&(G.innerHTML=$l),wl=i(t),y(D.$$.fragment,t),hl=i(t),L=b(t,"P",{}),Nl(L).forEach(M),this.h()},h(){dl(a,"name","hf:doc:metadata"),dl(a,"content",ps),dl(k,"class","tip"),dl(G,"class","tip")},m(t,o){vl(document.head,a),T(t,e,o),T(t,J,o),T(t,j,o),m(n,t,o),T(t,U,o),m(s,t,o),T(t,l,o),T(t,p,o),T(t,g,o),m(Z,t,o),T(t,P,o),T(t,F,o),T(t,ll,o),T(t,N,o),T(t,sl,o),T(t,Y,o),T(t,tl,o),m(B,t,o),T(t,Jl,o),m(S,t,o),T(t,al,o),T(t,W,o),T(t,Ul,o),T(t,O,o),T(t,nl,o),T(t,k,o),T(t,el,o),m(A,t,o),T(t,Ml,o),m(_,t,o),T(t,Tl,o),T(t,v,o),T(t,pl,o),m($,t,o),T(t,ol,o),T(t,X,o),T(t,jl,o),m(x,t,o),T(t,cl,o),T(t,z,o),T(t,il,o),m(V,t,o),T(t,rl,o),m(q,t,o),T(t,yl,o),T(t,H,o),T(t,ml,o),T(t,G,o),T(t,wl,o),m(D,t,o),T(t,hl,o),T(t,L,o),ul=!0},p(t,[o]){const Vl={};o&2&&(Vl.$$scope={dirty:o,ctx:t}),B.$set(Vl);const Gl={};o&2&&(Gl.$$scope={dirty:o,ctx:t}),A.$set(Gl);const Zl={};o&2&&(Zl.$$scope={dirty:o,ctx:t}),$.$set(Zl);const Fl={};o&2&&(Fl.$$scope={dirty:o,ctx:t}),V.$set(Fl)},i(t){ul||(w(n.$$.fragment,t),w(s.$$.fragment,t),w(Z.$$.fragment,t),w(B.$$.fragment,t),w(S.$$.fragment,t),w(A.$$.fragment,t),w(_.$$.fragment,t),w($.$$.fragment,t),w(x.$$.fragment,t),w(V.$$.fragment,t),w(q.$$.fragment,t),w(D.$$.fragment,t),ul=!0)},o(t){h(n.$$.fragment,t),h(s.$$.fragment,t),h(Z.$$.fragment,t),h(B.$$.fragment,t),h(S.$$.fragment,t),h(A.$$.fragment,t),h(_.$$.fragment,t),h($.$$.fragment,t),h(x.$$.fragment,t),h(V.$$.fragment,t),h(q.$$.fragment,t),h(D.$$.fragment,t),ul=!1},d(t){t&&(M(e),M(J),M(j),M(U),M(l),M(p),M(g),M(P),M(F),M(ll),M(N),M(sl),M(Y),M(tl),M(Jl),M(al),M(W),M(Ul),M(O),M(nl),M(k),M(el),M(Ml),M(Tl),M(v),M(pl),M(ol),M(X),M(jl),M(cl),M(z),M(il),M(rl),M(yl),M(H),M(ml),M(G),M(wl),M(hl),M(L)),M(a),u(n,t),u(s,t),u(Z,t),u(B,t),u(S,t),u(A,t),u(_,t),u($,t),u(x,t),u(V,t),u(q,t),u(D,t)}}}const ps='{"title":"构建并集成智能体工具","local":"构建并集成智能体工具","sections":[{"title":"赋予智能体网络访问能力","local":"赋予智能体网络访问能力","sections":[],"depth":2},{"title":"创建天气信息工具（烟花调度）","local":"创建天气信息工具烟花调度","sections":[],"depth":2},{"title":"为有影响力的 AI 开发者创建 Hub 统计工具","local":"为有影响力的-ai-开发者创建-hub-统计工具","sections":[],"depth":2},{"title":"将工具与 Alfred 集成","local":"将工具与-alfred-集成","sections":[],"depth":2},{"title":"结论","local":"结论","sections":[],"depth":2}],"depth":1}';function os(d){return Sl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ws extends Wl{constructor(a){super(),Ol(this,a,os,Ts,Yl,{})}}export{ws as component};
