import{s as As,f as Ft,o as Qs,n as Ws}from"../chunks/scheduler.889ebb13.js";import{S as Rs,i as Ss,g as M,s as J,r as y,A as Hs,h as n,f as t,c as U,j as Zt,u as i,x as T,k as I,y as xs,a as s,v as p,d as w,t as o,w as C,m as Kl,n as le}from"../chunks/index.ca18042b.js";import{T as Gt}from"../chunks/Tip.b8116e3c.js";import{C as j}from"../chunks/CodeBlock.a65374d4.js";import{C as _s}from"../chunks/CourseFloatingBanner.897040e9.js";import{H as h,E as Ys}from"../chunks/index.d845d0a2.js";function Xs(f){let r,a,m="smolagents 文档中的这个指南",u;return{c(){r=Kl("如果你想了解更多关于为什么代码智能体如此有效的信息，请查看 "),a=M("a"),a.textContent=m,u=Kl("。"),this.h()},l(c){r=le(c,"如果你想了解更多关于为什么代码智能体如此有效的信息，请查看 "),a=n(c,"A",{href:!0,target:!0,"data-svelte-h":!0}),T(a)!=="svelte-13q8t7h"&&(a.textContent=m),u=le(c,"。"),this.h()},h(){I(a,"href","https://huggingface.co/docs/smolagents/en/conceptual_guides/intro_agents#code-agents"),I(a,"target","_blank")},m(c,g){s(c,r,g),s(c,a,g),s(c,u,g)},p:Ws,d(c){c&&(t(r),t(a),t(u))}}}function zs(f){let r,a,m="这个笔记本",u;return{c(){r=Kl("你可以在 "),a=M("a"),a.textContent=m,u=Kl(" 中跟随代码，可以使用 Google Colab 运行。"),this.h()},l(c){r=le(c,"你可以在 "),a=n(c,"A",{href:!0,target:!0,"data-svelte-h":!0}),T(a)!=="svelte-1rjsp7d"&&(a.textContent=m),u=le(c," 中跟随代码，可以使用 Google Colab 运行。"),this.h()},h(){I(a,"href","https://huggingface.co/agents-course/notebooks/blob/main/unit2/smolagents/code_agents.ipynb"),I(a,"target","_blank")},m(c,g){s(c,r,g),s(c,a,g),s(c,u,g)},p:Ws,d(c){c&&(t(r),t(a),t(u))}}}function qs(f){let r;return{c(){r=Kl("如果你想分享你的智能体项目，请创建一个 space 并在 Hugging Face Hub 上标记 [agents-course](https://huggingface.co/agents-course)。我们很想看看你创造了什么！")},l(a){r=le(a,"如果你想分享你的智能体项目，请创建一个 space 并在 Hugging Face Hub 上标记 [agents-course](https://huggingface.co/agents-course)。我们很想看看你创造了什么！")},m(a,m){s(a,r,m)},d(a){a&&t(r)}}}function Ls(f){let r,a,m,u,c,g,k,ee,N,vt="代码智能体（Code agents）是 <code>smolagents</code> 中的默认智能体类型。它们生成 Python 工具调用来执行操作，实现高效、表达力强且准确的操作表示。",te,F,Et="它们的简化方法减少了所需操作的数量，简化了复杂操作，并实现了对现有代码函数的重用。<code>smolagents</code> 提供了一个轻量级框架，用约 1,000 行代码实现构建代码智能体（code agents）。",se,Z,$t=`<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/code_vs_json_actions.png" alt="代码与 JSON 操作对比"/>
图片来自论文 <a href="https://huggingface.co/papers/2402.01030" rel="nofollow">Executable Code Actions Elicit Better LLM Agents</a>`,Je,b,Ue,G,Me,v,Wt="在多步骤智能体过程中，大语言模型（LLM）编写并执行操作，通常涉及外部工具调用。传统方法使用 JSON 格式来指定工具名称和参数作为字符串，<strong>系统必须解析这些内容以确定要执行哪个工具</strong>。",ne,E,At='然而，研究表明，<strong>工具调用型大语言模型直接使用代码工作更有效</strong>。这是 <code>smolagents</code> 的核心原则，如上图所示，来自论文 <a href="https://huggingface.co/papers/2402.01030" rel="nofollow">Executable Code Actions Elicit Better LLM Agents</a>。',Te,$,Qt="用代码而非 JSON 编写操作提供了几个关键优势：",ae,W,Rt="<li><strong>可组合性（Composability）</strong>：轻松组合和重用操作</li> <li><strong>对象管理（Object Management）</strong>：直接处理复杂结构，如图像</li> <li><strong>通用性（Generality）</strong>：表达任何计算上可能的任务</li> <li><strong>适合大语言模型</strong>：高质量代码已存在于大语言模型的训练数据中</li>",ye,A,ie,Q,St='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/smolagents/codeagent_docs.png" alt="来自 https://huggingface.co/docs/smolagents/conceptual_guides/react"/>',pe,R,Ht="上图说明了 <code>CodeAgent.run()</code> 如何操作，遵循我们在第 1 单元中提到的 ReAct 框架。<code>smolagents</code> 中智能体的主要抽象是 <code>MultiStepAgent</code>，它作为核心构建块。如我们将在下面的示例中看到的，<code>CodeAgent</code> 是一种特殊的 <code>MultiStepAgent</code>。",we,S,xt="<code>CodeAgent</code> 通过一系列步骤执行操作，将现有变量和知识整合到智能体的上下文中，这些内容保存在执行日志中：",oe,H,_t='<li><p>系统提示存储在 <code>SystemPromptStep</code> 中，用户查询记录在 <code>TaskStep</code> 中。</p></li> <li><p>然后，执行以下循环：</p> <p>2.1 方法 <code>agent.write_memory_to_messages()</code> 将智能体的日志写入大语言模型可读的<a href="https://huggingface.co/docs/transformers/en/chat_templating" rel="nofollow">聊天消息</a>列表中。</p> <p>2.2 这些消息发送给 <code>Model</code>，生成补全（completion）。</p> <p>2.3 解析补全内容以提取操作，在我们的例子中，这应该是代码片段，因为我们使用的是 <code>CodeAgent</code>。</p> <p>2.4 执行该操作。</p> <p>2.5 将结果记录到内存中的 <code>ActionStep</code> 中。</p></li>',Ce,x,Yt="在每个步骤结束时，如果智能体包含任何函数调用（在 <code>agent.step_callback</code> 中），它们将被执行。",ce,_,re,V,Ie,Y,Xt="阿尔弗雷德（Alfred）正在韦恩家族大宅计划一场派对，需要你的帮助确保一切顺利进行。为了帮助他，我们将应用我们所学到的关于多步骤 <code>CodeAgent</code> 如何运作的知识。",ue,X,zt,me,z,qt="如果你还没有安装 <code>smolagents</code>，可以运行以下命令进行安装：",je,q,ge,L,Lt="让我们也登录到 Hugging Face Hub，以便访问无服务器推理 API（Serverless Inference API）。",de,P,he,O,fe,D,Pt="音乐是成功派对的重要组成部分！阿尔弗雷德需要一些帮助来选择播放列表。幸运的是，<code>smolagents</code> 能够帮助我们！我们可以构建一个能够使用 DuckDuckGo 搜索网络的智能体。要让智能体访问此工具，我们在创建智能体时将其包含在工具列表中。",be,K,Ot,Ve,ll,Dt='对于模型，我们将依赖 <code>HfApiModel</code>，它提供对 Hugging Face 的<a href="https://huggingface.co/docs/api-inference/index" rel="nofollow">无服务器推理 API</a>的访问。默认模型是 <code>&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</code>，它性能良好并可用于快速推理，但你可以从 Hub 中选择任何兼容的模型。',Be,el,Kt="运行智能体相当简单：",ke,tl,Ne,sl,ls="当你运行这个例子时，输出将<strong>显示正在执行的工作流步骤的跟踪</strong>。它还会打印相应的 Python 代码，并附带消息：",Fe,Jl,Ze,Ul,es="几个步骤后，你将看到阿尔弗雷德可以用于派对的生成播放列表！🎵",Ge,Ml,ve,nl,ts,Ee,Tl,ss="现在我们已经选择了播放列表，我们需要为客人组织菜单。同样，阿尔弗雷德可以利用 <code>smolagents</code> 来做到这一点。在这里，我们使用 <code>@tool</code> 装饰器定义一个作为工具的自定义函数。我们稍后将更详细地介绍工具创建，所以现在我们可以简单地运行代码。",$e,al,Js="如下例所示，我们将使用 <code>@tool</code> 装饰器创建一个工具，并将其包含在 <code>tools</code> 列表中。",We,yl,Ae,il,Us="智能体将运行几个步骤，直到找到答案。",Qe,pl,Ms="菜单准备好了！🥗",Re,wl,Se,ol,ns="我们已经准备好了播放列表和菜单，但我们需要检查另一个关键细节：准备时间！",He,Cl,Ts="阿尔弗雷德需要计算如果他现在开始准备，什么时候一切都会准备就绪，以防他们需要其他超级英雄的帮助。",xe,cl,as=`<code>smolagents</code> 专门用于编写和执行 Python 代码片段的智能体，为安全提供沙盒执行环境。<br/> <strong>代码执行有严格的安全措施</strong> - 默认情况下，预定义安全列表之外的导入被阻止。但是，您可以通过将它们作为字符串传递到 <code>additional_authorized_imports</code> 中来授权额外的导入。
有关安全代码执行的更多详情，请参阅官方<a href="https://huggingface.co/docs/smolagents/tutorials/secure_code_execution" rel="nofollow">指南</a>。`,_e,rl,ys="创建智能体时，我们将使用 <code>additional_authorized_imports</code> 来允许导入 <code>datetime</code> 模块。",Ye,Il,Xe,ul,is=`这些例子只是代码智能体能做的事情的开始，我们已经开始看到它们对准备派对的实用性。
你可以在 <a href="https://huggingface.co/docs/smolagents" rel="nofollow">smolagents 文档</a> 中了解更多关于如何构建代码智能体的信息。`,ze,ml,ps="总之，<code>smolagents</code> 专注于编写和执行 Python 代码片段的智能体，提供安全的沙盒执行环境。它支持本地和基于 API 的语言模型，使其适应各种开发环境。",qe,jl,Le,gl,ws="<strong>将我们自己的阿尔弗雷德智能体与社区分享</strong>难道不会很棒吗？通过这样做，任何人都可以轻松地从 Hub 下载并直接使用这个智能体，将哥谭市的终极派对策划者带到他们的指尖！让我们实现这个想法！🎉",Pe,dl,os="<code>smolagents</code> 库使这成为可能，允许你与社区分享完整的智能体，并下载其他人的智能体立即使用。这很简单，如下所示：",Oe,hl,De,fl,Cs="要再次下载智能体，请使用以下代码：",Ke,bl,lt,Vl,cs='令人兴奋的是，共享的智能体直接作为 Hugging Face Spaces 提供，允许你实时与它们交互。你可以在<a href="https://huggingface.co/spaces/davidberenstein1957/smolagents-and-tools" rel="nofollow">这里</a>探索其他智能体。',et,Bl,rs='例如，<em>AlfredAgent</em> 在<a href="https://huggingface.co/spaces/sergiopaniego/AlfredAgent" rel="nofollow">这里</a>可用。你可以直接在下面尝试：',tt,d,Is,st,kl,us="你可能想知道——阿尔弗雷德如何使用 <code>smolagents</code> 构建这样一个智能体？通过整合几个工具，他可以生成一个如下的智能体。现在不用担心这些工具，因为我们将在本单元后面有专门的部分详细探讨：",Jt,Nl,Ut,Fl,ms="如你所见，我们创建了一个具有多种工具的 <code>CodeAgent</code>，这些工具增强了智能体的功能，将其变成了准备好与社区分享的终极派对策划者！🎉",Mt,Zl,js="现在，轮到你了：使用我们刚刚学到的知识，构建你自己的智能体并与社区分享！🕵️‍♂️💡",nt,B,Tt,Gl,at,vl,gs="随着阿尔弗雷德对派对准备智能体的微调，他对调试其运行越来越疲惫。智能体本质上是不可预测的，难以检查。但由于他的目标是构建终极派对准备智能体并将其部署到生产环境中，他需要强大的可追踪性，用于未来的监控和分析。",yt,El,ds='再一次，<code>smolagents</code> 来救援！它采用 <a href="https://opentelemetry.io/" rel="nofollow">OpenTelemetry</a> 标准来检测智能体运行，允许无缝检查和日志记录。在 <a href="https://langfuse.com/" rel="nofollow">Langfuse</a> 和 <code>SmolagentsInstrumentor</code> 的帮助下，阿尔弗雷德可以轻松跟踪和分析他的智能体行为。',it,$l,hs="设置非常简单！",pt,Wl,fs="首先，我们需要安装必要的依赖项：",wt,Al,ot,Ql,bs='接下来，阿尔弗雷德已经在 Langfuse 上创建了一个账户，并准备好了他的 API 密钥。如果你还没有这样做，你可以在<a href="https://cloud.langfuse.com/" rel="nofollow">这里</a>注册 Langfuse Cloud 或探索<a href="https://huggingface.co/docs/smolagents/tutorials/inspect_runs" rel="nofollow">替代方案</a>。',Ct,Rl,Vs="一旦你有了 API 密钥，它们需要正确配置如下：",ct,Sl,rt,Hl,Bs="最后，阿尔弗雷德准备初始化 <code>SmolagentsInstrumentor</code> 并开始跟踪他的智能体性能。",It,xl,ut,_l,ks="阿尔弗雷德现在已连接 🔌！来自 <code>smolagents</code> 的运行正在 Langfuse 中记录，让他完全可见智能体的行为。有了这个设置，他准备重新访问之前的运行并进一步改进他的派对准备智能体。",mt,Yl,jt,Xl,Ns='阿尔弗雷德现在可以在<a href="https://cloud.langfuse.com/project/cm7bq0abj025rad078ak3luwi/traces/995fc019255528e4f48cf6770b0ce27b?timestamp=2025-02-19T10%3A28%3A36.929Z" rel="nofollow">这里</a>访问这些日志来审查和分析它们。',gt,zl,Fs='同时，<a href="https://open.spotify.com/playlist/0gZMMHjuxMrrybQ7wTMTpw" rel="nofollow">建议的播放列表</a>为派对准备设置了完美的氛围。很酷，对吧？🎶',dt,ht,ft,ql,Zs="现在我们已经创建了我们的第一个代码智能体，让我们<strong>学习如何创建工具调用智能体（Tool Calling Agents）</strong>，这是 <code>smolagents</code> 中可用的第二种智能体类型。",bt,Ll,Vt,Pl,Gs='<li><a href="https://huggingface.co/blog/smolagents" rel="nofollow">smolagents 博客</a> - smolagents 和代码交互介绍</li> <li><a href="https://huggingface.co/docs/smolagents/tutorials/building_good_agents" rel="nofollow">smolagents：构建好的智能体</a> - 可靠智能体的最佳实践</li> <li><a href="https://www.anthropic.com/research/building-effective-agents" rel="nofollow">构建有效的智能体 - Anthropic</a> - 智能体设计原则</li> <li><a href="https://huggingface.co/docs/smolagents/tutorials/inspect_runs" rel="nofollow">使用 OpenTelemetry 共享运行</a> - 关于如何为跟踪你的智能体设置 OpenTelemetry 的详细信息</li>',Bt,Ol,kt,Dl,Nt;return c=new _s({props:{chapter:2,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/agents-course/blob/main/notebooks/unit2/smolagents/code_agents.ipynb"}]}}),k=new h({props:{title:"构建使用代码的智能体",local:"构建使用代码的智能体",headingTag:"h1"}}),b=new Gt({props:{$$slots:{default:[Xs]},$$scope:{ctx:f}}}),G=new h({props:{title:"为什么选择代码智能体？",local:"为什么选择代码智能体",headingTag:"h2"}}),A=new h({props:{title:"代码智能体如何工作？",local:"代码智能体如何工作",headingTag:"h2"}}),_=new h({props:{title:"让我们看一些例子",local:"让我们看一些例子",headingTag:"h2"}}),V=new Gt({props:{$$slots:{default:[zs]},$$scope:{ctx:f}}}),q=new j({props:{code:"cGlwJTIwaW5zdGFsbCUyMHNtb2xhZ2VudHMlMjAtVQ==",highlighted:"pip install smolagents -U",wrap:!1}}),P=new j({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGxvZ2luJTBBJTBBbG9naW4oKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> login

login()`,wrap:!1}}),O=new h({props:{title:"使用 smolagents 为派对选择播放列表",local:"使用-smolagents-为派对选择播放列表",headingTag:"h3"}}),tl=new j({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBEdWNrRHVja0dvU2VhcmNoVG9vbCUyQyUyMEhmQXBpTW9kZWwlMEElMEFhZ2VudCUyMCUzRCUyMENvZGVBZ2VudCh0b29scyUzRCU1QkR1Y2tEdWNrR29TZWFyY2hUb29sKCklNUQlMkMlMjBtb2RlbCUzREhmQXBpTW9kZWwoKSklMEElMEFhZ2VudC5ydW4oJTIyU2VhcmNoJTIwZm9yJTIwdGhlJTIwYmVzdCUyMG11c2ljJTIwcmVjb21tZW5kYXRpb25zJTIwZm9yJTIwYSUyMHBhcnR5JTIwYXQlMjB0aGUlMjBXYXluZSdzJTIwbWFuc2lvbi4lMjIp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, DuckDuckGoSearchTool, HfApiModel

agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())

agent.run(<span class="hljs-string">&quot;Search for the best music recommendations for a party at the Wayne&#x27;s mansion.&quot;</span>)`,wrap:!1}}),Jl=new j({props:{code:"JTIwJUUyJTk0JTgwJTIwRXhlY3V0aW5nJTIwcGFyc2VkJTIwY29kZSUzQSUyMCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCVFMiU5NCU4MCUyMCUwQSUyMCUyMHJlc3VsdHMlMjAlM0QlMjB3ZWJfc2VhcmNoKHF1ZXJ5JTNEJTIyYmVzdCUyMG11c2ljJTIwZm9yJTIwYSUyMEJhdG1hbiUyMHBhcnR5JTIyKSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUwQSUyMCUyMHByaW50KHJlc3VsdHMpJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTBBJTIwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJTIw",highlighted:` ─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────── 
  results = web_search(query=<span class="hljs-string">&quot;best music for a Batman party&quot;</span>)                                                      
  <span class="hljs-built_in">print</span>(results)                                                                                                   
 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── `,wrap:!1}}),Ml=new h({props:{title:"使用自定义工具准备菜单",local:"使用自定义工具准备菜单",headingTag:"h3"}}),yl=new j({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjB0b29sJTJDJTIwSGZBcGlNb2RlbCUwQSUwQSUyMyUyMCVFNiVBMCVCOSVFNiU4RCVBRSVFNSU5QyVCQSVFNSU5MCU4OCVFNSVCQiVCQSVFOCVBRSVBRSVFOCU4RiU5QyVFNSU4RCU5NSVFNyU5QSU4NCVFNSVCNyVBNSVFNSU4NSVCNyUwQSU0MHRvb2wlMEFkZWYlMjBzdWdnZXN0X21lbnUob2NjYXNpb24lM0ElMjBzdHIpJTIwLSUzRSUyMHN0ciUzQSUwQSUyMCUyMCUyMCUyMCUyMiUyMiUyMiUwQSUyMCUyMCUyMCUyMFN1Z2dlc3RzJTIwYSUyMG1lbnUlMjBiYXNlZCUyMG9uJTIwdGhlJTIwb2NjYXNpb24uJTBBJTIwJTIwJTIwJTIwQXJncyUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG9jY2FzaW9uJTNBJTIwVGhlJTIwdHlwZSUyMG9mJTIwb2NjYXNpb24lMjBmb3IlMjB0aGUlMjBwYXJ0eS4lMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBpZiUyMG9jY2FzaW9uJTIwJTNEJTNEJTIwJTIyY2FzdWFsJTIyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyUGl6emElMkMlMjBzbmFja3MlMkMlMjBhbmQlMjBkcmlua3MuJTIyJTBBJTIwJTIwJTIwJTIwZWxpZiUyMG9jY2FzaW9uJTIwJTNEJTNEJTIwJTIyZm9ybWFsJTIyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyMy1jb3Vyc2UlMjBkaW5uZXIlMjB3aXRoJTIwd2luZSUyMGFuZCUyMGRlc3NlcnQuJTIyJTBBJTIwJTIwJTIwJTIwZWxpZiUyMG9jY2FzaW9uJTIwJTNEJTNEJTIwJTIyc3VwZXJoZXJvJTIyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyQnVmZmV0JTIwd2l0aCUyMGhpZ2gtZW5lcmd5JTIwYW5kJTIwaGVhbHRoeSUyMGZvb2QuJTIyJTBBJTIwJTIwJTIwJTIwZWxzZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMCUyMkN1c3RvbSUyMG1lbnUlMjBmb3IlMjB0aGUlMjBidXRsZXIuJTIyJTBBJTBBJTIzJTIwJUU3JUFFJUExJUU1JUFFJUI2JUU5JTk4JUJGJUU1JUIwJTk0JUU1JUJDJTk3JUU5JTlCJUI3JUU1JUJFJUI3JUVGJUJDJThDJUU0JUI4JUJBJUU2JUI0JUJFJUU1JUFGJUI5JUU1JTg3JTg2JUU1JUE0JTg3JUU4JThGJTlDJUU1JThEJTk1JTBBYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQodG9vbHMlM0QlNUJzdWdnZXN0X21lbnUlNUQlMkMlMjBtb2RlbCUzREhmQXBpTW9kZWwoKSklMEElMEElMjMlMjAlRTQlQjglQkElRTYlQjQlQkUlRTUlQUYlQjklRTUlODclODYlRTUlQTQlODclRTYlQUQlQTMlRTUlQkMlOEYlRTglOEYlOUMlRTUlOEQlOTUlMEFhZ2VudC5ydW4oJTIyUHJlcGFyZSUyMGElMjBmb3JtYWwlMjBtZW51JTIwZm9yJTIwdGhlJTIwcGFydHkuJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, tool, HfApiModel

<span class="hljs-comment"># 根据场合建议菜单的工具</span>
<span class="hljs-meta">@tool</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">suggest_menu</span>(<span class="hljs-params">occasion: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;
    Suggests a menu based on the occasion.
    Args:
        occasion: The type of occasion for the party.
    &quot;&quot;&quot;</span>
    <span class="hljs-keyword">if</span> occasion == <span class="hljs-string">&quot;casual&quot;</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Pizza, snacks, and drinks.&quot;</span>
    <span class="hljs-keyword">elif</span> occasion == <span class="hljs-string">&quot;formal&quot;</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;3-course dinner with wine and dessert.&quot;</span>
    <span class="hljs-keyword">elif</span> occasion == <span class="hljs-string">&quot;superhero&quot;</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Buffet with high-energy and healthy food.&quot;</span>
    <span class="hljs-keyword">else</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Custom menu for the butler.&quot;</span>

<span class="hljs-comment"># 管家阿尔弗雷德，为派对准备菜单</span>
agent = CodeAgent(tools=[suggest_menu], model=HfApiModel())

<span class="hljs-comment"># 为派对准备正式菜单</span>
agent.run(<span class="hljs-string">&quot;Prepare a formal menu for the party.&quot;</span>)`,wrap:!1}}),wl=new h({props:{title:"在智能体内部使用 Python 导入",local:"在智能体内部使用-python-导入",headingTag:"h3"}}),Il=new j({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBIZkFwaU1vZGVsJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdGltZSUwQWltcG9ydCUyMGRhdGV0aW1lJTBBJTBBYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQodG9vbHMlM0QlNUIlNUQlMkMlMjBtb2RlbCUzREhmQXBpTW9kZWwoKSUyQyUyMGFkZGl0aW9uYWxfYXV0aG9yaXplZF9pbXBvcnRzJTNEJTVCJ2RhdGV0aW1lJyU1RCklMEElMEFhZ2VudC5ydW4oJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyJTBBJTIwJTIwJTIwJTIwQWxmcmVkJTIwbmVlZHMlMjB0byUyMHByZXBhcmUlMjBmb3IlMjB0aGUlMjBwYXJ0eS4lMjBIZXJlJTIwYXJlJTIwdGhlJTIwdGFza3MlM0ElMEElMjAlMjAlMjAlMjAxLiUyMFByZXBhcmUlMjB0aGUlMjBkcmlua3MlMjAtJTIwMzAlMjBtaW51dGVzJTBBJTIwJTIwJTIwJTIwMi4lMjBEZWNvcmF0ZSUyMHRoZSUyMG1hbnNpb24lMjAtJTIwNjAlMjBtaW51dGVzJTBBJTIwJTIwJTIwJTIwMy4lMjBTZXQlMjB1cCUyMHRoZSUyMG1lbnUlMjAtJTIwNDUlMjBtaW51dGVzJTBBJTIwJTIwJTIwJTIwMy4lMjBQcmVwYXJlJTIwdGhlJTIwbXVzaWMlMjBhbmQlMjBwbGF5bGlzdCUyMC0lMjA0NSUyMG1pbnV0ZXMlMEElMEElMjAlMjAlMjAlMjBJZiUyMHdlJTIwc3RhcnQlMjByaWdodCUyMG5vdyUyQyUyMGF0JTIwd2hhdCUyMHRpbWUlMjB3aWxsJTIwdGhlJTIwcGFydHklMjBiZSUyMHJlYWR5JTNGJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, HfApiModel
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> time
<span class="hljs-keyword">import</span> datetime

agent = CodeAgent(tools=[], model=HfApiModel(), additional_authorized_imports=[<span class="hljs-string">&#x27;datetime&#x27;</span>])

agent.run(
    <span class="hljs-string">&quot;&quot;&quot;
    Alfred needs to prepare for the party. Here are the tasks:
    1. Prepare the drinks - 30 minutes
    2. Decorate the mansion - 60 minutes
    3. Set up the menu - 45 minutes
    3. Prepare the music and playlist - 45 minutes

    If we start right now, at what time will the party be ready?
    &quot;&quot;&quot;</span>
)`,wrap:!1}}),jl=new h({props:{title:"将我们的自定义派对准备智能体分享到 Hub",local:"将我们的自定义派对准备智能体分享到-hub",headingTag:"h3"}}),hl=new j({props:{code:"JTIzJTIwJUU2JTlCJUI0JUU2JTk0JUI5JUU0JUI4JUJBJUU0JUJEJUEwJUU3JTlBJTg0JUU3JTk0JUE4JUU2JTg4JUI3JUU1JTkwJThEJUU1JTkyJThDJUU0JUJCJTkzJUU1JUJBJTkzJUU1JTkwJThEJTBBYWdlbnQucHVzaF90b19odWIoJ3Nlcmdpb3BhbmllZ28lMkZBbGZyZWRBZ2VudCcp",highlighted:`<span class="hljs-comment"># 更改为你的用户名和仓库名</span>
agent.push_to_hub(<span class="hljs-string">&#x27;sergiopaniego/AlfredAgent&#x27;</span>)`,wrap:!1}}),bl=new j({props:{code:"JTIzJTIwJUU2JTlCJUI0JUU2JTk0JUI5JUU0JUI4JUJBJUU0JUJEJUEwJUU3JTlBJTg0JUU3JTk0JUE4JUU2JTg4JUI3JUU1JTkwJThEJUU1JTkyJThDJUU0JUJCJTkzJUU1JUJBJTkzJUU1JTkwJThEJTBBYWxmcmVkX2FnZW50JTIwJTNEJTIwYWdlbnQuZnJvbV9odWIoJ3Nlcmdpb3BhbmllZ28lMkZBbGZyZWRBZ2VudCcpJTBBJTBBYWxmcmVkX2FnZW50LnJ1biglMjJHaXZlJTIwbWUlMjB0aGUlMjBiZXN0JTIwcGxheWxpc3QlMjBmb3IlMjBhJTIwcGFydHklMjBhdCUyMFdheW5lJ3MlMjBtYW5zaW9uLiUyMFRoZSUyMHBhcnR5JTIwaWRlYSUyMGlzJTIwYSUyMCd2aWxsYWluJTIwbWFzcXVlcmFkZSclMjB0aGVtZSUyMiklMjAlMjA=",highlighted:`<span class="hljs-comment"># 更改为你的用户名和仓库名</span>
alfred_agent = agent.from_hub(<span class="hljs-string">&#x27;sergiopaniego/AlfredAgent&#x27;</span>)

alfred_agent.run(<span class="hljs-string">&quot;Give me the best playlist for a party at Wayne&#x27;s mansion. The party idea is a &#x27;villain masquerade&#x27; theme&quot;</span>)  `,wrap:!1}}),Nl=new j({props:{code:" ",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool, HfApiModel, Tool, tool, VisitWebpageTool

<span class="hljs-meta">@tool</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">suggest_menu</span>(<span class="hljs-params">occasion: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;
    Suggests a menu based on the occasion.
    Args:
        occasion: The type of occasion for the party.
    &quot;&quot;&quot;</span>
    <span class="hljs-keyword">if</span> occasion == <span class="hljs-string">&quot;casual&quot;</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Pizza, snacks, and drinks.&quot;</span>
    <span class="hljs-keyword">elif</span> occasion == <span class="hljs-string">&quot;formal&quot;</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;3-course dinner with wine and dessert.&quot;</span>
    <span class="hljs-keyword">elif</span> occasion == <span class="hljs-string">&quot;superhero&quot;</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Buffet with high-energy and healthy food.&quot;</span>
    <span class="hljs-keyword">else</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Custom menu for the butler.&quot;</span>

<span class="hljs-meta">@tool</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">catering_service_tool</span>(<span class="hljs-params">query: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;
    This tool returns the highest-rated catering service in Gotham City.
    
    Args:
        query: A search term for finding catering services.
    &quot;&quot;&quot;</span>
    <span class="hljs-comment"># 餐饮服务及其评分的示例列表    </span>
    services = {
        <span class="hljs-string">&quot;Gotham Catering Co.&quot;</span>: <span class="hljs-number">4.9</span>,
        <span class="hljs-string">&quot;Wayne Manor Catering&quot;</span>: <span class="hljs-number">4.8</span>,
        <span class="hljs-string">&quot;Gotham City Events&quot;</span>: <span class="hljs-number">4.7</span>,
    }
    
    <span class="hljs-comment"># 找到评分最高的餐饮服务（模拟搜索查询过滤）</span>
    best_service = <span class="hljs-built_in">max</span>(services, key=services.get)
    
    <span class="hljs-keyword">return</span> best_service

<span class="hljs-keyword">class</span> <span class="hljs-title class_">SuperheroPartyThemeTool</span>(<span class="hljs-title class_ inherited__">Tool</span>):
    name = <span class="hljs-string">&quot;superhero_party_theme_generator&quot;</span>
    description = <span class="hljs-string">&quot;&quot;&quot;
    This tool suggests creative superhero-themed party ideas based on a category.
    It returns a unique party theme idea.&quot;&quot;&quot;</span>
    
    inputs = {
        <span class="hljs-string">&quot;category&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 type of superhero party (e.g., &#x27;classic heroes&#x27;, &#x27;villain masquerade&#x27;, &#x27;futuristic Gotham&#x27;).&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, category: <span class="hljs-built_in">str</span></span>):
        themes = {
            <span class="hljs-string">&quot;classic heroes&quot;</span>: <span class="hljs-string">&quot;Justice League Gala: Guests come dressed as their favorite DC heroes with themed cocktails like &#x27;The Kryptonite Punch&#x27;.&quot;</span>,
            <span class="hljs-string">&quot;villain masquerade&quot;</span>: <span class="hljs-string">&quot;Gotham Rogues&#x27; Ball: A mysterious masquerade where guests dress as classic Batman villains.&quot;</span>,
            <span class="hljs-string">&quot;futuristic Gotham&quot;</span>: <span class="hljs-string">&quot;Neo-Gotham Night: A cyberpunk-style party inspired by Batman Beyond, with neon decorations and futuristic gadgets.&quot;</span>
        }
        
        <span class="hljs-keyword">return</span> themes.get(category.lower(), <span class="hljs-string">&quot;Themed party idea not found. Try &#x27;classic heroes&#x27;, &#x27;villain masquerade&#x27;, or &#x27;futuristic Gotham&#x27;.&quot;</span>)


<span class="hljs-comment"># 管家阿尔弗雷德，为派对准备菜单</span>
agent = CodeAgent(
    tools=[
        DuckDuckGoSearchTool(), 
        VisitWebpageTool(),
        suggest_menu,
        catering_service_tool,
        SuperheroPartyThemeTool()
    ], 
    model=HfApiModel(),
    max_steps=<span class="hljs-number">10</span>,
    verbosity_level=<span class="hljs-number">2</span>
)

agent.run(<span class="hljs-string">&quot;Give me best playlist for a party at the Wayne&#x27;s mansion. The party idea is a &#x27;villain masquerade&#x27; theme&quot;</span>)`,wrap:!1}}),B=new Gt({props:{$$slots:{default:[qs]},$$scope:{ctx:f}}}),Gl=new h({props:{title:"使用 OpenTelemetry 和 Langfuse 检查我们的派对准备智能体 📡",local:"使用-opentelemetry-和-langfuse-检查我们的派对准备智能体-",headingTag:"h3"}}),Al=new j({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wZW50ZWxlbWV0cnktc2RrJTIwb3BlbnRlbGVtZXRyeS1leHBvcnRlci1vdGxwJTIwb3BlbmluZmVyZW5jZS1pbnN0cnVtZW50YXRpb24tc21vbGFnZW50cw==",highlighted:"pip install opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-smolagents",wrap:!1}}),Sl=new j({props:{code:"aW1wb3J0JTIwb3MlMEFpbXBvcnQlMjBiYXNlNjQlMEElMEFMQU5HRlVTRV9QVUJMSUNfS0VZJTNEJTIycGstbGYtLi4uJTIyJTBBTEFOR0ZVU0VfU0VDUkVUX0tFWSUzRCUyMnNrLWxmLS4uLiUyMiUwQUxBTkdGVVNFX0FVVEglM0RiYXNlNjQuYjY0ZW5jb2RlKGYlMjIlN0JMQU5HRlVTRV9QVUJMSUNfS0VZJTdEJTNBJTdCTEFOR0ZVU0VfU0VDUkVUX0tFWSU3RCUyMi5lbmNvZGUoKSkuZGVjb2RlKCklMEElMEFvcy5lbnZpcm9uJTVCJTIyT1RFTF9FWFBPUlRFUl9PVExQX0VORFBPSU5UJTIyJTVEJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZjbG91ZC5sYW5nZnVzZS5jb20lMkZhcGklMkZwdWJsaWMlMkZvdGVsJTIyJTIwJTIzJTIwRVUlMjAlRTYlOTUlQjAlRTYlOEQlQUUlRTUlOEMlQkElRTUlOUYlOUYlMEElMjMlMjBvcy5lbnZpcm9uJTVCJTIyT1RFTF9FWFBPUlRFUl9PVExQX0VORFBPSU5UJTIyJTVEJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZ1cy5jbG91ZC5sYW5nZnVzZS5jb20lMkZhcGklMkZwdWJsaWMlMkZvdGVsJTIyJTIwJTIzJTIwVVMlMjAlRTYlOTUlQjAlRTYlOEQlQUUlRTUlOEMlQkElRTUlOUYlOUYlMEFvcy5lbnZpcm9uJTVCJTIyT1RFTF9FWFBPUlRFUl9PVExQX0hFQURFUlMlMjIlNUQlMjAlM0QlMjBmJTIyQXV0aG9yaXphdGlvbiUzREJhc2ljJTIwJTdCTEFOR0ZVU0VfQVVUSCU3RCUyMg==",highlighted:`<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> base64

LANGFUSE_PUBLIC_KEY=<span class="hljs-string">&quot;pk-lf-...&quot;</span>
LANGFUSE_SECRET_KEY=<span class="hljs-string">&quot;sk-lf-...&quot;</span>
LANGFUSE_AUTH=base64.b64encode(<span class="hljs-string">f&quot;<span class="hljs-subst">{LANGFUSE_PUBLIC_KEY}</span>:<span class="hljs-subst">{LANGFUSE_SECRET_KEY}</span>&quot;</span>.encode()).decode()

os.environ[<span class="hljs-string">&quot;OTEL_EXPORTER_OTLP_ENDPOINT&quot;</span>] = <span class="hljs-string">&quot;https://cloud.langfuse.com/api/public/otel&quot;</span> <span class="hljs-comment"># EU 数据区域</span>
<span class="hljs-comment"># os.environ[&quot;OTEL_EXPORTER_OTLP_ENDPOINT&quot;] = &quot;https://us.cloud.langfuse.com/api/public/otel&quot; # US 数据区域</span>
os.environ[<span class="hljs-string">&quot;OTEL_EXPORTER_OTLP_HEADERS&quot;</span>] = <span class="hljs-string">f&quot;Authorization=Basic <span class="hljs-subst">{LANGFUSE_AUTH}</span>&quot;</span>`,wrap:!1}}),xl=new j({props:{code:"ZnJvbSUyMG9wZW50ZWxlbWV0cnkuc2RrLnRyYWNlJTIwaW1wb3J0JTIwVHJhY2VyUHJvdmlkZXIlMEElMEFmcm9tJTIwb3BlbmluZmVyZW5jZS5pbnN0cnVtZW50YXRpb24uc21vbGFnZW50cyUyMGltcG9ydCUyMFNtb2xhZ2VudHNJbnN0cnVtZW50b3IlMEFmcm9tJTIwb3BlbnRlbGVtZXRyeS5leHBvcnRlci5vdGxwLnByb3RvLmh0dHAudHJhY2VfZXhwb3J0ZXIlMjBpbXBvcnQlMjBPVExQU3BhbkV4cG9ydGVyJTBBZnJvbSUyMG9wZW50ZWxlbWV0cnkuc2RrLnRyYWNlLmV4cG9ydCUyMGltcG9ydCUyMFNpbXBsZVNwYW5Qcm9jZXNzb3IlMEElMEF0cmFjZV9wcm92aWRlciUyMCUzRCUyMFRyYWNlclByb3ZpZGVyKCklMEF0cmFjZV9wcm92aWRlci5hZGRfc3Bhbl9wcm9jZXNzb3IoU2ltcGxlU3BhblByb2Nlc3NvcihPVExQU3BhbkV4cG9ydGVyKCkpKSUwQSUwQVNtb2xhZ2VudHNJbnN0cnVtZW50b3IoKS5pbnN0cnVtZW50KHRyYWNlcl9wcm92aWRlciUzRHRyYWNlX3Byb3ZpZGVyKQ==",highlighted:`<span class="hljs-keyword">from</span> opentelemetry.sdk.trace <span class="hljs-keyword">import</span> TracerProvider

<span class="hljs-keyword">from</span> openinference.instrumentation.smolagents <span class="hljs-keyword">import</span> SmolagentsInstrumentor
<span class="hljs-keyword">from</span> opentelemetry.exporter.otlp.proto.http.trace_exporter <span class="hljs-keyword">import</span> OTLPSpanExporter
<span class="hljs-keyword">from</span> opentelemetry.sdk.trace.export <span class="hljs-keyword">import</span> SimpleSpanProcessor

trace_provider = TracerProvider()
trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))

SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)`,wrap:!1}}),Yl=new j({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBIZkFwaU1vZGVsJTBBJTBBYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQodG9vbHMlM0QlNUIlNUQlMkMlMjBtb2RlbCUzREhmQXBpTW9kZWwoKSklMEFhbGZyZWRfYWdlbnQlMjAlM0QlMjBhZ2VudC5mcm9tX2h1Yignc2VyZ2lvcGFuaWVnbyUyRkFsZnJlZEFnZW50JyUyQyUyMHRydXN0X3JlbW90ZV9jb2RlJTNEVHJ1ZSklMEFhbGZyZWRfYWdlbnQucnVuKCUyMkdpdmUlMjBtZSUyMHRoZSUyMGJlc3QlMjBwbGF5bGlzdCUyMGZvciUyMGElMjBwYXJ0eSUyMGF0JTIwV2F5bmUncyUyMG1hbnNpb24uJTIwVGhlJTIwcGFydHklMjBpZGVhJTIwaXMlMjBhJTIwJ3ZpbGxhaW4lMjBtYXNxdWVyYWRlJyUyMHRoZW1lJTIyKSUyMCUyMA==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, HfApiModel

agent = CodeAgent(tools=[], model=HfApiModel())
alfred_agent = agent.from_hub(<span class="hljs-string">&#x27;sergiopaniego/AlfredAgent&#x27;</span>, trust_remote_code=<span class="hljs-literal">True</span>)
alfred_agent.run(<span class="hljs-string">&quot;Give me the best playlist for a party at Wayne&#x27;s mansion. The party idea is a &#x27;villain masquerade&#x27; theme&quot;</span>)  `,wrap:!1}}),Ll=new h({props:{title:"资源",local:"资源",headingTag:"h2"}}),Ol=new Ys({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit2/smolagents/code_agents.mdx"}}),{c(){r=M("meta"),a=J(),m=M("p"),u=J(),y(c.$$.fragment),g=J(),y(k.$$.fragment),ee=J(),N=M("p"),N.innerHTML=vt,te=J(),F=M("p"),F.innerHTML=Et,se=J(),Z=M("p"),Z.innerHTML=$t,Je=J(),y(b.$$.fragment),Ue=J(),y(G.$$.fragment),Me=J(),v=M("p"),v.innerHTML=Wt,ne=J(),E=M("p"),E.innerHTML=At,Te=J(),$=M("p"),$.textContent=Qt,ae=J(),W=M("ul"),W.innerHTML=Rt,ye=J(),y(A.$$.fragment),ie=J(),Q=M("p"),Q.innerHTML=St,pe=J(),R=M("p"),R.innerHTML=Ht,we=J(),S=M("p"),S.innerHTML=xt,oe=J(),H=M("ol"),H.innerHTML=_t,Ce=J(),x=M("p"),x.innerHTML=Yt,ce=J(),y(_.$$.fragment),re=J(),y(V.$$.fragment),Ie=J(),Y=M("p"),Y.innerHTML=Xt,ue=J(),X=M("img"),me=J(),z=M("p"),z.innerHTML=qt,je=J(),y(q.$$.fragment),ge=J(),L=M("p"),L.textContent=Lt,de=J(),y(P.$$.fragment),he=J(),y(O.$$.fragment),fe=J(),D=M("p"),D.innerHTML=Pt,be=J(),K=M("img"),Ve=J(),ll=M("p"),ll.innerHTML=Dt,Be=J(),el=M("p"),el.textContent=Kt,ke=J(),y(tl.$$.fragment),Ne=J(),sl=M("p"),sl.innerHTML=ls,Fe=J(),y(Jl.$$.fragment),Ze=J(),Ul=M("p"),Ul.textContent=es,Ge=J(),y(Ml.$$.fragment),ve=J(),nl=M("img"),Ee=J(),Tl=M("p"),Tl.innerHTML=ss,$e=J(),al=M("p"),al.innerHTML=Js,We=J(),y(yl.$$.fragment),Ae=J(),il=M("p"),il.textContent=Us,Qe=J(),pl=M("p"),pl.textContent=Ms,Re=J(),y(wl.$$.fragment),Se=J(),ol=M("p"),ol.textContent=ns,He=J(),Cl=M("p"),Cl.textContent=Ts,xe=J(),cl=M("p"),cl.innerHTML=as,_e=J(),rl=M("p"),rl.innerHTML=ys,Ye=J(),y(Il.$$.fragment),Xe=J(),ul=M("p"),ul.innerHTML=is,ze=J(),ml=M("p"),ml.innerHTML=ps,qe=J(),y(jl.$$.fragment),Le=J(),gl=M("p"),gl.innerHTML=ws,Pe=J(),dl=M("p"),dl.innerHTML=os,Oe=J(),y(hl.$$.fragment),De=J(),fl=M("p"),fl.textContent=Cs,Ke=J(),y(bl.$$.fragment),lt=J(),Vl=M("p"),Vl.innerHTML=cs,et=J(),Bl=M("p"),Bl.innerHTML=rs,tt=J(),d=M("iframe"),st=J(),kl=M("p"),kl.innerHTML=us,Jt=J(),y(Nl.$$.fragment),Ut=J(),Fl=M("p"),Fl.innerHTML=ms,Mt=J(),Zl=M("p"),Zl.textContent=js,nt=J(),y(B.$$.fragment),Tt=J(),y(Gl.$$.fragment),at=J(),vl=M("p"),vl.textContent=gs,yt=J(),El=M("p"),El.innerHTML=ds,it=J(),$l=M("p"),$l.textContent=hs,pt=J(),Wl=M("p"),Wl.textContent=fs,wt=J(),y(Al.$$.fragment),ot=J(),Ql=M("p"),Ql.innerHTML=bs,Ct=J(),Rl=M("p"),Rl.textContent=Vs,ct=J(),y(Sl.$$.fragment),rt=J(),Hl=M("p"),Hl.innerHTML=Bs,It=J(),y(xl.$$.fragment),ut=J(),_l=M("p"),_l.innerHTML=ks,mt=J(),y(Yl.$$.fragment),jt=J(),Xl=M("p"),Xl.innerHTML=Ns,gt=J(),zl=M("p"),zl.innerHTML=Fs,dt=J(),ht=M("hr"),ft=J(),ql=M("p"),ql.innerHTML=Zs,bt=J(),y(Ll.$$.fragment),Vt=J(),Pl=M("ul"),Pl.innerHTML=Gs,Bt=J(),y(Ol.$$.fragment),kt=J(),Dl=M("p"),this.h()},l(l){const e=Hs("svelte-u9bgzb",document.head);r=n(e,"META",{name:!0,content:!0}),e.forEach(t),a=U(l),m=n(l,"P",{}),Zt(m).forEach(t),u=U(l),i(c.$$.fragment,l),g=U(l),i(k.$$.fragment,l),ee=U(l),N=n(l,"P",{"data-svelte-h":!0}),T(N)!=="svelte-9ymf39"&&(N.innerHTML=vt),te=U(l),F=n(l,"P",{"data-svelte-h":!0}),T(F)!=="svelte-fp3c5i"&&(F.innerHTML=Et),se=U(l),Z=n(l,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-1fe7zeb"&&(Z.innerHTML=$t),Je=U(l),i(b.$$.fragment,l),Ue=U(l),i(G.$$.fragment,l),Me=U(l),v=n(l,"P",{"data-svelte-h":!0}),T(v)!=="svelte-l5zfvz"&&(v.innerHTML=Wt),ne=U(l),E=n(l,"P",{"data-svelte-h":!0}),T(E)!=="svelte-hwuo60"&&(E.innerHTML=At),Te=U(l),$=n(l,"P",{"data-svelte-h":!0}),T($)!=="svelte-7wpd4j"&&($.textContent=Qt),ae=U(l),W=n(l,"UL",{"data-svelte-h":!0}),T(W)!=="svelte-1o5j9s7"&&(W.innerHTML=Rt),ye=U(l),i(A.$$.fragment,l),ie=U(l),Q=n(l,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-11zkmfo"&&(Q.innerHTML=St),pe=U(l),R=n(l,"P",{"data-svelte-h":!0}),T(R)!=="svelte-19v0aru"&&(R.innerHTML=Ht),we=U(l),S=n(l,"P",{"data-svelte-h":!0}),T(S)!=="svelte-1y2sq4s"&&(S.innerHTML=xt),oe=U(l),H=n(l,"OL",{"data-svelte-h":!0}),T(H)!=="svelte-zvc6d4"&&(H.innerHTML=_t),Ce=U(l),x=n(l,"P",{"data-svelte-h":!0}),T(x)!=="svelte-1iis6f"&&(x.innerHTML=Yt),ce=U(l),i(_.$$.fragment,l),re=U(l),i(V.$$.fragment,l),Ie=U(l),Y=n(l,"P",{"data-svelte-h":!0}),T(Y)!=="svelte-1n6vc7y"&&(Y.innerHTML=Xt),ue=U(l),X=n(l,"IMG",{src:!0,alt:!0}),me=U(l),z=n(l,"P",{"data-svelte-h":!0}),T(z)!=="svelte-utbpgy"&&(z.innerHTML=qt),je=U(l),i(q.$$.fragment,l),ge=U(l),L=n(l,"P",{"data-svelte-h":!0}),T(L)!=="svelte-1db12br"&&(L.textContent=Lt),de=U(l),i(P.$$.fragment,l),he=U(l),i(O.$$.fragment,l),fe=U(l),D=n(l,"P",{"data-svelte-h":!0}),T(D)!=="svelte-12eqykj"&&(D.innerHTML=Pt),be=U(l),K=n(l,"IMG",{src:!0,alt:!0}),Ve=U(l),ll=n(l,"P",{"data-svelte-h":!0}),T(ll)!=="svelte-at08d1"&&(ll.innerHTML=Dt),Be=U(l),el=n(l,"P",{"data-svelte-h":!0}),T(el)!=="svelte-wei6ii"&&(el.textContent=Kt),ke=U(l),i(tl.$$.fragment,l),Ne=U(l),sl=n(l,"P",{"data-svelte-h":!0}),T(sl)!=="svelte-1fgov2e"&&(sl.innerHTML=ls),Fe=U(l),i(Jl.$$.fragment,l),Ze=U(l),Ul=n(l,"P",{"data-svelte-h":!0}),T(Ul)!=="svelte-1tb9ak8"&&(Ul.textContent=es),Ge=U(l),i(Ml.$$.fragment,l),ve=U(l),nl=n(l,"IMG",{src:!0,alt:!0}),Ee=U(l),Tl=n(l,"P",{"data-svelte-h":!0}),T(Tl)!=="svelte-v2hosz"&&(Tl.innerHTML=ss),$e=U(l),al=n(l,"P",{"data-svelte-h":!0}),T(al)!=="svelte-1ypx3hb"&&(al.innerHTML=Js),We=U(l),i(yl.$$.fragment,l),Ae=U(l),il=n(l,"P",{"data-svelte-h":!0}),T(il)!=="svelte-a8jfmd"&&(il.textContent=Us),Qe=U(l),pl=n(l,"P",{"data-svelte-h":!0}),T(pl)!=="svelte-g3pzw9"&&(pl.textContent=Ms),Re=U(l),i(wl.$$.fragment,l),Se=U(l),ol=n(l,"P",{"data-svelte-h":!0}),T(ol)!=="svelte-15uzzdb"&&(ol.textContent=ns),He=U(l),Cl=n(l,"P",{"data-svelte-h":!0}),T(Cl)!=="svelte-1c12mmu"&&(Cl.textContent=Ts),xe=U(l),cl=n(l,"P",{"data-svelte-h":!0}),T(cl)!=="svelte-1mvdut1"&&(cl.innerHTML=as),_e=U(l),rl=n(l,"P",{"data-svelte-h":!0}),T(rl)!=="svelte-1w0bcf1"&&(rl.innerHTML=ys),Ye=U(l),i(Il.$$.fragment,l),Xe=U(l),ul=n(l,"P",{"data-svelte-h":!0}),T(ul)!=="svelte-nmbtz8"&&(ul.innerHTML=is),ze=U(l),ml=n(l,"P",{"data-svelte-h":!0}),T(ml)!=="svelte-1m8jf34"&&(ml.innerHTML=ps),qe=U(l),i(jl.$$.fragment,l),Le=U(l),gl=n(l,"P",{"data-svelte-h":!0}),T(gl)!=="svelte-qdl6e5"&&(gl.innerHTML=ws),Pe=U(l),dl=n(l,"P",{"data-svelte-h":!0}),T(dl)!=="svelte-lx3ox3"&&(dl.innerHTML=os),Oe=U(l),i(hl.$$.fragment,l),De=U(l),fl=n(l,"P",{"data-svelte-h":!0}),T(fl)!=="svelte-gf9unb"&&(fl.textContent=Cs),Ke=U(l),i(bl.$$.fragment,l),lt=U(l),Vl=n(l,"P",{"data-svelte-h":!0}),T(Vl)!=="svelte-1wixttm"&&(Vl.innerHTML=cs),et=U(l),Bl=n(l,"P",{"data-svelte-h":!0}),T(Bl)!=="svelte-1oeri7k"&&(Bl.innerHTML=rs),tt=U(l),d=n(l,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),Zt(d).forEach(t),st=U(l),kl=n(l,"P",{"data-svelte-h":!0}),T(kl)!=="svelte-4djxsr"&&(kl.innerHTML=us),Jt=U(l),i(Nl.$$.fragment,l),Ut=U(l),Fl=n(l,"P",{"data-svelte-h":!0}),T(Fl)!=="svelte-10guegr"&&(Fl.innerHTML=ms),Mt=U(l),Zl=n(l,"P",{"data-svelte-h":!0}),T(Zl)!=="svelte-1bia4fv"&&(Zl.textContent=js),nt=U(l),i(B.$$.fragment,l),Tt=U(l),i(Gl.$$.fragment,l),at=U(l),vl=n(l,"P",{"data-svelte-h":!0}),T(vl)!=="svelte-1dqmr61"&&(vl.textContent=gs),yt=U(l),El=n(l,"P",{"data-svelte-h":!0}),T(El)!=="svelte-risard"&&(El.innerHTML=ds),it=U(l),$l=n(l,"P",{"data-svelte-h":!0}),T($l)!=="svelte-45pd9s"&&($l.textContent=hs),pt=U(l),Wl=n(l,"P",{"data-svelte-h":!0}),T(Wl)!=="svelte-1tvhb6o"&&(Wl.textContent=fs),wt=U(l),i(Al.$$.fragment,l),ot=U(l),Ql=n(l,"P",{"data-svelte-h":!0}),T(Ql)!=="svelte-1jcoxv6"&&(Ql.innerHTML=bs),Ct=U(l),Rl=n(l,"P",{"data-svelte-h":!0}),T(Rl)!=="svelte-bbwrb5"&&(Rl.textContent=Vs),ct=U(l),i(Sl.$$.fragment,l),rt=U(l),Hl=n(l,"P",{"data-svelte-h":!0}),T(Hl)!=="svelte-s74a79"&&(Hl.innerHTML=Bs),It=U(l),i(xl.$$.fragment,l),ut=U(l),_l=n(l,"P",{"data-svelte-h":!0}),T(_l)!=="svelte-1pnj6yu"&&(_l.innerHTML=ks),mt=U(l),i(Yl.$$.fragment,l),jt=U(l),Xl=n(l,"P",{"data-svelte-h":!0}),T(Xl)!=="svelte-1rlcqk3"&&(Xl.innerHTML=Ns),gt=U(l),zl=n(l,"P",{"data-svelte-h":!0}),T(zl)!=="svelte-15hdrrv"&&(zl.innerHTML=Fs),dt=U(l),ht=n(l,"HR",{}),ft=U(l),ql=n(l,"P",{"data-svelte-h":!0}),T(ql)!=="svelte-zrixdg"&&(ql.innerHTML=Zs),bt=U(l),i(Ll.$$.fragment,l),Vt=U(l),Pl=n(l,"UL",{"data-svelte-h":!0}),T(Pl)!=="svelte-1dvfmxx"&&(Pl.innerHTML=Gs),Bt=U(l),i(Ol.$$.fragment,l),kt=U(l),Dl=n(l,"P",{}),Zt(Dl).forEach(t),this.h()},h(){I(r,"name","hf:doc:metadata"),I(r,"content",Ps),Ft(X.src,zt="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/smolagents/alfred-party.jpg")||I(X,"src",zt),I(X,"alt","Alfred 派对"),Ft(K.src,Ot="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/smolagents/alfred-playlist.jpg")||I(K,"src",Ot),I(K,"alt","Alfred 播放列表"),Ft(nl.src,ts="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/smolagents/alfred-menu.jpg")||I(nl,"src",ts),I(nl,"alt","Alfred 菜单"),Ft(d.src,Is="https://sergiopaniego-alfredagent.hf.space/")||I(d,"src",Is),I(d,"frameborder","0"),I(d,"width","850"),I(d,"height","450")},m(l,e){xs(document.head,r),s(l,a,e),s(l,m,e),s(l,u,e),p(c,l,e),s(l,g,e),p(k,l,e),s(l,ee,e),s(l,N,e),s(l,te,e),s(l,F,e),s(l,se,e),s(l,Z,e),s(l,Je,e),p(b,l,e),s(l,Ue,e),p(G,l,e),s(l,Me,e),s(l,v,e),s(l,ne,e),s(l,E,e),s(l,Te,e),s(l,$,e),s(l,ae,e),s(l,W,e),s(l,ye,e),p(A,l,e),s(l,ie,e),s(l,Q,e),s(l,pe,e),s(l,R,e),s(l,we,e),s(l,S,e),s(l,oe,e),s(l,H,e),s(l,Ce,e),s(l,x,e),s(l,ce,e),p(_,l,e),s(l,re,e),p(V,l,e),s(l,Ie,e),s(l,Y,e),s(l,ue,e),s(l,X,e),s(l,me,e),s(l,z,e),s(l,je,e),p(q,l,e),s(l,ge,e),s(l,L,e),s(l,de,e),p(P,l,e),s(l,he,e),p(O,l,e),s(l,fe,e),s(l,D,e),s(l,be,e),s(l,K,e),s(l,Ve,e),s(l,ll,e),s(l,Be,e),s(l,el,e),s(l,ke,e),p(tl,l,e),s(l,Ne,e),s(l,sl,e),s(l,Fe,e),p(Jl,l,e),s(l,Ze,e),s(l,Ul,e),s(l,Ge,e),p(Ml,l,e),s(l,ve,e),s(l,nl,e),s(l,Ee,e),s(l,Tl,e),s(l,$e,e),s(l,al,e),s(l,We,e),p(yl,l,e),s(l,Ae,e),s(l,il,e),s(l,Qe,e),s(l,pl,e),s(l,Re,e),p(wl,l,e),s(l,Se,e),s(l,ol,e),s(l,He,e),s(l,Cl,e),s(l,xe,e),s(l,cl,e),s(l,_e,e),s(l,rl,e),s(l,Ye,e),p(Il,l,e),s(l,Xe,e),s(l,ul,e),s(l,ze,e),s(l,ml,e),s(l,qe,e),p(jl,l,e),s(l,Le,e),s(l,gl,e),s(l,Pe,e),s(l,dl,e),s(l,Oe,e),p(hl,l,e),s(l,De,e),s(l,fl,e),s(l,Ke,e),p(bl,l,e),s(l,lt,e),s(l,Vl,e),s(l,et,e),s(l,Bl,e),s(l,tt,e),s(l,d,e),s(l,st,e),s(l,kl,e),s(l,Jt,e),p(Nl,l,e),s(l,Ut,e),s(l,Fl,e),s(l,Mt,e),s(l,Zl,e),s(l,nt,e),p(B,l,e),s(l,Tt,e),p(Gl,l,e),s(l,at,e),s(l,vl,e),s(l,yt,e),s(l,El,e),s(l,it,e),s(l,$l,e),s(l,pt,e),s(l,Wl,e),s(l,wt,e),p(Al,l,e),s(l,ot,e),s(l,Ql,e),s(l,Ct,e),s(l,Rl,e),s(l,ct,e),p(Sl,l,e),s(l,rt,e),s(l,Hl,e),s(l,It,e),p(xl,l,e),s(l,ut,e),s(l,_l,e),s(l,mt,e),p(Yl,l,e),s(l,jt,e),s(l,Xl,e),s(l,gt,e),s(l,zl,e),s(l,dt,e),s(l,ht,e),s(l,ft,e),s(l,ql,e),s(l,bt,e),p(Ll,l,e),s(l,Vt,e),s(l,Pl,e),s(l,Bt,e),p(Ol,l,e),s(l,kt,e),s(l,Dl,e),Nt=!0},p(l,[e]){const vs={};e&2&&(vs.$$scope={dirty:e,ctx:l}),b.$set(vs);const Es={};e&2&&(Es.$$scope={dirty:e,ctx:l}),V.$set(Es);const $s={};e&2&&($s.$$scope={dirty:e,ctx:l}),B.$set($s)},i(l){Nt||(w(c.$$.fragment,l),w(k.$$.fragment,l),w(b.$$.fragment,l),w(G.$$.fragment,l),w(A.$$.fragment,l),w(_.$$.fragment,l),w(V.$$.fragment,l),w(q.$$.fragment,l),w(P.$$.fragment,l),w(O.$$.fragment,l),w(tl.$$.fragment,l),w(Jl.$$.fragment,l),w(Ml.$$.fragment,l),w(yl.$$.fragment,l),w(wl.$$.fragment,l),w(Il.$$.fragment,l),w(jl.$$.fragment,l),w(hl.$$.fragment,l),w(bl.$$.fragment,l),w(Nl.$$.fragment,l),w(B.$$.fragment,l),w(Gl.$$.fragment,l),w(Al.$$.fragment,l),w(Sl.$$.fragment,l),w(xl.$$.fragment,l),w(Yl.$$.fragment,l),w(Ll.$$.fragment,l),w(Ol.$$.fragment,l),Nt=!0)},o(l){o(c.$$.fragment,l),o(k.$$.fragment,l),o(b.$$.fragment,l),o(G.$$.fragment,l),o(A.$$.fragment,l),o(_.$$.fragment,l),o(V.$$.fragment,l),o(q.$$.fragment,l),o(P.$$.fragment,l),o(O.$$.fragment,l),o(tl.$$.fragment,l),o(Jl.$$.fragment,l),o(Ml.$$.fragment,l),o(yl.$$.fragment,l),o(wl.$$.fragment,l),o(Il.$$.fragment,l),o(jl.$$.fragment,l),o(hl.$$.fragment,l),o(bl.$$.fragment,l),o(Nl.$$.fragment,l),o(B.$$.fragment,l),o(Gl.$$.fragment,l),o(Al.$$.fragment,l),o(Sl.$$.fragment,l),o(xl.$$.fragment,l),o(Yl.$$.fragment,l),o(Ll.$$.fragment,l),o(Ol.$$.fragment,l),Nt=!1},d(l){l&&(t(a),t(m),t(u),t(g),t(ee),t(N),t(te),t(F),t(se),t(Z),t(Je),t(Ue),t(Me),t(v),t(ne),t(E),t(Te),t($),t(ae),t(W),t(ye),t(ie),t(Q),t(pe),t(R),t(we),t(S),t(oe),t(H),t(Ce),t(x),t(ce),t(re),t(Ie),t(Y),t(ue),t(X),t(me),t(z),t(je),t(ge),t(L),t(de),t(he),t(fe),t(D),t(be),t(K),t(Ve),t(ll),t(Be),t(el),t(ke),t(Ne),t(sl),t(Fe),t(Ze),t(Ul),t(Ge),t(ve),t(nl),t(Ee),t(Tl),t($e),t(al),t(We),t(Ae),t(il),t(Qe),t(pl),t(Re),t(Se),t(ol),t(He),t(Cl),t(xe),t(cl),t(_e),t(rl),t(Ye),t(Xe),t(ul),t(ze),t(ml),t(qe),t(Le),t(gl),t(Pe),t(dl),t(Oe),t(De),t(fl),t(Ke),t(lt),t(Vl),t(et),t(Bl),t(tt),t(d),t(st),t(kl),t(Jt),t(Ut),t(Fl),t(Mt),t(Zl),t(nt),t(Tt),t(at),t(vl),t(yt),t(El),t(it),t($l),t(pt),t(Wl),t(wt),t(ot),t(Ql),t(Ct),t(Rl),t(ct),t(rt),t(Hl),t(It),t(ut),t(_l),t(mt),t(jt),t(Xl),t(gt),t(zl),t(dt),t(ht),t(ft),t(ql),t(bt),t(Vt),t(Pl),t(Bt),t(kt),t(Dl)),t(r),C(c,l),C(k,l),C(b,l),C(G,l),C(A,l),C(_,l),C(V,l),C(q,l),C(P,l),C(O,l),C(tl,l),C(Jl,l),C(Ml,l),C(yl,l),C(wl,l),C(Il,l),C(jl,l),C(hl,l),C(bl,l),C(Nl,l),C(B,l),C(Gl,l),C(Al,l),C(Sl,l),C(xl,l),C(Yl,l),C(Ll,l),C(Ol,l)}}}const Ps='{"title":"构建使用代码的智能体","local":"构建使用代码的智能体","sections":[{"title":"为什么选择代码智能体？","local":"为什么选择代码智能体","sections":[],"depth":2},{"title":"代码智能体如何工作？","local":"代码智能体如何工作","sections":[],"depth":2},{"title":"让我们看一些例子","local":"让我们看一些例子","sections":[{"title":"使用 smolagents 为派对选择播放列表","local":"使用-smolagents-为派对选择播放列表","sections":[],"depth":3},{"title":"使用自定义工具准备菜单","local":"使用自定义工具准备菜单","sections":[],"depth":3},{"title":"在智能体内部使用 Python 导入","local":"在智能体内部使用-python-导入","sections":[],"depth":3},{"title":"将我们的自定义派对准备智能体分享到 Hub","local":"将我们的自定义派对准备智能体分享到-hub","sections":[],"depth":3},{"title":"使用 OpenTelemetry 和 Langfuse 检查我们的派对准备智能体 📡","local":"使用-opentelemetry-和-langfuse-检查我们的派对准备智能体-","sections":[],"depth":3}],"depth":2},{"title":"资源","local":"资源","sections":[],"depth":2}],"depth":1}';function Os(f){return Qs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class JJ extends Rs{constructor(r){super(),Ss(this,r,Os,Ls,As,{})}}export{JJ as component};
