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

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