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

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

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}}),Ml=new m({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}}),Ul=new h({props:{title:"使用自定义工具准备菜单",local:"使用自定义工具准备菜单",headingTag:"h3"}}),yl=new m({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjB0b29sJTJDJTIwSW5mZXJlbmNlQ2xpZW50TW9kZWwlMEElMEElMjMlMjAlRTYlQTAlQjklRTYlOEQlQUUlRTUlOUMlQkElRTUlOTAlODglRTUlQkIlQkElRTglQUUlQUUlRTglOEYlOUMlRTUlOEQlOTUlRTclOUElODQlRTUlQjclQTUlRTUlODUlQjclMEElNDB0b29sJTBBZGVmJTIwc3VnZ2VzdF9tZW51KG9jY2FzaW9uJTNBJTIwc3RyKSUyMC0lM0UlMjBzdHIlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBTdWdnZXN0cyUyMGElMjBtZW51JTIwYmFzZWQlMjBvbiUyMHRoZSUyMG9jY2FzaW9uLiUwQSUyMCUyMCUyMCUyMEFyZ3MlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvY2Nhc2lvbiUzQSUyMFRoZSUyMHR5cGUlMjBvZiUyMG9jY2FzaW9uJTIwZm9yJTIwdGhlJTIwcGFydHkuJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyJTBBJTIwJTIwJTIwJTIwaWYlMjBvY2Nhc2lvbiUyMCUzRCUzRCUyMCUyMmNhc3VhbCUyMiUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMCUyMlBpenphJTJDJTIwc25hY2tzJTJDJTIwYW5kJTIwZHJpbmtzLiUyMiUwQSUyMCUyMCUyMCUyMGVsaWYlMjBvY2Nhc2lvbiUyMCUzRCUzRCUyMCUyMmZvcm1hbCUyMiUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMCUyMjMtY291cnNlJTIwZGlubmVyJTIwd2l0aCUyMHdpbmUlMjBhbmQlMjBkZXNzZXJ0LiUyMiUwQSUyMCUyMCUyMCUyMGVsaWYlMjBvY2Nhc2lvbiUyMCUzRCUzRCUyMCUyMnN1cGVyaGVybyUyMiUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMCUyMkJ1ZmZldCUyMHdpdGglMjBoaWdoLWVuZXJneSUyMGFuZCUyMGhlYWx0aHklMjBmb29kLiUyMiUwQSUyMCUyMCUyMCUyMGVsc2UlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjAlMjJDdXN0b20lMjBtZW51JTIwZm9yJTIwdGhlJTIwYnV0bGVyLiUyMiUwQSUwQSUyMyUyMCVFNyVBRSVBMSVFNSVBRSVCNiVFOSU5OCVCRiVFNSVCMCU5NCVFNSVCQyU5NyVFOSU5QiVCNyVFNSVCRSVCNyVFRiVCQyU4QyVFNCVCOCVCQSVFNiVCNCVCRSVFNSVBRiVCOSVFNSU4NyU4NiVFNSVBNCU4NyVFOCU4RiU5QyVFNSU4RCU5NSUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCc3VnZ2VzdF9tZW51JTVEJTJDJTIwbW9kZWwlM0RJbmZlcmVuY2VDbGllbnRNb2RlbCgpKSUwQSUwQSUyMyUyMCVFNCVCOCVCQSVFNiVCNCVCRSVFNSVBRiVCOSVFNSU4NyU4NiVFNSVBNCU4NyVFNiVBRCVBMyVFNSVCQyU4RiVFOCU4RiU5QyVFNSU4RCU5NSUwQWFnZW50LnJ1biglMjJQcmVwYXJlJTIwYSUyMGZvcm1hbCUyMG1lbnUlMjBmb3IlMjB0aGUlMjBwYXJ0eS4lMjIp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, tool, InferenceClientModel

<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=InferenceClientModel())

<span class="hljs-comment"># 为派对准备正式菜单</span>
agent.run(<span class="hljs-string">&quot;Prepare a formal menu for the party.&quot;</span>)`,wrap:!1}}),ol=new h({props:{title:"在智能体内部使用 Python 导入",local:"在智能体内部使用-python-导入",headingTag:"h3"}}),rl=new m({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUwQWltcG9ydCUyMG51bXB5JTIwYXMlMjBucCUwQWltcG9ydCUyMHRpbWUlMEFpbXBvcnQlMjBkYXRldGltZSUwQSUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCJTVEJTJDJTIwbW9kZWwlM0RJbmZlcmVuY2VDbGllbnRNb2RlbCgpJTJDJTIwYWRkaXRpb25hbF9hdXRob3JpemVkX2ltcG9ydHMlM0QlNUInZGF0ZXRpbWUnJTVEKSUwQSUwQWFnZW50LnJ1biglMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBBbGZyZWQlMjBuZWVkcyUyMHRvJTIwcHJlcGFyZSUyMGZvciUyMHRoZSUyMHBhcnR5LiUyMEhlcmUlMjBhcmUlMjB0aGUlMjB0YXNrcyUzQSUwQSUyMCUyMCUyMCUyMDEuJTIwUHJlcGFyZSUyMHRoZSUyMGRyaW5rcyUyMC0lMjAzMCUyMG1pbnV0ZXMlMEElMjAlMjAlMjAlMjAyLiUyMERlY29yYXRlJTIwdGhlJTIwbWFuc2lvbiUyMC0lMjA2MCUyMG1pbnV0ZXMlMEElMjAlMjAlMjAlMjAzLiUyMFNldCUyMHVwJTIwdGhlJTIwbWVudSUyMC0lMjA0NSUyMG1pbnV0ZXMlMEElMjAlMjAlMjAlMjAzLiUyMFByZXBhcmUlMjB0aGUlMjBtdXNpYyUyMGFuZCUyMHBsYXlsaXN0JTIwLSUyMDQ1JTIwbWludXRlcyUwQSUwQSUyMCUyMCUyMCUyMElmJTIwd2UlMjBzdGFydCUyMHJpZ2h0JTIwbm93JTJDJTIwYXQlMjB3aGF0JTIwdGltZSUyMHdpbGwlMjB0aGUlMjBwYXJ0eSUyMGJlJTIwcmVhZHklM0YlMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEEp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, InferenceClientModel
<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=InferenceClientModel(), 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}}),Il=new h({props:{title:"将我们的自定义派对准备智能体分享到 Hub",local:"将我们的自定义派对准备智能体分享到-hub",headingTag:"h3"}}),fl=new m({props:{code:"JTIzJTIwJUU2JTlCJUI0JUU2JTk0JUI5JUU0JUI4JUJBJUU0JUJEJUEwJUU3JTlBJTg0JUU3JTk0JUE4JUU2JTg4JUI3JUU1JTkwJThEJUU1JTkyJThDJUU0JUJCJTkzJUU1JUJBJTkzJUU1JTkwJThEJTBBYWdlbnQucHVzaF90b19odWIoJ3Nlcmdpb3BhbmllZ28lMkZBbGZyZWRBZ2VudCcp",highlighted:`<span class="hljs-comment"># 更改为你的用户名和仓库名</span>
agent.push_to_hub(<span class="hljs-string">&#x27;sergiopaniego/AlfredAgent&#x27;</span>)`,wrap:!1}}),Vl=new m({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 m({props:{code:" ",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool, InferenceClientModel, 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=InferenceClientModel(),
    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 St({props:{$$slots:{default:[tM]},$$scope:{ctx:f}}}),Gl=new h({props:{title:"使用 OpenTelemetry 和 Langfuse 检查我们的派对准备智能体 📡",local:"使用-opentelemetry-和-langfuse-检查我们的派对准备智能体-",headingTag:"h3"}}),Sl=new m({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wZW50ZWxlbWV0cnktc2RrJTIwb3BlbnRlbGVtZXRyeS1leHBvcnRlci1vdGxwJTIwb3BlbmluZmVyZW5jZS1pbnN0cnVtZW50YXRpb24tc21vbGFnZW50cyUyMGxhbmdmdXNl",highlighted:"pip install opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-smolagents langfuse",wrap:!1}}),El=new m({props:{code:"aW1wb3J0JTIwb3MlMEElMEElMjMlMjBHZXQlMjBrZXlzJTIwZm9yJTIweW91ciUyMHByb2plY3QlMjBmcm9tJTIwdGhlJTIwcHJvamVjdCUyMHNldHRpbmdzJTIwcGFnZSUzQSUyMGh0dHBzJTNBJTJGJTJGY2xvdWQubGFuZ2Z1c2UuY29tJTBBb3MuZW52aXJvbiU1QiUyMkxBTkdGVVNFX1BVQkxJQ19LRVklMjIlNUQlMjAlM0QlMjAlMjJway1sZi0uLi4lMjIlMjAlMEFvcy5lbnZpcm9uJTVCJTIyTEFOR0ZVU0VfU0VDUkVUX0tFWSUyMiU1RCUyMCUzRCUyMCUyMnNrLWxmLS4uLiUyMiUyMCUwQW9zLmVudmlyb24lNUIlMjJMQU5HRlVTRV9IT1NUJTIyJTVEJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZjbG91ZC5sYW5nZnVzZS5jb20lMjIlMjAlMjMlMjAlRjAlOUYlODclQUElRjAlOUYlODclQkElMjBFVSUyMHJlZ2lvbiUwQSUyMyUyMG9zLmVudmlyb24lNUIlMjJMQU5HRlVTRV9IT1NUJTIyJTVEJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZ1cy5jbG91ZC5sYW5nZnVzZS5jb20lMjIlMjAlMjMlMjAlRjAlOUYlODclQkElRjAlOUYlODclQjglMjBVUyUyMHJlZ2lvbg==",highlighted:`<span class="hljs-keyword">import</span> os

<span class="hljs-comment"># Get keys for your project from the project settings page: https://cloud.langfuse.com</span>
os.environ[<span class="hljs-string">&quot;LANGFUSE_PUBLIC_KEY&quot;</span>] = <span class="hljs-string">&quot;pk-lf-...&quot;</span> 
os.environ[<span class="hljs-string">&quot;LANGFUSE_SECRET_KEY&quot;</span>] = <span class="hljs-string">&quot;sk-lf-...&quot;</span> 
os.environ[<span class="hljs-string">&quot;LANGFUSE_HOST&quot;</span>] = <span class="hljs-string">&quot;https://cloud.langfuse.com&quot;</span> <span class="hljs-comment"># 🇪🇺 EU region</span>
<span class="hljs-comment"># os.environ[&quot;LANGFUSE_HOST&quot;] = &quot;https://us.cloud.langfuse.com&quot; # 🇺🇸 US region</span>`,wrap:!1}}),_l=new m({props:{code:"ZnJvbSUyMGxhbmdmdXNlJTIwaW1wb3J0JTIwZ2V0X2NsaWVudCUwQSUyMCUwQWxhbmdmdXNlJTIwJTNEJTIwZ2V0X2NsaWVudCgpJTBBJTIwJTBBJTIzJTIwVmVyaWZ5JTIwY29ubmVjdGlvbiUwQWlmJTIwbGFuZ2Z1c2UuYXV0aF9jaGVjaygpJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQoJTIyTGFuZ2Z1c2UlMjBjbGllbnQlMjBpcyUyMGF1dGhlbnRpY2F0ZWQlMjBhbmQlMjByZWFkeSElMjIpJTBBZWxzZSUzQSUwQSUyMCUyMCUyMCUyMHByaW50KCUyMkF1dGhlbnRpY2F0aW9uJTIwZmFpbGVkLiUyMFBsZWFzZSUyMGNoZWNrJTIweW91ciUyMGNyZWRlbnRpYWxzJTIwYW5kJTIwaG9zdC4lMjIp",highlighted:`<span class="hljs-keyword">from</span> langfuse <span class="hljs-keyword">import</span> get_client
 
langfuse = get_client()
 
<span class="hljs-comment"># Verify connection</span>
<span class="hljs-keyword">if</span> langfuse.auth_check():
    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Langfuse client is authenticated and ready!&quot;</span>)
<span class="hljs-keyword">else</span>:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Authentication failed. Please check your credentials and host.&quot;</span>)`,wrap:!1}}),ql=new m({props:{code:"ZnJvbSUyMG9wZW5pbmZlcmVuY2UuaW5zdHJ1bWVudGF0aW9uLnNtb2xhZ2VudHMlMjBpbXBvcnQlMjBTbW9sYWdlbnRzSW5zdHJ1bWVudG9yJTBBJTBBU21vbGFnZW50c0luc3RydW1lbnRvcigpLmluc3RydW1lbnQoKQ==",highlighted:`<span class="hljs-keyword">from</span> openinference.instrumentation.smolagents <span class="hljs-keyword">import</span> SmolagentsInstrumentor

SmolagentsInstrumentor().instrument()`,wrap:!1}}),zl=new m({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUwQSUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCJTVEJTJDJTIwbW9kZWwlM0RJbmZlcmVuY2VDbGllbnRNb2RlbCgpKSUwQWFsZnJlZF9hZ2VudCUyMCUzRCUyMGFnZW50LmZyb21faHViKCdzZXJnaW9wYW5pZWdvJTJGQWxmcmVkQWdlbnQnJTJDJTIwdHJ1c3RfcmVtb3RlX2NvZGUlM0RUcnVlKSUwQWFsZnJlZF9hZ2VudC5ydW4oJTIyR2l2ZSUyMG1lJTIwdGhlJTIwYmVzdCUyMHBsYXlsaXN0JTIwZm9yJTIwYSUyMHBhcnR5JTIwYXQlMjBXYXluZSdzJTIwbWFuc2lvbi4lMjBUaGUlMjBwYXJ0eSUyMGlkZWElMjBpcyUyMGElMjAndmlsbGFpbiUyMG1hc3F1ZXJhZGUnJTIwdGhlbWUlMjIpJTIwJTIw",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, InferenceClientModel

agent = CodeAgent(tools=[], model=InferenceClientModel())
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}}),Dl=new h({props:{title:"资源",local:"资源",headingTag:"h2"}}),le=new Ks({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/zh-CN/unit2/smolagents/code_agents.mdx"}}),{c(){j=U("meta"),T=M(),g=U("p"),r=M(),y(c.$$.fragment),I=M(),y(k.$$.fragment),Me=M(),Z=U("p"),Z.innerHTML=Ht,ne=M(),N=U("p"),N.innerHTML=Rt,Ue=M(),A=U("p"),A.innerHTML=Et,Je=M(),y(b.$$.fragment),ae=M(),y(v.$$.fragment),Te=M(),G=U("p"),G.innerHTML=xt,ye=M(),F=U("p"),F.innerHTML=_t,ie=M(),Q=U("p"),Q.textContent=Yt,pe=M(),$=U("ul"),$.innerHTML=qt,oe=M(),y(W.$$.fragment),we=M(),S=U("p"),S.innerHTML=Xt,Ce=M(),H=U("p"),H.innerHTML=zt,ce=M(),R=U("p"),R.innerHTML=Lt,je=M(),E=U("ol"),E.innerHTML=Pt,ue=M(),x=U("p"),x.innerHTML=Ot,re=M(),y(_.$$.fragment),me=M(),y(V.$$.fragment),ge=M(),Y=U("p"),Y.innerHTML=Dt,Ie=M(),q=U("img"),de=M(),X=U("p"),X.innerHTML=ls,he=M(),y(z.$$.fragment),fe=M(),L=U("p"),L.textContent=es,be=M(),y(P.$$.fragment),Ve=M(),y(O.$$.fragment),Be=M(),D=U("p"),D.innerHTML=ts,ke=M(),K=U("img"),Ze=M(),ll=U("p"),ll.innerHTML=Ms,Ne=M(),el=U("p"),el.textContent=ns,Ae=M(),y(tl.$$.fragment),ve=M(),sl=U("p"),sl.innerHTML=Us,Ge=M(),y(Ml.$$.fragment),Fe=M(),nl=U("p"),nl.textContent=Js,Qe=M(),y(Ul.$$.fragment),$e=M(),Jl=U("img"),We=M(),al=U("p"),al.innerHTML=Ts,Se=M(),Tl=U("p"),Tl.innerHTML=ys,He=M(),y(yl.$$.fragment),Re=M(),il=U("p"),il.textContent=is,Ee=M(),pl=U("p"),pl.textContent=ps,xe=M(),y(ol.$$.fragment),_e=M(),wl=U("p"),wl.textContent=os,Ye=M(),Cl=U("p"),Cl.textContent=ws,qe=M(),cl=U("p"),cl.innerHTML=Cs,Xe=M(),jl=U("p"),jl.innerHTML=cs,ze=M(),ul=U("p"),ul.innerHTML=js,Le=M(),y(rl.$$.fragment),Pe=M(),ml=U("p"),ml.innerHTML=us,Oe=M(),gl=U("p"),gl.innerHTML=rs,De=M(),y(Il.$$.fragment),Ke=M(),dl=U("p"),dl.innerHTML=ms,lt=M(),hl=U("p"),hl.innerHTML=gs,et=M(),y(fl.$$.fragment),tt=M(),bl=U("p"),bl.textContent=Is,st=M(),y(Vl.$$.fragment),Mt=M(),Bl=U("p"),Bl.innerHTML=ds,nt=M(),kl=U("p"),kl.innerHTML=hs,Ut=M(),d=U("iframe"),Jt=M(),Zl=U("p"),Zl.innerHTML=bs,at=M(),y(Nl.$$.fragment),Tt=M(),Al=U("p"),Al.innerHTML=Vs,yt=M(),vl=U("p"),vl.textContent=Bs,it=M(),y(B.$$.fragment),pt=M(),y(Gl.$$.fragment),ot=M(),Fl=U("p"),Fl.textContent=ks,wt=M(),Ql=U("p"),Ql.innerHTML=Zs,Ct=M(),$l=U("p"),$l.textContent=Ns,ct=M(),Wl=U("p"),Wl.textContent=As,jt=M(),y(Sl.$$.fragment),ut=M(),Hl=U("p"),Hl.innerHTML=vs,rt=M(),Rl=U("p"),Rl.textContent=Gs,mt=M(),y(El.$$.fragment),gt=M(),xl=U("p"),xl.textContent=Fs,It=M(),y(_l.$$.fragment),dt=M(),Yl=U("p"),Yl.innerHTML=Qs,ht=M(),y(ql.$$.fragment),ft=M(),Xl=U("p"),Xl.innerHTML=$s,bt=M(),y(zl.$$.fragment),Vt=M(),Ll=U("p"),Ll.innerHTML=Ws,Bt=M(),Pl=U("p"),Pl.innerHTML=Ss,kt=M(),Zt=U("hr"),Nt=M(),Ol=U("p"),Ol.innerHTML=Hs,At=M(),y(Dl.$$.fragment),vt=M(),Kl=U("ul"),Kl.innerHTML=Rs,Gt=M(),y(le.$$.fragment),Ft=M(),ee=U("p"),this.h()},l(l){const e=Ps("svelte-u9bgzb",document.head);j=J(e,"META",{name:!0,content:!0}),e.forEach(t),T=n(l),g=J(l,"P",{}),Wt(g).forEach(t),r=n(l),i(c.$$.fragment,l),I=n(l),i(k.$$.fragment,l),Me=n(l),Z=J(l,"P",{"data-svelte-h":!0}),a(Z)!=="svelte-9ymf39"&&(Z.innerHTML=Ht),ne=n(l),N=J(l,"P",{"data-svelte-h":!0}),a(N)!=="svelte-fp3c5i"&&(N.innerHTML=Rt),Ue=n(l),A=J(l,"P",{"data-svelte-h":!0}),a(A)!=="svelte-1fe7zeb"&&(A.innerHTML=Et),Je=n(l),i(b.$$.fragment,l),ae=n(l),i(v.$$.fragment,l),Te=n(l),G=J(l,"P",{"data-svelte-h":!0}),a(G)!=="svelte-l5zfvz"&&(G.innerHTML=xt),ye=n(l),F=J(l,"P",{"data-svelte-h":!0}),a(F)!=="svelte-hwuo60"&&(F.innerHTML=_t),ie=n(l),Q=J(l,"P",{"data-svelte-h":!0}),a(Q)!=="svelte-7wpd4j"&&(Q.textContent=Yt),pe=n(l),$=J(l,"UL",{"data-svelte-h":!0}),a($)!=="svelte-1o5j9s7"&&($.innerHTML=qt),oe=n(l),i(W.$$.fragment,l),we=n(l),S=J(l,"P",{"data-svelte-h":!0}),a(S)!=="svelte-11zkmfo"&&(S.innerHTML=Xt),Ce=n(l),H=J(l,"P",{"data-svelte-h":!0}),a(H)!=="svelte-19v0aru"&&(H.innerHTML=zt),ce=n(l),R=J(l,"P",{"data-svelte-h":!0}),a(R)!=="svelte-1y2sq4s"&&(R.innerHTML=Lt),je=n(l),E=J(l,"OL",{"data-svelte-h":!0}),a(E)!=="svelte-zvc6d4"&&(E.innerHTML=Pt),ue=n(l),x=J(l,"P",{"data-svelte-h":!0}),a(x)!=="svelte-1iis6f"&&(x.innerHTML=Ot),re=n(l),i(_.$$.fragment,l),me=n(l),i(V.$$.fragment,l),ge=n(l),Y=J(l,"P",{"data-svelte-h":!0}),a(Y)!=="svelte-1n6vc7y"&&(Y.innerHTML=Dt),Ie=n(l),q=J(l,"IMG",{src:!0,alt:!0}),de=n(l),X=J(l,"P",{"data-svelte-h":!0}),a(X)!=="svelte-utbpgy"&&(X.innerHTML=ls),he=n(l),i(z.$$.fragment,l),fe=n(l),L=J(l,"P",{"data-svelte-h":!0}),a(L)!=="svelte-1db12br"&&(L.textContent=es),be=n(l),i(P.$$.fragment,l),Ve=n(l),i(O.$$.fragment,l),Be=n(l),D=J(l,"P",{"data-svelte-h":!0}),a(D)!=="svelte-12eqykj"&&(D.innerHTML=ts),ke=n(l),K=J(l,"IMG",{src:!0,alt:!0}),Ze=n(l),ll=J(l,"P",{"data-svelte-h":!0}),a(ll)!=="svelte-w6dexj"&&(ll.innerHTML=Ms),Ne=n(l),el=J(l,"P",{"data-svelte-h":!0}),a(el)!=="svelte-wei6ii"&&(el.textContent=ns),Ae=n(l),i(tl.$$.fragment,l),ve=n(l),sl=J(l,"P",{"data-svelte-h":!0}),a(sl)!=="svelte-1fgov2e"&&(sl.innerHTML=Us),Ge=n(l),i(Ml.$$.fragment,l),Fe=n(l),nl=J(l,"P",{"data-svelte-h":!0}),a(nl)!=="svelte-1tb9ak8"&&(nl.textContent=Js),Qe=n(l),i(Ul.$$.fragment,l),$e=n(l),Jl=J(l,"IMG",{src:!0,alt:!0}),We=n(l),al=J(l,"P",{"data-svelte-h":!0}),a(al)!=="svelte-v2hosz"&&(al.innerHTML=Ts),Se=n(l),Tl=J(l,"P",{"data-svelte-h":!0}),a(Tl)!=="svelte-1ypx3hb"&&(Tl.innerHTML=ys),He=n(l),i(yl.$$.fragment,l),Re=n(l),il=J(l,"P",{"data-svelte-h":!0}),a(il)!=="svelte-a8jfmd"&&(il.textContent=is),Ee=n(l),pl=J(l,"P",{"data-svelte-h":!0}),a(pl)!=="svelte-g3pzw9"&&(pl.textContent=ps),xe=n(l),i(ol.$$.fragment,l),_e=n(l),wl=J(l,"P",{"data-svelte-h":!0}),a(wl)!=="svelte-15uzzdb"&&(wl.textContent=os),Ye=n(l),Cl=J(l,"P",{"data-svelte-h":!0}),a(Cl)!=="svelte-1c12mmu"&&(Cl.textContent=ws),qe=n(l),cl=J(l,"P",{"data-svelte-h":!0}),a(cl)!=="svelte-1glgfrs"&&(cl.innerHTML=Cs),Xe=n(l),jl=J(l,"P",{"data-svelte-h":!0}),a(jl)!=="svelte-1ugdcvu"&&(jl.innerHTML=cs),ze=n(l),ul=J(l,"P",{"data-svelte-h":!0}),a(ul)!=="svelte-1w0bcf1"&&(ul.innerHTML=js),Le=n(l),i(rl.$$.fragment,l),Pe=n(l),ml=J(l,"P",{"data-svelte-h":!0}),a(ml)!=="svelte-nmbtz8"&&(ml.innerHTML=us),Oe=n(l),gl=J(l,"P",{"data-svelte-h":!0}),a(gl)!=="svelte-1m8jf34"&&(gl.innerHTML=rs),De=n(l),i(Il.$$.fragment,l),Ke=n(l),dl=J(l,"P",{"data-svelte-h":!0}),a(dl)!=="svelte-qdl6e5"&&(dl.innerHTML=ms),lt=n(l),hl=J(l,"P",{"data-svelte-h":!0}),a(hl)!=="svelte-lx3ox3"&&(hl.innerHTML=gs),et=n(l),i(fl.$$.fragment,l),tt=n(l),bl=J(l,"P",{"data-svelte-h":!0}),a(bl)!=="svelte-gf9unb"&&(bl.textContent=Is),st=n(l),i(Vl.$$.fragment,l),Mt=n(l),Bl=J(l,"P",{"data-svelte-h":!0}),a(Bl)!=="svelte-1wixttm"&&(Bl.innerHTML=ds),nt=n(l),kl=J(l,"P",{"data-svelte-h":!0}),a(kl)!=="svelte-1oeri7k"&&(kl.innerHTML=hs),Ut=n(l),d=J(l,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),Wt(d).forEach(t),Jt=n(l),Zl=J(l,"P",{"data-svelte-h":!0}),a(Zl)!=="svelte-4djxsr"&&(Zl.innerHTML=bs),at=n(l),i(Nl.$$.fragment,l),Tt=n(l),Al=J(l,"P",{"data-svelte-h":!0}),a(Al)!=="svelte-10guegr"&&(Al.innerHTML=Vs),yt=n(l),vl=J(l,"P",{"data-svelte-h":!0}),a(vl)!=="svelte-1bia4fv"&&(vl.textContent=Bs),it=n(l),i(B.$$.fragment,l),pt=n(l),i(Gl.$$.fragment,l),ot=n(l),Fl=J(l,"P",{"data-svelte-h":!0}),a(Fl)!=="svelte-1dqmr61"&&(Fl.textContent=ks),wt=n(l),Ql=J(l,"P",{"data-svelte-h":!0}),a(Ql)!=="svelte-risard"&&(Ql.innerHTML=Zs),Ct=n(l),$l=J(l,"P",{"data-svelte-h":!0}),a($l)!=="svelte-45pd9s"&&($l.textContent=Ns),ct=n(l),Wl=J(l,"P",{"data-svelte-h":!0}),a(Wl)!=="svelte-1tvhb6o"&&(Wl.textContent=As),jt=n(l),i(Sl.$$.fragment,l),ut=n(l),Hl=J(l,"P",{"data-svelte-h":!0}),a(Hl)!=="svelte-1jcoxv6"&&(Hl.innerHTML=vs),rt=n(l),Rl=J(l,"P",{"data-svelte-h":!0}),a(Rl)!=="svelte-bbwrb5"&&(Rl.textContent=Gs),mt=n(l),i(El.$$.fragment,l),gt=n(l),xl=J(l,"P",{"data-svelte-h":!0}),a(xl)!=="svelte-kdnbgz"&&(xl.textContent=Fs),It=n(l),i(_l.$$.fragment,l),dt=n(l),Yl=J(l,"P",{"data-svelte-h":!0}),a(Yl)!=="svelte-s74a79"&&(Yl.innerHTML=Qs),ht=n(l),i(ql.$$.fragment,l),ft=n(l),Xl=J(l,"P",{"data-svelte-h":!0}),a(Xl)!=="svelte-1pnj6yu"&&(Xl.innerHTML=$s),bt=n(l),i(zl.$$.fragment,l),Vt=n(l),Ll=J(l,"P",{"data-svelte-h":!0}),a(Ll)!=="svelte-1rlcqk3"&&(Ll.innerHTML=Ws),Bt=n(l),Pl=J(l,"P",{"data-svelte-h":!0}),a(Pl)!=="svelte-15hdrrv"&&(Pl.innerHTML=Ss),kt=n(l),Zt=J(l,"HR",{}),Nt=n(l),Ol=J(l,"P",{"data-svelte-h":!0}),a(Ol)!=="svelte-zrixdg"&&(Ol.innerHTML=Hs),At=n(l),i(Dl.$$.fragment,l),vt=n(l),Kl=J(l,"UL",{"data-svelte-h":!0}),a(Kl)!=="svelte-1dvfmxx"&&(Kl.innerHTML=Rs),Gt=n(l),i(le.$$.fragment,l),Ft=n(l),ee=J(l,"P",{}),Wt(ee).forEach(t),this.h()},h(){u(j,"name","hf:doc:metadata"),u(j,"content",MM),$t(q.src,Kt="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/smolagents/alfred-party.jpg")||u(q,"src",Kt),u(q,"alt","Alfred 派对"),$t(K.src,ss="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/smolagents/alfred-playlist.jpg")||u(K,"src",ss),u(K,"alt","Alfred 播放列表"),$t(Jl.src,as="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/smolagents/alfred-menu.jpg")||u(Jl,"src",as),u(Jl,"alt","Alfred 菜单"),$t(d.src,fs="https://sergiopaniego-alfredagent.hf.space/")||u(d,"src",fs),u(d,"frameborder","0"),u(d,"width","850"),u(d,"height","450")},m(l,e){Os(document.head,j),s(l,T,e),s(l,g,e),s(l,r,e),p(c,l,e),s(l,I,e),p(k,l,e),s(l,Me,e),s(l,Z,e),s(l,ne,e),s(l,N,e),s(l,Ue,e),s(l,A,e),s(l,Je,e),p(b,l,e),s(l,ae,e),p(v,l,e),s(l,Te,e),s(l,G,e),s(l,ye,e),s(l,F,e),s(l,ie,e),s(l,Q,e),s(l,pe,e),s(l,$,e),s(l,oe,e),p(W,l,e),s(l,we,e),s(l,S,e),s(l,Ce,e),s(l,H,e),s(l,ce,e),s(l,R,e),s(l,je,e),s(l,E,e),s(l,ue,e),s(l,x,e),s(l,re,e),p(_,l,e),s(l,me,e),p(V,l,e),s(l,ge,e),s(l,Y,e),s(l,Ie,e),s(l,q,e),s(l,de,e),s(l,X,e),s(l,he,e),p(z,l,e),s(l,fe,e),s(l,L,e),s(l,be,e),p(P,l,e),s(l,Ve,e),p(O,l,e),s(l,Be,e),s(l,D,e),s(l,ke,e),s(l,K,e),s(l,Ze,e),s(l,ll,e),s(l,Ne,e),s(l,el,e),s(l,Ae,e),p(tl,l,e),s(l,ve,e),s(l,sl,e),s(l,Ge,e),p(Ml,l,e),s(l,Fe,e),s(l,nl,e),s(l,Qe,e),p(Ul,l,e),s(l,$e,e),s(l,Jl,e),s(l,We,e),s(l,al,e),s(l,Se,e),s(l,Tl,e),s(l,He,e),p(yl,l,e),s(l,Re,e),s(l,il,e),s(l,Ee,e),s(l,pl,e),s(l,xe,e),p(ol,l,e),s(l,_e,e),s(l,wl,e),s(l,Ye,e),s(l,Cl,e),s(l,qe,e),s(l,cl,e),s(l,Xe,e),s(l,jl,e),s(l,ze,e),s(l,ul,e),s(l,Le,e),p(rl,l,e),s(l,Pe,e),s(l,ml,e),s(l,Oe,e),s(l,gl,e),s(l,De,e),p(Il,l,e),s(l,Ke,e),s(l,dl,e),s(l,lt,e),s(l,hl,e),s(l,et,e),p(fl,l,e),s(l,tt,e),s(l,bl,e),s(l,st,e),p(Vl,l,e),s(l,Mt,e),s(l,Bl,e),s(l,nt,e),s(l,kl,e),s(l,Ut,e),s(l,d,e),s(l,Jt,e),s(l,Zl,e),s(l,at,e),p(Nl,l,e),s(l,Tt,e),s(l,Al,e),s(l,yt,e),s(l,vl,e),s(l,it,e),p(B,l,e),s(l,pt,e),p(Gl,l,e),s(l,ot,e),s(l,Fl,e),s(l,wt,e),s(l,Ql,e),s(l,Ct,e),s(l,$l,e),s(l,ct,e),s(l,Wl,e),s(l,jt,e),p(Sl,l,e),s(l,ut,e),s(l,Hl,e),s(l,rt,e),s(l,Rl,e),s(l,mt,e),p(El,l,e),s(l,gt,e),s(l,xl,e),s(l,It,e),p(_l,l,e),s(l,dt,e),s(l,Yl,e),s(l,ht,e),p(ql,l,e),s(l,ft,e),s(l,Xl,e),s(l,bt,e),p(zl,l,e),s(l,Vt,e),s(l,Ll,e),s(l,Bt,e),s(l,Pl,e),s(l,kt,e),s(l,Zt,e),s(l,Nt,e),s(l,Ol,e),s(l,At,e),p(Dl,l,e),s(l,vt,e),s(l,Kl,e),s(l,Gt,e),p(le,l,e),s(l,Ft,e),s(l,ee,e),Qt=!0},p(l,[e]){const Es={};e&2&&(Es.$$scope={dirty:e,ctx:l}),b.$set(Es);const xs={};e&2&&(xs.$$scope={dirty:e,ctx:l}),V.$set(xs);const _s={};e&2&&(_s.$$scope={dirty:e,ctx:l}),B.$set(_s)},i(l){Qt||(o(c.$$.fragment,l),o(k.$$.fragment,l),o(b.$$.fragment,l),o(v.$$.fragment,l),o(W.$$.fragment,l),o(_.$$.fragment,l),o(V.$$.fragment,l),o(z.$$.fragment,l),o(P.$$.fragment,l),o(O.$$.fragment,l),o(tl.$$.fragment,l),o(Ml.$$.fragment,l),o(Ul.$$.fragment,l),o(yl.$$.fragment,l),o(ol.$$.fragment,l),o(rl.$$.fragment,l),o(Il.$$.fragment,l),o(fl.$$.fragment,l),o(Vl.$$.fragment,l),o(Nl.$$.fragment,l),o(B.$$.fragment,l),o(Gl.$$.fragment,l),o(Sl.$$.fragment,l),o(El.$$.fragment,l),o(_l.$$.fragment,l),o(ql.$$.fragment,l),o(zl.$$.fragment,l),o(Dl.$$.fragment,l),o(le.$$.fragment,l),Qt=!0)},o(l){w(c.$$.fragment,l),w(k.$$.fragment,l),w(b.$$.fragment,l),w(v.$$.fragment,l),w(W.$$.fragment,l),w(_.$$.fragment,l),w(V.$$.fragment,l),w(z.$$.fragment,l),w(P.$$.fragment,l),w(O.$$.fragment,l),w(tl.$$.fragment,l),w(Ml.$$.fragment,l),w(Ul.$$.fragment,l),w(yl.$$.fragment,l),w(ol.$$.fragment,l),w(rl.$$.fragment,l),w(Il.$$.fragment,l),w(fl.$$.fragment,l),w(Vl.$$.fragment,l),w(Nl.$$.fragment,l),w(B.$$.fragment,l),w(Gl.$$.fragment,l),w(Sl.$$.fragment,l),w(El.$$.fragment,l),w(_l.$$.fragment,l),w(ql.$$.fragment,l),w(zl.$$.fragment,l),w(Dl.$$.fragment,l),w(le.$$.fragment,l),Qt=!1},d(l){l&&(t(T),t(g),t(r),t(I),t(Me),t(Z),t(ne),t(N),t(Ue),t(A),t(Je),t(ae),t(Te),t(G),t(ye),t(F),t(ie),t(Q),t(pe),t($),t(oe),t(we),t(S),t(Ce),t(H),t(ce),t(R),t(je),t(E),t(ue),t(x),t(re),t(me),t(ge),t(Y),t(Ie),t(q),t(de),t(X),t(he),t(fe),t(L),t(be),t(Ve),t(Be),t(D),t(ke),t(K),t(Ze),t(ll),t(Ne),t(el),t(Ae),t(ve),t(sl),t(Ge),t(Fe),t(nl),t(Qe),t($e),t(Jl),t(We),t(al),t(Se),t(Tl),t(He),t(Re),t(il),t(Ee),t(pl),t(xe),t(_e),t(wl),t(Ye),t(Cl),t(qe),t(cl),t(Xe),t(jl),t(ze),t(ul),t(Le),t(Pe),t(ml),t(Oe),t(gl),t(De),t(Ke),t(dl),t(lt),t(hl),t(et),t(tt),t(bl),t(st),t(Mt),t(Bl),t(nt),t(kl),t(Ut),t(d),t(Jt),t(Zl),t(at),t(Tt),t(Al),t(yt),t(vl),t(it),t(pt),t(ot),t(Fl),t(wt),t(Ql),t(Ct),t($l),t(ct),t(Wl),t(jt),t(ut),t(Hl),t(rt),t(Rl),t(mt),t(gt),t(xl),t(It),t(dt),t(Yl),t(ht),t(ft),t(Xl),t(bt),t(Vt),t(Ll),t(Bt),t(Pl),t(kt),t(Zt),t(Nt),t(Ol),t(At),t(vt),t(Kl),t(Gt),t(Ft),t(ee)),t(j),C(c,l),C(k,l),C(b,l),C(v,l),C(W,l),C(_,l),C(V,l),C(z,l),C(P,l),C(O,l),C(tl,l),C(Ml,l),C(Ul,l),C(yl,l),C(ol,l),C(rl,l),C(Il,l),C(fl,l),C(Vl,l),C(Nl,l),C(B,l),C(Gl,l),C(Sl,l),C(El,l),C(_l,l),C(ql,l),C(zl,l),C(Dl,l),C(le,l)}}}const MM='{"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 nM(f){return Xs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class oM extends zs{constructor(j){super(),Ls(this,j,nM,sM,qs,{})}}export{oM as component};
