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

login()`,wrap:!1}}),q=new u({props:{title:"使用 smolagents 为派对选择播放列表",local:"使用-smolagents-为派对选择播放列表",headingTag:"h3"}}),P=new c({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}}),K=new c({props:{code:"JTIwJUUyJTk0JTgwJTIwRXhlY3V0aW5nJTIwcGFyc2VkJTIwY29kZSUzQSUyMCVFMi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gwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJUUyJTk0JTgwJTIw",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}}),el=new u({props:{title:"使用自定义工具准备菜单",local:"使用自定义工具准备菜单",headingTag:"h3"}}),nl=new c({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjB0b29sJTJDJTIwSW5mZXJlbmNlQ2xpZW50TW9kZWwlMEElMEElMjMlMjAlRTYlQTAlQjklRTYlOEQlQUUlRTUlOUMlQkElRTUlOTAlODglRTUlQkIlQkElRTglQUUlQUUlRTglOEYlOUMlRTUlOEQlOTUlRTclOUElODQlRTUlQjclQTUlRTUlODUlQjclMEElNDB0b29sJTBBZGVmJTIwc3VnZ2VzdF9tZW51KG9jY2FzaW9uJTNBJTIwc3RyKSUyMC0lM0UlMjBzdHIlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBTdWdnZXN0cyUyMGElMjBtZW51JTIwYmFzZWQlMjBvbiUyMHRoZSUyMG9jY2FzaW9uLiUwQSUyMCUyMCUyMCUyMEFyZ3MlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvY2Nhc2lvbiUzQSUyMFRoZSUyMHR5cGUlMjBvZiUyMG9jY2FzaW9uJTIwZm9yJTIwdGhlJTIwcGFydHkuJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyJTBBJTIwJTIwJTIwJTIwaWYlMjBvY2Nhc2lvbiUyMCUzRCUzRCUyMCUyMmNhc3VhbCUyMiUzQSUw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QyU4RiVFOCU4RiU5QyVFNSU4RCU5NSUwQWFnZW50LnJ1biglMjJQcmVwYXJlJTIwYSUyMGZvcm1hbCUyMG1lbnUlMjBmb3IlMjB0aGUlMjBwYXJ0eS4lMjIp",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}}),al=new u({props:{title:"在智能体内部使用 Python 导入",local:"在智能体内部使用-python-导入",headingTag:"h3"}}),wl=new c({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjB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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}}),jl=new u({props:{title:"将我们的自定义派对准备智能体分享到 Hub",local:"将我们的自定义派对准备智能体分享到-hub",headingTag:"h3"}}),ml=new c({props:{code:"JTIzJTIwJUU2JTlCJUI0JUU2JTk0JUI5JUU0JUI4JUJBJUU0JUJEJUEwJUU3JTlBJTg0JUU3JTk0JUE4JUU2JTg4JUI3JUU1JTkwJThEJUU1JTkyJThDJUU0JUJCJTkzJUU1JUJBJTkzJUU1JTkwJThEJTBBYWdlbnQucHVzaF90b19odWIoJ3Nlcmdpb3BhbmllZ28lMkZBbGZyZWRBZ2VudCcp",highlighted:`<span class="hljs-comment"># 更改为你的用户名和仓库名</span>
agent.push_to_hub(<span class="hljs-string">&#x27;sergiopaniego/AlfredAgent&#x27;</span>)`,wrap:!1}}),Il=new c({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}}),bl=new c({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}}),kl=new u({props:{title:"使用 OpenTelemetry 和 Langfuse 检查我们的派对准备智能体 📡",local:"使用-opentelemetry-和-langfuse-检查我们的派对准备智能体-",headingTag:"h3"}}),Gl=new c({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wZW50ZWxlbWV0cnktc2RrJTIwb3BlbnRlbGVtZXRyeS1leHBvcnRlci1vdGxwJTIwb3BlbmluZmVyZW5jZS1pbnN0cnVtZW50YXRpb24tc21vbGFnZW50cyUyMGxhbmdmdXNl",highlighted:"pip install opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-smolagents langfuse",wrap:!1}}),Wl=new c({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}}),Hl=new c({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}}),Rl=new c({props:{code:"ZnJvbSUyMG9wZW5pbmZlcmVuY2UuaW5zdHJ1bWVudGF0aW9uLnNtb2xhZ2VudHMlMjBpbXBvcnQlMjBTbW9sYWdlbnRzSW5zdHJ1bWVudG9yJTBBJTBBU21vbGFnZW50c0luc3RydW1lbnRvcigpLmluc3RydW1lbnQoKQ==",highlighted:`<span class="hljs-keyword">from</span> openinference.instrumentation.smolagents <span class="hljs-keyword">import</span> SmolagentsInstrumentor

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