import{s as Wl,o as Sl,n as R}from"../chunks/scheduler.37c15a92.js";import{S as _l,i as Ol,g as I,s as c,r,A as vl,h as b,f as M,c as i,j as Nl,u as y,x as f,k as ul,y as Xl,a as T,v as m,d as w,t as h,w as u,m as dl,n as Il}from"../chunks/index.2bf4358c.js";import{T as Yl}from"../chunks/Tip.363c041f.js";import{C as Q}from"../chunks/CodeBlock.4e987730.js";import{H as D}from"../chunks/Heading.8ada512a.js";import{H as hl,a as E}from"../chunks/HfOption.02c8e375.js";import{E as xl}from"../chunks/getInferenceSnippets.54ddb825.js";function zl(d){let t,U,a,p="预期输出:",n,e,s;return t=new Q({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}}),e=new Q({props:{code:"JUU2JUIzJTk1JUU1JTlCJUJEJUU3JThFJUIwJUU0JUJCJUJCJUU2JTgwJUJCJUU3JUJCJTlGJUU0JUI4JUJBJTIwRW1tYW51ZWwlMjBNYWNyb24lRTMlODAlODI=",highlighted:"法国现任总统为 Emmanuel Macron。",wrap:!1}}),{c(){r(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1w2r872"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i(l){s||(w(t.$$.fragment,l),w(e.$$.fragment,l),s=!0)},o(l){h(t.$$.fragment,l),h(e.$$.fragment,l),s=!1},d(l){l&&(M(U),M(a),M(n)),u(t,l),u(e,l)}}}function ql(d){let t,U,a,p="预期输出:",n,e,s;return t=new Q({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}}),e=new Q({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(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1w2r872"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i(l){s||(w(t.$$.fragment,l),w(e.$$.fragment,l),s=!0)},o(l){h(t.$$.fragment,l),h(e.$$.fragment,l),s=!1},d(l){l&&(M(U),M(a),M(n)),u(t,l),u(e,l)}}}function Hl(d){let t,U,a,p="预期输出:",n,e,s;return t=new Q({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}}),e=new Q({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(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1w2r872"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i(l){s||(w(t.$$.fragment,l),w(e.$$.fragment,l),s=!0)},o(l){h(t.$$.fragment,l),h(e.$$.fragment,l),s=!1},d(l){l&&(M(U),M(a),M(n)),u(t,l),u(e,l)}}}function Dl(d){let t,U,a,p,n,e;return t=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[zl]},$$scope:{ctx:d}}}),a=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[ql]},$$scope:{ctx:d}}}),n=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[Hl]},$$scope:{ctx:d}}}),{c(){r(t.$$.fragment),U=c(),r(a.$$.fragment),p=c(),r(n.$$.fragment)},l(s){y(t.$$.fragment,s),U=i(s),y(a.$$.fragment,s),p=i(s),y(n.$$.fragment,s)},m(s,l){m(t,s,l),T(s,U,l),m(a,s,l),T(s,p,l),m(n,s,l),e=!0},p(s,l){const o={};l&2&&(o.$$scope={dirty:l,ctx:s}),t.$set(o);const g={};l&2&&(g.$$scope={dirty:l,ctx:s}),a.$set(g);const C={};l&2&&(C.$$scope={dirty:l,ctx:s}),n.$set(C)},i(s){e||(w(t.$$.fragment,s),w(a.$$.fragment,s),w(n.$$.fragment,s),e=!0)},o(s){h(t.$$.fragment,s),h(a.$$.fragment,s),h(n.$$.fragment,s),e=!1},d(s){s&&(M(U),M(p)),u(t,s),u(a,s),u(n,s)}}}function Kl(d){let t,U,a="Unit 1",p;return{c(){t=dl("为了简单起见，我们在本例中使用了一个虚拟的天气 API。如果您想使用真实的天气 API，您可以实现一个使用 OpenWeatherMap API 的天气工具，就像"),U=I("a"),U.textContent=a,p=dl("中提到的那样。"),this.h()},l(n){t=Il(n,"为了简单起见，我们在本例中使用了一个虚拟的天气 API。如果您想使用真实的天气 API，您可以实现一个使用 OpenWeatherMap API 的天气工具，就像"),U=b(n,"A",{href:!0,"data-svelte-h":!0}),f(U)!=="svelte-qu572p"&&(U.textContent=a),p=Il(n,"中提到的那样。"),this.h()},h(){ul(U,"href","../../unit1/tutorial")},m(n,e){T(n,t,e),T(n,U,e),T(n,p,e)},p:R,d(n){n&&(M(t),M(U),M(p))}}}function Pl(d){let t,U;return t=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBUb29sJTBBaW1wb3J0JTIwcmFuZG9tJT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yword">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(t.$$.fragment)},l(a){y(t.$$.fragment,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ODklRTYlOEIlQTklRTQlQjglODAlRTclQTclOEQlRTUlQTQlQTklRTYlQjAlOTQlRTclOEElQjYlRTUlODYlQjUlMEElMjAlMjAlMjAlMjBkYXRhJTIwJTNEJTIwcmFuZG9tLmNob2ljZSh3ZWF0aGVyX2NvbmRpdGlvbnMpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwZiUyMldlYXRoZXIlMjBpbiUyMCU3QmxvY2F0aW9uJTdEJTNBJTIwJTdCZGF0YSU1Qidjb25kaXRpb24nJTVEJTdEJTJDJTIwJTdCZGF0YSU1Qid0ZW1wX2MnJTVEJTdEJUMyJUIwQyUyMiUwQSUwQSUyMyUyMCVFNSU4OCU5RCVFNSVBNyU4QiVFNSU4QyU5NiVFNSVCNyVBNSVFNSU4NSVCNyUwQXdlYXRoZXJfaW5mb190b29sJTIwJTNEJTIwRnVuY3Rpb25Ub29sLmZyb21fZGVmYXVsdHMoZ2V0X3dlYXRoZXJfaW5mbyk=",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(t.$$.fragment)},l(a){y(t.$$.fragment,a)},m(a,p){m(t,a,p),U=!0},p:R,i(a){U||(w(t.$$.fragment,a),U=!0)},o(a){h(t.$$.fragment,a),U=!1},d(a){u(t,a)}}}function ls(d){let t,U;return t=new Q({props:{code:"ZnJvbSUyMGxhbmdjaGFpbi50b29scyUyMGltcG9ydCUyMFRvb2wlMEFpbXBvcnQlMjByYW5kb20lMEElMEFkZWYlMjBnZXRfd2VhdGhlcl9pbmZvKGxvY2F0aW9uJTNBJTIwc3RyKSUyMC0lM0UlMjBzdHIlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjJGZXRjaGVzJTIwZHVtbXklMjB3ZWF0aGVyJTIwaW5mb3JtYXRpb24lMjBmb3IlMjBhJTIwZ2l2ZW4lMjBsb2NhdGlvbi4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjAlMjMlMjAlRTglOTklOUElRTYlOEIlOUYlRTUlQTQlQTklRTYlQjAlOTQlRTYlOTUlQjAlRTYlOEQlQUUlMEElMjAlMjAlMjAlMjB3ZWF0aGVyX2NvbmRpdGlvbnMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJjb25kaXRpb24lMjIlM0ElMjAlMjJSYWlueSUyMiUyQyUyMCUyMnRlbXBfYyUyMiUzQSUyMDE1JTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTI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s-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(t.$$.fragment)},l(a){y(t.$$.fragment,a)},m(a,p){m(t,a,p),U=!0},p:R,i(a){U||(w(t.$$.fragment,a),U=!0)},o(a){h(t.$$.fragment,a),U=!1},d(a){u(t,a)}}}function ss(d){let t,U,a,p,n,e;return t=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[Pl]},$$scope:{ctx:d}}}),a=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[Ll]},$$scope:{ctx:d}}}),n=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[ls]},$$scope:{ctx:d}}}),{c(){r(t.$$.fragment),U=c(),r(a.$$.fragment),p=c(),r(n.$$.fragment)},l(s){y(t.$$.fragment,s),U=i(s),y(a.$$.fragment,s),p=i(s),y(n.$$.fragment,s)},m(s,l){m(t,s,l),T(s,U,l),m(a,s,l),T(s,p,l),m(n,s,l),e=!0},p(s,l){const o={};l&2&&(o.$$scope={dirty:l,ctx:s}),t.$set(o);const g={};l&2&&(g.$$scope={dirty:l,ctx:s}),a.$set(g);const C={};l&2&&(C.$$scope={dirty:l,ctx:s}),n.$set(C)},i(s){e||(w(t.$$.fragment,s),w(a.$$.fragment,s),w(n.$$.fragment,s),e=!0)},o(s){h(t.$$.fragment,s),h(a.$$.fragment,s),h(n.$$.fragment,s),e=!1},d(s){s&&(M(U),M(p)),u(t,s),u(a,s),u(n,s)}}}function ts(d){let t,U,a,p="预期输出:",n,e,s;return t=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBUb29sJTBBZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGxpc3RfbW9kZWxzJTBBJTBBY2xhc3MlMjBIdWJTdGF0c1Rvb2woVG9vbCklM0ElMEElMjAlMjAlMjAlMjBuYW1lJTIwJTNEJTIwJTIyaHViX3N0YXRzJTIyJTBBJTIwJTIwJTIwJTIwZGVzY3JpcHRpb24lMjAlM0QlMjAlMjJGZXRjaGVzJTIwdGhlJTIwbW9zdCUyMGRvd25sb2FkZWQlMjBtb2RlbCUyMGZyb20lMjBhJTIwc3BlY2lmaWMlMjBhdXRob3IlMjBvbiUyMHRoZSUyMEh1Z2dpbmclMjBGYWNlJTIwSHViLiUyMiUwQSUyMCUyMCUyMCUyMGlucHV0cyUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMC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EJTIwSHViU3RhdHNUb29sKCklMEElMEElMjMlMjAlRTclQTQlQkElRTQlQkUlOEIlRTclOTQlQTglRTYlQjMlOTUlMEFwcmludChodWJfc3RhdHNfdG9vbCglMjJmYWNlYm9vayUyMikpJTIwJTIzJTIwRXhhbXBsZSUzQSUyMEdldCUyMHRoZSUyMG1vc3QlMjBkb3dubG9hZGVkJTIwbW9kZWwlMjBieSUyMEZhY2Vib29r",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}}),e=new Q({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(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1w2r872"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i(l){s||(w(t.$$.fragment,l),w(e.$$.fragment,l),s=!0)},o(l){h(t.$$.f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jBtb2RlbCUyMGJ5JTIwRmFjZWJvb2s=",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}}),e=new Q({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(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1w2r872"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i(l){s||(w(t.$$.fragment,l),w(e.$$.fragment,l),s=!0)},o(l){h(t.$$.fragment,l),h(e.$$.fragment,l),s=!1},d(l){l&&(M(U),M(a),M(n)),u(t,l),u(e,l)}}}function as(d){let t,U,a,p="预期输出:",n,e,s;return t=new Q({props:{code:"ZnJvbSUyMGxhbmdjaGFpbi50b29scyUyMGltcG9ydCUyMFRvb2wlMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwbGlzdF9tb2RlbHMlMEElMEFkZWYlMjBnZXRfaHViX3N0YXRzKGF1dGhvciUzQSUyMHN0ciklMjAtJTNFJTIwc3RyJTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyRmV0Y2hlcyUyMHRoZSUyMG1vc3QlMjBkb3dubG9hZGVkJTIwbW9kZWwlMjBmcm9tJTI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yMGZvdW5kJTIwZm9yJTIwYXV0aG9yJTIwJTdCYXV0aG9yJTdELiUyMiUwQSUyMCUyMCUyMCUyMGV4Y2VwdCUyMEV4Y2VwdGlvbiUyMGFzJTIwZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMGYlMjJFcnJvciUyMGZldGNoaW5nJTIwbW9kZWxzJTIwZm9yJTIwJTdCYXV0aG9yJTdEJTNBJTIwJTdCc3RyKGUpJTdEJTIyJTBBJTBBJTIzJTIwJUU1JTg4JTlEJUU1JUE3JThCJUU1JThDJTk2JUU1JUI3JUE1JUU1JTg1JUI3JTBBaHViX3N0YXRzX3Rvb2wlMjAlM0QlMjBUb29sKCUwQSUyMCUyMCUyMCUyMG5hbWUlM0QlMjJnZXRfaHViX3N0YXRzJTIyJTJDJTBBJTIwJTIwJTIwJTIwZnVuYyUzRGdldF9odWJfc3RhdHMlMkMlMEElMjAlMjAlMjAlMjBkZXNjcmlwdGlvbiUzRCUyMkZldGNoZXMlMjB0aGUlMjBtb3N0JTIwZG93bmxvYWRlZCUyMG1vZGVsJTIwZnJvbSUyMGElMjBzcGVjaWZpYyUyMGF1dGhvciUyMG9uJTIwdGhlJTIwSHVnZ2luZyUyMEZhY2UlMjBIdWIuJTIyJTBBKSUwQSUwQSUyMyUyMCVFNyVBNCVCQSVFNCVCRSU4QiVFNyU5NCVBOCVFNiVCMyU5NSUwQXByaW50KGh1Yl9zdGF0c190b29sLmludm9rZSglMjJmYWNlYm9vayUyMikpJTIwJTIzJTIwRXhhbXBsZSUzQSUyMEdldCUyMHRoZSUyMG1vc3QlMjBkb3dubG9hZGVkJTIwbW9kZWwlMjBieSUyMEZhY2Vib29r",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}}),e=new Q({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(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1w2r872"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i(l){s||(w(t.$$.fragment,l),w(e.$$.fragment,l),s=!0)},o(l){h(t.$$.fragment,l),h(e.$$.fragment,l),s=!1},d(l){l&&(M(U),M(a),M(n)),u(t,l),u(e,l)}}}function Us(d){let t,U,a,p,n,e;return t=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[ts]},$$scope:{ctx:d}}}),a=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[Js]},$$scope:{ctx:d}}}),n=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[as]},$$scope:{ctx:d}}}),{c(){r(t.$$.fragment),U=c(),r(a.$$.fragment),p=c(),r(n.$$.fragment)},l(s){y(t.$$.fragment,s),U=i(s),y(a.$$.fragment,s),p=i(s),y(n.$$.fragment,s)},m(s,l){m(t,s,l),T(s,U,l),m(a,s,l),T(s,p,l),m(n,s,l),e=!0},p(s,l){const o={};l&2&&(o.$$scope={dirty:l,ctx:s}),t.$set(o);const g={};l&2&&(g.$$scope={dirty:l,ctx:s}),a.$set(g);const C={};l&2&&(C.$$scope={dirty:l,ctx:s}),n.$set(C)},i(s){e||(w(t.$$.fragment,s),w(a.$$.fragment,s),w(n.$$.fragment,s),e=!0)},o(s){h(t.$$.fragment,s),h(a.$$.fragment,s),h(n.$$.fragment,s),e=!1},d(s){s&&(M(U),M(p)),u(t,s),u(a,s),u(n,s)}}}function ns(d){let t,U,a,p="预期输出:",n,e,s;return t=new Q({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}}),e=new Q({props:{code:"JUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUwQUZhY2Vib29rJTIwJUU2JTk4JUFGJUU0JUI4JTgwJUU0JUI4JUFBJUU3JUE0JUJFJUU0JUJBJUE0JUU3JUJEJTkxJUU3JUFCJTk5JUVGJUJDJThDJUU3JTk0JUE4JUU2JTg4JUI3JUU1JThGJUFGJUU0JUJCJUE1JUU1JTlDJUE4JUU4JUJGJTk5JUU5JTg3JThDJUU0JUJBJTkyJUU3JTlCJUI4JUU4JTgxJTk0JUU3JUIzJUJCJUUzJTgwJTgxJUU1JTg4JTg2JUU0JUJBJUFCJUU0JUJGJUExJUU2JTgxJUFGJUU1JUI5JUI2JUU0JUJBJTkyJUU1JThBJUE4JUUzJTgwJTgyRmFjZWJvb2slMjAlRTUlOUMlQTglMjBIdWdnaW5nJTIwRmFjZSUyMEh1YiUyMCVFNCVCOCU4QSVFNCVCOCU4QiVFOCVCRCVCRCVFNiVBQyVBMSVFNiU5NSVCMCVFNiU5QyU4MCVFNSVBNCU5QSVFNyU5QSU4NCVFNiVBOCVBMSVFNSU5RSU4QiVFNiU5OCVBRiUyMEVTTUZvbGRfdjElRTMlODAlODI=",highlighted:`🎩 Alfred<span class="hljs-symbol">&#x27;s</span> Response:
Facebook 是一个社交网站，用户可以在这里互相联系、分享信息并互动。Facebook 在 Hugging Face Hub 上下载次数最多的模型是 ESMFold_v1。`,wrap:!1}}),{c(){r(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1uwcr0q"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i(l){s||(w(t.$$.fragment,l),w(e.$$.fragment,l),s=!0)},o(l){h(t.$$.fragment,l),h(e.$$.fragment,l),s=!1},d(l){l&&(M(U),M(a),M(n)),u(t,l),u(e,l)}}}function es(d){let t,U,a,p="预期输出:",n,e,s;return t=new Q({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmNvcmUuYWdlbnQud29ya2Zsb3clMjBpbXBvcnQlMjBBZ2VudFdvcmtmbG93JTBBZnJvbSUyMGxsYW1hX2luZGV4LmxsbXMuaHVnZ2luZ2ZhY2VfYXBpJTIwaW1wb3J0JTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUEklMEElMEElMjMlMjAlRTUlODglOUQlRTUlQTclOEIlRTUlOEMlOTYlMjBIdWdnaW5nJTIwRmFjZSUyMCVFNiVBOCVBMSVFNSU5RSU4QiUwQWxsbSUyMCUzRCUyMEh1Z2dpbmdGYWNlSW5mZXJlbmNlQVBJKG1vZGVsX25hbWUlM0QlMjJRd2VuJTJGUXdlbjIuNS1Db2Rlci0zMkItSW5zdHJ1Y3QlMjIpJTBBJTIzJTIwJUU0JUJEJUJGJUU3JTk0JUE4JUU2JTg5JTgwJUU2JTlDJTg5JUU1JUI3JUE1JUU1JTg1JUI3JUU1JTg4JTlCJUU1JUJCJUJBJTIwQWxmcmVkJTBBYWxmcmVkJTIwJTNEJTIwQWdlbnRXb3JrZmxvdy5mcm9tX3Rvb2xzX29yX2Z1bmN0aW9ucyglMEElMjAlMjAlMjAlMjAlNUJzZWFyY2hfdG9vbCUyQyUyMHdlYXRoZXJfaW5mb190b29sJTJDJTIwaHViX3N0YXRzX3Rvb2wlNUQlMkMlMEElMjAlMjAlMjAlMjBsbG0lM0RsbG0lMEEpJTBBJTBBJTIzJTIwQWxmcmVkJTIwJUU1JTlDJUE4JUU1JUJBJTg2JUU1JTg1JUI4JUU2JTlDJTlGJUU5JTk3JUI0JUU1JThGJUFGJUU4JTgzJUJEJUU0JUJDJTlBJUU2JTk0JUI2JUU1JTg4JUIwJUU3JTlBJTg0JUU3JUE0JUJBJUU0JUJFJThCJUU2JTlGJUE1JUU4JUFGJUEyJTBBcmVzcG9uc2UlMjAlM0QlMjBhd2FpdCUyMGFsZnJlZC5ydW4oJTIyV2hhdCUyMGlzJTIwRmFjZWJvb2slMjBhbmQlMjB3aGF0J3MlMjB0aGVpciUyMG1vc3QlMjBwb3B1bGFyJTIwbW9kZWwlM0YlMjIpJTBBJTBBcHJpbnQoJTIyJUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUyMiklMEFwcmludChyZXNwb25zZSk=",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}}),e=new Q({props:{code:"JUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUwQUZhY2Vib29rJTIwJUU2JTk4JUFGJUU0JUI4JTgwJUU1JUFFJUI2JUU2JTgwJUJCJUU5JTgzJUE4JUU0JUJEJThEJUU0JUJBJThFJUU1JThBJUEwJUU1JTg4JUE5JUU3JUE2JThGJUU1JUIwJUJDJUU0JUJBJTlBJUU1JUI3JTlFJUU5JTk3JUE4JUU2JUI0JTlCJUU1JUI4JTk1JUU1JTg1JThCJUU3JTlBJTg0JUU3JUE0JUJFJUU0JUJBJUE0JUU3JUJEJTkxJUU3JUJCJTlDJUU2JTlDJThEJUU1JThBJUExJUU1JTkyJThDJUU3JUE3JTkxJUU2JThBJTgwJUU1JTg1JUFDJUU1JThGJUI4JUUzJTgwJTgyJUU1JUFFJTgzJUU3JTk0JUIxJUU5JUE5JUFDJUU1JTg1JThCJUMyJUI3JUU2JTg5JThFJUU1JTg1JThCJUU0JUJDJUFGJUU2JUEwJUJDJUU1JTg4JTlCJUU3JUFCJThCJUVGJUJDJThDJUU1JTg1JTgxJUU4JUFFJUI4JUU3JTk0JUE4JUU2JTg4JUI3JUU1JTg4JTlCJUU1JUJCJUJBJUU0JUI4JUFBJUU0JUJBJUJBJUU4JUI1JTg0JUU2JTk2JTk5JUUzJTgwJTgxJUU0JUI4JThFJUU0JUJBJUIyJUU2JTlDJThCJUU1JUE1JUJEJUU1JThGJThCJUU4JTgxJTk0JUU3JUIzJUJCJUUzJTgwJTgxJUU1JTg4JTg2JUU0JUJBJUFCJUU3JTg1JUE3JUU3JTg5JTg3JUU1JTkyJThDJUU4JUE3JTg2JUU5JUEyJTkxJUVGJUJDJThDJUU0JUJCJUE1JUU1JThGJThBJUU1JThBJUEwJUU1JTg1JUE1JUU1JTlGJUJBJUU0JUJBJThFJUU1JTg1JUIxJUU1JTkwJThDJUU1JTg1JUI0JUU4JUI2JUEzJUU3JTlBJTg0JUU3JUJFJUE0JUU3JUJCJTg0JUUzJTgwJTgyRmFjZWJvb2slMjAlRTUlOUMlQTglMjBIdWdnaW5nJTIwRmFjZSUyMEh1YiUyMCVFNCVCOCU4QSVFNiU5QyU4MCVFNSU4RiU5NyVFNiVBQyVBMiVFOCVCRiU4RSVFNyU5QSU4NCVFNiVBOCVBMSVFNSU5RSU4QiVFNiU5OCVBRiVFMiU4MCU5Q2ZhY2Vib29rJTJGZXNtZm9sZF92MSVFMiU4MCU5RCVFRiVCQyU4QyVFNCVCOCU4QiVFOCVCRCVCRCVFOSU4NyU4RiVFOCVCRSVCRSUyMDEzJTJDMTA5JTJDODYxJTIwJUU2JUFDJUExJUUzJTgwJTgy",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(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1uwcr0q"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i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ldobyUyMGlzJTIwRmFjZWJvb2slMjBhbmQlMjB3aGF0J3MlMjB0aGVpciUyMG1vc3QlMjBwb3B1bGFyJTIwbW9kZWwlM0YlMjIpJTVEJTBBcmVzcG9uc2UlMjAlM0QlMjBhbGZyZWQuaW52b2tlKCU3QiUyMm1lc3NhZ2VzJTIyJTNBJTIwbWVzc2FnZXMlN0QpJTBBJTBBcHJpbnQoJTIyJUYwJTlGJThFJUE5JTIwQWxmcmVkJ3MlMjBSZXNwb25zZSUzQSUyMiklMEFwcmludChyZXNwb25zZSU1QidtZXNzYWdlcyclNUQlNUItMSU1RC5jb250ZW50KQ==",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}}),e=new Q({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(t.$$.fragment),U=c(),a=I("p"),a.textContent=p,n=c(),r(e.$$.fragment)},l(l){y(t.$$.fragment,l),U=i(l),a=b(l,"P",{"data-svelte-h":!0}),f(a)!=="svelte-1w2r872"&&(a.textContent=p),n=i(l),y(e.$$.fragment,l)},m(l,o){m(t,l,o),T(l,U,o),T(l,a,o),T(l,n,o),m(e,l,o),s=!0},p:R,i(l){s||(w(t.$$.fragment,l),w(e.$$.fragment,l),s=!0)},o(l){h(t.$$.fragment,l),h(e.$$.fragment,l),s=!1},d(l){l&&(M(U),M(a),M(n)),u(t,l),u(e,l)}}}function Ts(d){let t,U,a,p,n,e;return t=new E({props:{id:"agents-frameworks",option:"smolagents",$$slots:{default:[ns]},$$scope:{ctx:d}}}),a=new E({props:{id:"agents-frameworks",option:"llama-index",$$slots:{default:[es]},$$scope:{ctx:d}}}),n=new E({props:{id:"agents-frameworks",option:"langgraph",$$slots:{default:[Ms]},$$scope:{ctx:d}}}),{c(){r(t.$$.fragment),U=c(),r(a.$$.fragment),p=c(),r(n.$$.fragment)},l(s){y(t.$$.fragment,s),U=i(s),y(a.$$.fragment,s),p=i(s),y(n.$$.fragment,s)},m(s,l){m(t,s,l),T(s,U,l),m(a,s,l),T(s,p,l),m(n,s,l),e=!0},p(s,l){const o={};l&2&&(o.$$scope={dirty:l,ctx:s}),t.$set(o);const g={};l&2&&(g.$$scope={dirty:l,ctx:s}),a.$set(g);const C={};l&2&&(C.$$scope={dirty:l,ctx:s}),n.$set(C)},i(s){e||(w(t.$$.fragment,s),w(a.$$.fragment,s),w(n.$$.fragment,s),e=!0)},o(s){h(t.$$.fragment,s),h(a.$$.fragment,s),h(n.$$.fragment,s),e=!1},d(s){s&&(M(U),M(p)),u(t,s),u(a,s),u(n,s)}}}function ps(d){let t,U,a="完成后，在 <code>tools.py</code> 文件中实现您的自定义工具。";return{c(){t=dl(`尝试实现一个可用于获取特定主题最新消息的工具。
`),U=I("p"),U.innerHTML=a},l(p){t=Il(p,`尝试实现一个可用于获取特定主题最新消息的工具。
`),U=b(p,"P",{"data-svelte-h":!0}),f(U)!=="svelte-vnbsoi"&&(U.innerHTML=a)},m(p,n){T(p,t,n),T(p,U,n)},p:R,d(p){p&&(M(t),M(U))}}}function os(d){let t,U,a,p,n,e,s,l=`节将为 Alfred 赋予网络访问能力，使其能够获取实时新闻与全球资讯。
同时还将集成天气数据和 Hugging Face Hub 模型下载统计功能，帮助其进行时效性话题交流。`,o,g,C,Z,bl="请记住，我们希望 Alfred 能够展现出一位真正的文艺复兴主持人的风采，并对世界有着深刻的了解。",P,F,fl="为此，我们需要确保 Alfred 能够获取有关世界的最新新闻和信息。",L,N,Ql="让我们从为 Alfred 创建一个网络搜索工具开始吧！",ll,B,sl,Y,tl,W,gl="完美的庆典应该在晴朗的天空下燃放烟花，我们需要确保烟花不会因为恶劣天气而取消。",Jl,S,Cl="让我们创建一个自定义工具，用于调用外部天气 API 并获取指定位置的天气信息。",al,A,Ul,k,nl,_,el,O,Rl="出席此次盛会的都是 AI 开发者的精英。Alfred 希望通过讨论他们最受欢迎的模型、数据集和空间来给他们留下深刻印象。我们将创建一个工具，根据用户名从 Hugging Face Hub 获取模型统计数据。",Ml,$,Tl,v,El="借助 Hub Stats 工具，Alfred 现在可以通过讨论他们最受欢迎的模型来打动有影响力的 AI 开发者。",pl,X,ol,x,Bl="现在我们已经拥有了所有工具，让我们将它们集成到 Alfred 的智能体中：",jl,V,cl,z,il,q,Al="通过集成这些工具，Alfred 现在可以处理各种任务，从网页搜索到天气更新和模型统计。这确保他始终是晚会上最了解情况、最有魅力的主持人。",rl,G,yl,H,ml,K,wl;return n=new D({props:{title:"构建并集成智能体工具",local:"构建并集成智能体工具",headingTag:"h1"}}),g=new D({props:{title:"赋予智能体网络访问能力",local:"赋予智能体网络访问能力",headingTag:"h2"}}),B=new hl({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[Dl]},$$scope:{ctx:d}}}),Y=new D({props:{title:"创建天气信息工具（烟花调度）",local:"创建天气信息工具烟花调度",headingTag:"h2"}}),A=new Yl({props:{$$slots:{default:[Kl]},$$scope:{ctx:d}}}),k=new hl({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[ss]},$$scope:{ctx:d}}}),_=new D({props:{title:"为有影响力的 AI 开发者创建 Hub 统计工具",local:"为有影响力的-ai-开发者创建-hub-统计工具",headingTag:"h2"}}),$=new hl({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[Us]},$$scope:{ctx:d}}}),X=new D({props:{title:"将工具与 Alfred 集成",local:"将工具与-alfred-集成",headingTag:"h2"}}),V=new hl({props:{id:"agents-frameworks",options:["smolagents","llama-index","langgraph"],$$slots:{default:[Ts]},$$scope:{ctx:d}}}),z=new D({props:{title:"结论",local:"结论",headingTag:"h2"}}),G=new Yl({props:{$$slots:{default:[ps]},$$scope:{ctx:d}}}),H=new xl({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit3/agentic-rag/tools.mdx"}}),{c(){t=I("meta"),U=c(),a=I("p"),p=c(),r(n.$$.fragment),e=c(),s=I("p"),s.textContent=l,o=c(),r(g.$$.fragment),C=c(),Z=I("p"),Z.textContent=bl,P=c(),F=I("p"),F.textContent=fl,L=c(),N=I("p"),N.textContent=Ql,ll=c(),r(B.$$.fragment),sl=c(),r(Y.$$.fragment),tl=c(),W=I("p"),W.textContent=gl,Jl=c(),S=I("p"),S.textContent=Cl,al=c(),r(A.$$.fragment),Ul=c(),r(k.$$.fragment),nl=c(),r(_.$$.fragment),el=c(),O=I("p"),O.textContent=Rl,Ml=c(),r($.$$.fragment),Tl=c(),v=I("p"),v.textContent=El,pl=c(),r(X.$$.fragment),ol=c(),x=I("p"),x.textContent=Bl,jl=c(),r(V.$$.fragment),cl=c(),r(z.$$.fragment),il=c(),q=I("p"),q.textContent=Al,rl=c(),r(G.$$.fragment),yl=c(),r(H.$$.fragment),ml=c(),K=I("p"),this.h()},l(J){const j=vl("svelte-u9bgzb",document.head);t=b(j,"META",{name:!0,content:!0}),j.forEach(M),U=i(J),a=b(J,"P",{}),Nl(a).forEach(M),p=i(J),y(n.$$.fragment,J),e=i(J),s=b(J,"P",{"data-svelte-h":!0}),f(s)!=="svelte-1nkflu3"&&(s.textContent=l),o=i(J),y(g.$$.fragment,J),C=i(J),Z=b(J,"P",{"data-svelte-h":!0}),f(Z)!=="svelte-1kj3kiq"&&(Z.textContent=bl),P=i(J),F=b(J,"P",{"data-svelte-h":!0}),f(F)!=="svelte-ymlpr"&&(F.textContent=fl),L=i(J),N=b(J,"P",{"data-svelte-h":!0}),f(N)!=="svelte-6e7otf"&&(N.textContent=Ql),ll=i(J),y(B.$$.fragment,J),sl=i(J),y(Y.$$.fragment,J),tl=i(J),W=b(J,"P",{"data-svelte-h":!0}),f(W)!=="svelte-13ixisj"&&(W.textContent=gl),Jl=i(J),S=b(J,"P",{"data-svelte-h":!0}),f(S)!=="svelte-1849wv6"&&(S.textContent=Cl),al=i(J),y(A.$$.fragment,J),Ul=i(J),y(k.$$.fragment,J),nl=i(J),y(_.$$.fragment,J),el=i(J),O=b(J,"P",{"data-svelte-h":!0}),f(O)!=="svelte-fst0pw"&&(O.textContent=Rl),Ml=i(J),y($.$$.fragment,J),Tl=i(J),v=b(J,"P",{"data-svelte-h":!0}),f(v)!=="svelte-1p4zbyi"&&(v.textContent=El),pl=i(J),y(X.$$.fragment,J),ol=i(J),x=b(J,"P",{"data-svelte-h":!0}),f(x)!=="svelte-11f3253"&&(x.textContent=Bl),jl=i(J),y(V.$$.fragment,J),cl=i(J),y(z.$$.fragment,J),il=i(J),q=b(J,"P",{"data-svelte-h":!0}),f(q)!=="svelte-5llu0c"&&(q.textContent=Al),rl=i(J),y(G.$$.fragment,J),yl=i(J),y(H.$$.fragment,J),ml=i(J),K=b(J,"P",{}),Nl(K).forEach(M),this.h()},h(){ul(t,"name","hf:doc:metadata"),ul(t,"content",js)},m(J,j){Xl(document.head,t),T(J,U,j),T(J,a,j),T(J,p,j),m(n,J,j),T(J,e,j),T(J,s,j),T(J,o,j),m(g,J,j),T(J,C,j),T(J,Z,j),T(J,P,j),T(J,F,j),T(J,L,j),T(J,N,j),T(J,ll,j),m(B,J,j),T(J,sl,j),m(Y,J,j),T(J,tl,j),T(J,W,j),T(J,Jl,j),T(J,S,j),T(J,al,j),m(A,J,j),T(J,Ul,j),m(k,J,j),T(J,nl,j),m(_,J,j),T(J,el,j),T(J,O,j),T(J,Ml,j),m($,J,j),T(J,Tl,j),T(J,v,j),T(J,pl,j),m(X,J,j),T(J,ol,j),T(J,x,j),T(J,jl,j),m(V,J,j),T(J,cl,j),m(z,J,j),T(J,il,j),T(J,q,j),T(J,rl,j),m(G,J,j),T(J,yl,j),m(H,J,j),T(J,ml,j),T(J,K,j),wl=!0},p(J,[j]){const kl={};j&2&&(kl.$$scope={dirty:j,ctx:J}),B.$set(kl);const $l={};j&2&&($l.$$scope={dirty:j,ctx:J}),A.$set($l);const Vl={};j&2&&(Vl.$$scope={dirty:j,ctx:J}),k.$set(Vl);const Gl={};j&2&&(Gl.$$scope={dirty:j,ctx:J}),$.$set(Gl);const Zl={};j&2&&(Zl.$$scope={dirty:j,ctx:J}),V.$set(Zl);const Fl={};j&2&&(Fl.$$scope={dirty:j,ctx:J}),G.$set(Fl)},i(J){wl||(w(n.$$.fragment,J),w(g.$$.fragment,J),w(B.$$.fragment,J),w(Y.$$.fragment,J),w(A.$$.fragment,J),w(k.$$.fragment,J),w(_.$$.fragment,J),w($.$$.fragment,J),w(X.$$.fragment,J),w(V.$$.fragment,J),w(z.$$.fragment,J),w(G.$$.fragment,J),w(H.$$.fragment,J),wl=!0)},o(J){h(n.$$.fragment,J),h(g.$$.fragment,J),h(B.$$.fragment,J),h(Y.$$.fragment,J),h(A.$$.fragment,J),h(k.$$.fragment,J),h(_.$$.fragment,J),h($.$$.fragment,J),h(X.$$.fragment,J),h(V.$$.fragment,J),h(z.$$.fragment,J),h(G.$$.fragment,J),h(H.$$.fragment,J),wl=!1},d(J){J&&(M(U),M(a),M(p),M(e),M(s),M(o),M(C),M(Z),M(P),M(F),M(L),M(N),M(ll),M(sl),M(tl),M(W),M(Jl),M(S),M(al),M(Ul),M(nl),M(el),M(O),M(Ml),M(Tl),M(v),M(pl),M(ol),M(x),M(jl),M(cl),M(il),M(q),M(rl),M(yl),M(ml),M(K)),M(t),u(n,J),u(g,J),u(B,J),u(Y,J),u(A,J),u(k,J),u(_,J),u($,J),u(X,J),u(V,J),u(z,J),u(G,J),u(H,J)}}}const js='{"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 cs(d){return Sl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ds extends _l{constructor(t){super(),Ol(this,t,cs,os,Wl,{})}}export{ds as component};
