import{s as fe,n as be,o as he}from"../chunks/scheduler.1f027d5a.js";import{S as ge,i as Be,e as s,s as T,c as a,h as ke,a as n,d as J,b as w,f as ce,g as M,j as I,k as je,l as $e,m as l,n as p,t as U,o as i,p as y}from"../chunks/index.6117a65d.js";import{C as Se}from"../chunks/CopyLLMTxtMenu.610b106b.js";import{D as _e,C as m}from"../chunks/DocNotebookDropdown.4ae0d470.js";import{H as Yt,E as Ze}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.bd18ae98.js";function ve(qt){let o,wt,lt,st,r,nt,C,It,d,at,u,Dt='<em>作者：<a href="https://huggingface.co/m-ric" rel="nofollow">Aymeric Roucher</a></em>',Mt,c,Pt='<p>本教程属于进阶内容，建议先了解<a href="agents">另一本指南</a>中的概念！</p>',pt,j,Ot="在本笔记本中，我们将构建一个<strong>多智能体网页浏览器：一个多个智能体协作，通过互联网解决问题的智能体系统！</strong>",Ut,f,Kt="它将是一个简单的层级结构，使用 <code>ManagedAgent</code> 对象来封装受管理的网页搜索智能体：",it,b,yt,h,te="让我们开始搭建这个系统。",ot,g,ee='⚡️ 我们的智能体将由 <a href="https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct" rel="nofollow">meta-llama/Meta-Llama-3.1-70B-Instruct</a> 提供支持，使用 <code>HfApiEngine</code> 类，它利用了 HF 的推理 API：推理 API 可以快速、轻松地运行任何操作系统模型。',mt,B,Je="运行以下命令来安装所需的依赖项：",rt,k,Ct,$,le='我们将选择使用由 <a href="https://huggingface.co/Qwen/Qwen2.5-72B-Instruct" rel="nofollow">Qwen/Qwen2.5-72B-Instruct</a> 提供支持的模型，因为它非常强大，并且在 HF API 中可以免费使用。',dt,S,ut,_,ct,Z,Te='对于网页浏览，我们可以直接使用我们现有的 <a href="https://github.com/huggingface/transformers/blob/main/src/transformers/agents/search.py" rel="nofollow"><code>DuckDuckGoSearchTool</code></a> 工具来提供一个类似于 Google 搜索的功能。',jt,v,we=`但是，我们还需要能够查看 <code>DuckDuckGoSearchTool</code> 找到的网页内容。<br/>
为此，我们可以导入库中内建的 <code>VisitWebpageTool</code>，但我们将重新构建这个工具，以便了解它是如何实现的。`,ft,A,se="因此，让我们从零开始，使用 <code>markdownify</code> 创建我们的 <code>VisitWebpageTool</code> 工具。",bt,V,ht,R,ne="好了，现在让我们初始化并测试我们的工具！",gt,L,Bt,E,Ie=`Hugging Face \\- Wikipedia

[Jump to content](#bodyContent)

Main menu

Main menu
move to sidebar
hide

 Navigation
 

* [Main page](/wiki/Main_Page "Visit the main page [z]")
* [Contents](/wiki/Wikipedia:Contents "Guides to browsing Wikipedia")
* [Current events](/wiki/Portal:Current_events "Articles related to current events")
* [Random article](/wiki/Special:Random "Visit a randomly selected article [x]")
* [About Wikipedia](/wiki/Wikipedia:About "Learn about Wikipedia and how it works")
* [Co
`,kt,W,$t,G,ae="现在我们已经拥有了所有的工具 <code>search</code> 和 <code>visit_webpage</code>，可以使用它们来创建网页智能体。",St,x,Me="该选择什么配置呢？",_t,Q,pe="<li>网页浏览是一个单线程任务，不需要并行调用工具，因此使用 JSON 调用工具非常合适。因此，我们选择 <code>ReactJsonAgent</code>。</li> <li>此外，由于有时网页搜索需要浏览多个页面才能找到正确答案，我们更倾向于将 <code>max_iterations</code> 增加到 10。</li>",Zt,H,vt,N,Ue="然后，我们将这个智能体封装到一个 <code>ManagedAgent</code> 中，这样它就可以通过管理员智能体进行调用了。",At,X,Vt,F,ie="最后，我们创建一个管理员智能体，并在初始化时将我们的受管理智能体通过 <code>managed_agents</code> 参数传递给它。",Rt,z,ye="由于这个智能体负责规划和思考，因此高级推理将非常有帮助，所以选择 <code>ReactCodeAgent</code> 是最合适的。",Lt,Y,oe="另外，我们想提一个涉及当前年份的问题：因此，我们需要添加 <code>additional_authorized_imports=[&quot;time&quot;, &quot;datetime&quot;]</code>。",Et,q,Wt,D,me="就这样！现在让我们运行我们的系统！我们选择一个需要进行一些计算的问题",Gt,P,xt,O,re="我们的智能体成功地高效协作，解决了任务！ ✅",Qt,K,Ce="💡 你可以轻松地扩展到更多智能体：一个负责代码执行，一个负责网页搜索，一个负责文件加载……",Ht,tt,de="🤔💭 甚至可以考虑构建更复杂的树状层级结构，一个 CEO 智能体负责管理多个中层经理，每个经理下有多个报告。",Nt,et,ue="我们甚至可以添加更多的中间管理层，每层都有多个日常会议，进行大量敏捷工作和 Scrum 主管，每个新增的组件都会增加足够的摩擦力，确保任务永远无法完成……嗯，等等，不，我们还是坚持我们的简单结构吧。",Xt,Jt,Ft,Tt,zt;return r=new _e({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/cookbook/blob/main/notebooks/zh-CN/multiagent_web_assistant.ipynb"}]}}),C=new Se({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),d=new Yt({props:{title:"让多个智能体在多智能体层级中协作 🤖🤝🤖",local:"让多个智能体在多智能体层级中协作-",headingTag:"h1"}}),b=new m({props:{code:"JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJCLS0tLS0tLS0tLS0tLS0tLSUyQiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QyUyMCVFNyVBRSVBMSVFNyU5MCU4NiVFNSU5MSU5OCVFNiU5OSVCQSVFOCU4MyVCRCVFNCVCRCU5MyUyMCUyMCUyMCUyMCU3QyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyQi0tLS0tLS0tLS0tLS0tLS0lMkIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBfX19fX19fX19fX19fX18lN0NfX19fX19fX19fX19fXyUwQSUyMCUyMCUyMCUy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wJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTIwJTIwJTIwJTIwJTIwJTIwJTJCLS0tLS0tLS0tLS0tLS0tLS0tJTJCJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTIwJTIwJUU3JUJEJTkxJUU5JUExJUI1JUU2JTkwJTlDJUU3JUI0JUEyJUU1JUI3JUE1JUU1JTg1JUI3JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdDJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJUU4JUFFJUJGJUU5JTk3JUFFJUU3JUJEJTkxJUU5JUExJUI1JUU1JUI3JUE1JUU1JTg1JUI3JTIwJTIwJTIwJTdDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJCLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0lMkI=",highlighted:`              +----------------+
              |<span class="hljs-string"> 管理员智能体    </span>|
              +----------------+
                       |<span class="hljs-string">
        _______________</span>|______________
       |<span class="hljs-string">                              </span>|
  代码解释器       +--------------------------------+
       工具         |<span class="hljs-string">         受管理的智能体        </span>|
                     |<span class="hljs-string">      +------------------+      </span>|
                     |<span class="hljs-string">      </span>|<span class="hljs-string"> 网页搜索智能体   </span>|<span class="hljs-string">      </span>|
                     |<span class="hljs-string">      +------------------+      </span>|
                     |<span class="hljs-string">         </span>|<span class="hljs-string">            </span>|<span class="hljs-string">         </span>|
                     |<span class="hljs-string">  网页搜索工具       </span>|<span class="hljs-string">         </span>|
                     |<span class="hljs-string">             访问网页工具   </span>|
                     +--------------------------------+`,wrap:!1}}),k=new m({props:{code:"IXBpcCUyMGluc3RhbGwlMjBtYXJrZG93bmlmeSUyMGR1Y2tkdWNrZ28tc2VhcmNoJTIwJTIydHJhbnNmb3JtZXJzJTVCYWdlbnRzJTVEJTIyJTIwLS11cGdyYWRlJTIwLXE=",highlighted:'!pip install markdownify duckduckgo-search <span class="hljs-string">&quot;transformers[agents]&quot;</span> --upgrade -q',wrap:!1}}),S=new m({props:{code:"bW9kZWwlMjAlM0QlMjAlMjJRd2VuJTJGUXdlbjIuNS03MkItSW5zdHJ1Y3QlMjI=",highlighted:'model = <span class="hljs-string">&quot;Qwen/Qwen2.5-72B-Instruct&quot;</span>',wrap:!1}}),_=new Yt({props:{title:"🔍 创建一个网页搜索工具",local:"-创建一个网页搜索工具",headingTag:"h3"}}),V=new m({props:{code:"aW1wb3J0JTIwcmUlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBtYXJrZG93bmlmeSUyMGltcG9ydCUyMG1hcmtkb3duaWZ5JTIwYXMlMjBtZCUwQWZyb20lMjByZXF1ZXN0cy5leGNlcHRpb25zJTIwaW1wb3J0JTIwUmVxdWVzdEV4Y2VwdGlvbiUwQWZyb20lMjB0cmFuc2Zvcm1lcnMuYWdlbnRzJTIwaW1wb3J0JTIwdG9vbCUwQSUwQSUwQSU0MHRvb2wlMEFkZWYlMjB2aXNpdF93ZWJwYWdl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yMHRoZSUyMEhUTUwlMjBjb250ZW50JTIwdG8lMjBNYXJrZG93biUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1hcmtkb3duX2NvbnRlbnQlMjAlM0QlMjBtZChyZXNwb25zZS50ZXh0KS5zdHJpcCgpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwUmVtb3ZlJTIwbXVsdGlwbGUlMjBsaW5lJTIwYnJlYWtzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWFya2Rvd25fY29udGVudCUyMCUzRCUyMHJlLnN1YihyJTIyJTVDbiU3QjMlMkMlN0QlMjIlMkMlMjAlMjIlNUNuJTVDbiUyMiUyQyUyMG1hcmtkb3duX2NvbnRlbnQpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWFya2Rvd25fY29udGVudCUwQSUwQSUyMCUyMCUyMCUyMGV4Y2VwdCUyMFJlcXVlc3RFeGNlcHRpb24lMjBhcyUyMGUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBmJTIyRXJyb3IlMjBmZXRjaGluZyUyMHRoZSUyMHdlYnBhZ2UlM0ElMjAlN0JzdHIoZSklN0QlMjIlMEElMjAlMjAlMjAlMjBleGNlcHQlMjBFeGNlcHRpb24lMjBhcyUyMGUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBmJTIyQW4lMjB1bmV4cGVjdGVkJTIwZXJyb3IlMjBvY2N1cnJlZCUzQSUyMCU3QnN0cihlKSU3RCUyMg==",highlighted:`<span class="hljs-keyword">import</span> re
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> markdownify <span class="hljs-keyword">import</span> markdownify <span class="hljs-keyword">as</span> md
<span class="hljs-keyword">from</span> requests.exceptions <span class="hljs-keyword">import</span> RequestException
<span class="hljs-keyword">from</span> transformers.agents <span class="hljs-keyword">import</span> tool


<span class="hljs-meta">@tool</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">visit_webpage</span>(<span class="hljs-params">url: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;Visits a webpage at the given URL and returns its content as a markdown string.

    Args:
        url: The URL of the webpage to visit.

    Returns:
        The content of the webpage converted to Markdown, or an error message if the request fails.
    &quot;&quot;&quot;</span>
    <span class="hljs-keyword">try</span>:
        <span class="hljs-comment"># Send a GET request to the URL</span>
        response = requests.get(url)
        response.raise_for_status()  <span class="hljs-comment"># Raise an exception for bad status codes</span>

        <span class="hljs-comment"># Convert the HTML content to Markdown</span>
        markdown_content = md(response.text).strip()

        <span class="hljs-comment"># Remove multiple line breaks</span>
        markdown_content = re.sub(<span class="hljs-string">r&quot;\\n{3,}&quot;</span>, <span class="hljs-string">&quot;\\n\\n&quot;</span>, markdown_content)

        <span class="hljs-keyword">return</span> markdown_content

    <span class="hljs-keyword">except</span> RequestException <span class="hljs-keyword">as</span> e:
        <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;Error fetching the webpage: <span class="hljs-subst">{<span class="hljs-built_in">str</span>(e)}</span>&quot;</span>
    <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
        <span class="hljs-keyword">return</span> <span class="hljs-string">f&quot;An unexpected error occurred: <span class="hljs-subst">{<span class="hljs-built_in">str</span>(e)}</span>&quot;</span>`,wrap:!1}}),L=new m({props:{code:"cHJpbnQodmlzaXRfd2VicGFnZSglMjJodHRwcyUzQSUyRiUyRmVuLndpa2lwZWRpYS5vcmclMkZ3aWtpJTJGSHVnZ2luZ19GYWNlJTIyKSU1QiUzQTUwMCU1RCk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(visit_webpage(<span class="hljs-string">&quot;https://en.wikipedia.org/wiki/Hugging_Face&quot;</span>)[:<span class="hljs-number">500</span>])',wrap:!1}}),W=new Yt({props:{title:"构建我们的多智能体系统 🤖🤝🤖",local:"构建我们的多智能体系统-",headingTag:"h2"}}),H=new m({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5hZ2VudHMlMjBpbXBvcnQlMjAoJTBBJTIwJTIwJTIwJTIwUmVhY3RDb2RlQWdlbnQlMkMlMEElMjAlMjAlMjAlMjBSZWFjdEpzb25BZ2VudCUyQyUwQSUyMCUyMCUyMCUyMEhmQXBpRW5naW5lJTJDJTBBJTIwJTIwJTIwJTIwTWFuYWdlZEFnZW50JTJDJTBBKSUwQWZyb20lMjB0cmFuc2Zvcm1lcnMuYWdlbnRzLnNlYXJjaCUyMGltcG9ydCUyMER1Y2tEdWNrR29TZWFyY2hUb29sJTBBJTBBbGxtX2VuZ2luZSUyMCUzRCUyMEhmQXBpRW5naW5lKG1vZGVsKSUwQSUwQXdlYl9hZ2VudCUyMCUzRCUyMFJlYWN0SnNvbkFnZW50KCUwQSUyMCUyMCUyMCUyMHRvb2xzJTNEJTVCRHVja0R1Y2tHb1NlYXJjaFRvb2woKSUyQyUyMHZpc2l0X3dlYnBhZ2UlNUQlMkMlMEElMjAlMjAlMjAlMjBsbG1fZW5naW5lJTNEbGxtX2VuZ2luZSUyQyUwQSUyMCUyMCUyMCUyMG1heF9pdGVyYXRpb25zJTNEMTAlMkMlMEEp",highlighted:`<span class="hljs-keyword">from</span> transformers.agents <span class="hljs-keyword">import</span> (
    ReactCodeAgent,
    ReactJsonAgent,
    HfApiEngine,
    ManagedAgent,
)
<span class="hljs-keyword">from</span> transformers.agents.search <span class="hljs-keyword">import</span> DuckDuckGoSearchTool

llm_engine = HfApiEngine(model)

web_agent = ReactJsonAgent(
    tools=[DuckDuckGoSearchTool(), visit_webpage],
    llm_engine=llm_engine,
    max_iterations=<span class="hljs-number">10</span>,
)`,wrap:!1}}),X=new m({props:{code:"bWFuYWdlZF93ZWJfYWdlbnQlMjAlM0QlMjBNYW5hZ2VkQWdlbnQoJTBBJTIwJTIwJTIwJTIwYWdlbnQlM0R3ZWJfYWdlbnQlMkMlMEElMjAlMjAlMjAlMjBuYW1lJTNEJTIyc2VhcmNoJTIyJTJDJTBBJTIwJTIwJTIwJTIwZGVzY3JpcHRpb24lM0QlMjJSdW5zJTIwd2ViJTIwc2VhcmNoZXMlMjBmb3IlMjB5b3UuJTIwR2l2ZSUyMGl0JTIweW91ciUyMHF1ZXJ5JTIwYXMlMjBhbiUyMGFyZ3VtZW50LiUyMiUyQyUwQSk=",highlighted:`managed_web_agent = ManagedAgent(
    agent=web_agent,
    name=<span class="hljs-string">&quot;search&quot;</span>,
    description=<span class="hljs-string">&quot;Runs web searches for you. Give it your query as an argument.&quot;</span>,
)`,wrap:!1}}),q=new m({props:{code:"bWFuYWdlcl9hZ2VudCUyMCUzRCUyMFJlYWN0Q29kZUFnZW50KCUwQSUyMCUyMCUyMCUyMHRvb2xzJTNEJTVCJTVEJTJDJTBBJTIwJTIwJTIwJTIwbGxtX2VuZ2luZSUzRGxsbV9lbmdpbmUlMkMlMEElMjAlMjAlMjAlMjBtYW5hZ2VkX2FnZW50cyUzRCU1Qm1hbmFnZWRfd2ViX2FnZW50JTVEJTJDJTBBJTIwJTIwJTIwJTIwYWRkaXRpb25hbF9hdXRob3JpemVkX2ltcG9ydHMlM0QlNUIlMjJ0aW1lJTIyJTJDJTIwJTIyZGF0ZXRpbWUlMjIlNUQlMkMlMEEp",highlighted:`manager_agent = ReactCodeAgent(
    tools=[],
    llm_engine=llm_engine,
    managed_agents=[managed_web_agent],
    additional_authorized_imports=[<span class="hljs-string">&quot;time&quot;</span>, <span class="hljs-string">&quot;datetime&quot;</span>],
)`,wrap:!1}}),P=new m({props:{code:"bWFuYWdlcl9hZ2VudC5ydW4oJTIySG93JTIwbWFueSUyMHllYXJzJTIwYWdvJTIwd2FzJTIwU3RyaXBlJTIwZm91bmRlZCUzRiUyMik=",highlighted:'manager_agent.run(<span class="hljs-string">&quot;How many years ago was Stripe founded?&quot;</span>)',wrap:!1}}),Jt=new Ze({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/zh-CN/multiagent_web_assistant.md"}}),{c(){o=s("meta"),wt=T(),lt=s("p"),st=T(),a(r.$$.fragment),nt=T(),a(C.$$.fragment),It=T(),a(d.$$.fragment),at=T(),u=s("p"),u.innerHTML=Dt,Mt=T(),c=s("blockquote"),c.innerHTML=Pt,pt=T(),j=s("p"),j.innerHTML=Ot,Ut=T(),f=s("p"),f.innerHTML=Kt,it=T(),a(b.$$.fragment),yt=T(),h=s("p"),h.textContent=te,ot=T(),g=s("p"),g.innerHTML=ee,mt=T(),B=s("p"),B.textContent=Je,rt=T(),a(k.$$.fragment),Ct=T(),$=s("p"),$.innerHTML=le,dt=T(),a(S.$$.fragment),ut=T(),a(_.$$.fragment),ct=T(),Z=s("p"),Z.innerHTML=Te,jt=T(),v=s("p"),v.innerHTML=we,ft=T(),A=s("p"),A.innerHTML=se,bt=T(),a(V.$$.fragment),ht=T(),R=s("p"),R.textContent=ne,gt=T(),a(L.$$.fragment),Bt=T(),E=s("pre"),E.textContent=Ie,kt=T(),a(W.$$.fragment),$t=T(),G=s("p"),G.innerHTML=ae,St=T(),x=s("p"),x.textContent=Me,_t=T(),Q=s("ul"),Q.innerHTML=pe,Zt=T(),a(H.$$.fragment),vt=T(),N=s("p"),N.innerHTML=Ue,At=T(),a(X.$$.fragment),Vt=T(),F=s("p"),F.innerHTML=ie,Rt=T(),z=s("p"),z.innerHTML=ye,Lt=T(),Y=s("p"),Y.innerHTML=oe,Et=T(),a(q.$$.fragment),Wt=T(),D=s("p"),D.textContent=me,Gt=T(),a(P.$$.fragment),xt=T(),O=s("p"),O.textContent=re,Qt=T(),K=s("p"),K.textContent=Ce,Ht=T(),tt=s("p"),tt.textContent=de,Nt=T(),et=s("p"),et.textContent=ue,Xt=T(),a(Jt.$$.fragment),Ft=T(),Tt=s("p"),this.h()},l(t){const e=ke("svelte-u9bgzb",document.head);o=n(e,"META",{name:!0,content:!0}),e.forEach(J),wt=w(t),lt=n(t,"P",{}),ce(lt).forEach(J),st=w(t),M(r.$$.fragment,t),nt=w(t),M(C.$$.fragment,t),It=w(t),M(d.$$.fragment,t),at=w(t),u=n(t,"P",{"data-svelte-h":!0}),I(u)!=="svelte-w1hogd"&&(u.innerHTML=Dt),Mt=w(t),c=n(t,"BLOCKQUOTE",{"data-svelte-h":!0}),I(c)!=="svelte-6sxzpj"&&(c.innerHTML=Pt),pt=w(t),j=n(t,"P",{"data-svelte-h":!0}),I(j)!=="svelte-pc1j50"&&(j.innerHTML=Ot),Ut=w(t),f=n(t,"P",{"data-svelte-h":!0}),I(f)!=="svelte-1y2xf6m"&&(f.innerHTML=Kt),it=w(t),M(b.$$.fragment,t),yt=w(t),h=n(t,"P",{"data-svelte-h":!0}),I(h)!=="svelte-1msaor7"&&(h.textContent=te),ot=w(t),g=n(t,"P",{"data-svelte-h":!0}),I(g)!=="svelte-19tzwyu"&&(g.innerHTML=ee),mt=w(t),B=n(t,"P",{"data-svelte-h":!0}),I(B)!=="svelte-1fttkle"&&(B.textContent=Je),rt=w(t),M(k.$$.fragment,t),Ct=w(t),$=n(t,"P",{"data-svelte-h":!0}),I($)!=="svelte-1gsndad"&&($.innerHTML=le),dt=w(t),M(S.$$.fragment,t),ut=w(t),M(_.$$.fragment,t),ct=w(t),Z=n(t,"P",{"data-svelte-h":!0}),I(Z)!=="svelte-q4xqvz"&&(Z.innerHTML=Te),jt=w(t),v=n(t,"P",{"data-svelte-h":!0}),I(v)!=="svelte-1lh8bvv"&&(v.innerHTML=we),ft=w(t),A=n(t,"P",{"data-svelte-h":!0}),I(A)!=="svelte-tauqux"&&(A.innerHTML=se),bt=w(t),M(V.$$.fragment,t),ht=w(t),R=n(t,"P",{"data-svelte-h":!0}),I(R)!=="svelte-bb05j9"&&(R.textContent=ne),gt=w(t),M(L.$$.fragment,t),Bt=w(t),E=n(t,"PRE",{"data-svelte-h":!0}),I(E)!=="svelte-1dfvpav"&&(E.textContent=Ie),kt=w(t),M(W.$$.fragment,t),$t=w(t),G=n(t,"P",{"data-svelte-h":!0}),I(G)!=="svelte-r341rq"&&(G.innerHTML=ae),St=w(t),x=n(t,"P",{"data-svelte-h":!0}),I(x)!=="svelte-1566qf1"&&(x.textContent=Me),_t=w(t),Q=n(t,"UL",{"data-svelte-h":!0}),I(Q)!=="svelte-1rb4eel"&&(Q.innerHTML=pe),Zt=w(t),M(H.$$.fragment,t),vt=w(t),N=n(t,"P",{"data-svelte-h":!0}),I(N)!=="svelte-nxzc92"&&(N.innerHTML=Ue),At=w(t),M(X.$$.fragment,t),Vt=w(t),F=n(t,"P",{"data-svelte-h":!0}),I(F)!=="svelte-pk8g1s"&&(F.innerHTML=ie),Rt=w(t),z=n(t,"P",{"data-svelte-h":!0}),I(z)!=="svelte-16uc2j7"&&(z.innerHTML=ye),Lt=w(t),Y=n(t,"P",{"data-svelte-h":!0}),I(Y)!=="svelte-1lh1i1b"&&(Y.innerHTML=oe),Et=w(t),M(q.$$.fragment,t),Wt=w(t),D=n(t,"P",{"data-svelte-h":!0}),I(D)!=="svelte-tekfny"&&(D.textContent=me),Gt=w(t),M(P.$$.fragment,t),xt=w(t),O=n(t,"P",{"data-svelte-h":!0}),I(O)!=="svelte-vgzsdt"&&(O.textContent=re),Qt=w(t),K=n(t,"P",{"data-svelte-h":!0}),I(K)!=="svelte-1meg492"&&(K.textContent=Ce),Ht=w(t),tt=n(t,"P",{"data-svelte-h":!0}),I(tt)!=="svelte-2ib908"&&(tt.textContent=de),Nt=w(t),et=n(t,"P",{"data-svelte-h":!0}),I(et)!=="svelte-13th9au"&&(et.textContent=ue),Xt=w(t),M(Jt.$$.fragment,t),Ft=w(t),Tt=n(t,"P",{}),ce(Tt).forEach(J),this.h()},h(){je(o,"name","hf:doc:metadata"),je(o,"content",Ae)},m(t,e){$e(document.head,o),l(t,wt,e),l(t,lt,e),l(t,st,e),p(r,t,e),l(t,nt,e),p(C,t,e),l(t,It,e),p(d,t,e),l(t,at,e),l(t,u,e),l(t,Mt,e),l(t,c,e),l(t,pt,e),l(t,j,e),l(t,Ut,e),l(t,f,e),l(t,it,e),p(b,t,e),l(t,yt,e),l(t,h,e),l(t,ot,e),l(t,g,e),l(t,mt,e),l(t,B,e),l(t,rt,e),p(k,t,e),l(t,Ct,e),l(t,$,e),l(t,dt,e),p(S,t,e),l(t,ut,e),p(_,t,e),l(t,ct,e),l(t,Z,e),l(t,jt,e),l(t,v,e),l(t,ft,e),l(t,A,e),l(t,bt,e),p(V,t,e),l(t,ht,e),l(t,R,e),l(t,gt,e),p(L,t,e),l(t,Bt,e),l(t,E,e),l(t,kt,e),p(W,t,e),l(t,$t,e),l(t,G,e),l(t,St,e),l(t,x,e),l(t,_t,e),l(t,Q,e),l(t,Zt,e),p(H,t,e),l(t,vt,e),l(t,N,e),l(t,At,e),p(X,t,e),l(t,Vt,e),l(t,F,e),l(t,Rt,e),l(t,z,e),l(t,Lt,e),l(t,Y,e),l(t,Et,e),p(q,t,e),l(t,Wt,e),l(t,D,e),l(t,Gt,e),p(P,t,e),l(t,xt,e),l(t,O,e),l(t,Qt,e),l(t,K,e),l(t,Ht,e),l(t,tt,e),l(t,Nt,e),l(t,et,e),l(t,Xt,e),p(Jt,t,e),l(t,Ft,e),l(t,Tt,e),zt=!0},p:be,i(t){zt||(U(r.$$.fragment,t),U(C.$$.fragment,t),U(d.$$.fragment,t),U(b.$$.fragment,t),U(k.$$.fragment,t),U(S.$$.fragment,t),U(_.$$.fragment,t),U(V.$$.fragment,t),U(L.$$.fragment,t),U(W.$$.fragment,t),U(H.$$.fragment,t),U(X.$$.fragment,t),U(q.$$.fragment,t),U(P.$$.fragment,t),U(Jt.$$.fragment,t),zt=!0)},o(t){i(r.$$.fragment,t),i(C.$$.fragment,t),i(d.$$.fragment,t),i(b.$$.fragment,t),i(k.$$.fragment,t),i(S.$$.fragment,t),i(_.$$.fragment,t),i(V.$$.fragment,t),i(L.$$.fragment,t),i(W.$$.fragment,t),i(H.$$.fragment,t),i(X.$$.fragment,t),i(q.$$.fragment,t),i(P.$$.fragment,t),i(Jt.$$.fragment,t),zt=!1},d(t){t&&(J(wt),J(lt),J(st),J(nt),J(It),J(at),J(u),J(Mt),J(c),J(pt),J(j),J(Ut),J(f),J(it),J(yt),J(h),J(ot),J(g),J(mt),J(B),J(rt),J(Ct),J($),J(dt),J(ut),J(ct),J(Z),J(jt),J(v),J(ft),J(A),J(bt),J(ht),J(R),J(gt),J(Bt),J(E),J(kt),J($t),J(G),J(St),J(x),J(_t),J(Q),J(Zt),J(vt),J(N),J(At),J(Vt),J(F),J(Rt),J(z),J(Lt),J(Y),J(Et),J(Wt),J(D),J(Gt),J(xt),J(O),J(Qt),J(K),J(Ht),J(tt),J(Nt),J(et),J(Xt),J(Ft),J(Tt)),J(o),y(r,t),y(C,t),y(d,t),y(b,t),y(k,t),y(S,t),y(_,t),y(V,t),y(L,t),y(W,t),y(H,t),y(X,t),y(q,t),y(P,t),y(Jt,t)}}}const Ae='{"title":"让多个智能体在多智能体层级中协作 🤖🤝🤖","local":"让多个智能体在多智能体层级中协作-","sections":[{"title":"🔍 创建一个网页搜索工具","local":"-创建一个网页搜索工具","sections":[],"depth":3},{"title":"构建我们的多智能体系统 🤖🤝🤖","local":"构建我们的多智能体系统-","sections":[],"depth":2}],"depth":1}';function Ve(qt){return he(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xe extends ge{constructor(o){super(),Be(this,o,Ve,ve,fe,{})}}export{xe as component};
