import{s as Us,n as ps,o as ws}from"../chunks/scheduler.f6319a2a.js";import{S as Js,i as os,g as a,s as M,r as p,A as js,h as y,f as e,c as n,j as as,u as w,x as U,k as ys,y as Ts,a as t,v as J,d as o,t as j,w as T}from"../chunks/index.85aa684c.js";import{C as i}from"../chunks/CodeBlock.3400fc53.js";import{D as is}from"../chunks/DocNotebookDropdown.3fc3604b.js";import{H as Ql,E as Cs}from"../chunks/getInferenceSnippets.55a93fbe.js";function cs(_l){let C,ll,K,sl,c,el,r,tl,I,Hl="此notebook将构建一个 <strong>multi-agent 网络浏览器：一个有多个代理协作，使用网络进行搜索解决问题的代理系统</strong>",Ml,d,Rl="<code>ManagedAgent</code> 对象将封装这些管理网络搜索的agent，形成一个简单的层次结构：",nl,m,al,u,Xl="我们来一起构建这个系统。运行下列代码以安装依赖包：",yl,h,Ul,b,xl="我们需要登录Hugging Face Hub以调用HF的Inference API：",pl,g,wl,B,Ll=`⚡️ HF的Inference API 可以快速轻松地运行任何开源模型，因此我们的agent将使用HF的Inference API
中的<code>InferenceClientModel</code>类来调用
<a href="https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct" rel="nofollow">Qwen/Qwen2.5-Coder-32B-Instruct</a>模型。`,Jl,f,Nl='<em>Note:</em> 基于多参数和部署模型的 Inference API 可能在没有预先通知的情况下更新或替换模型。了解更多信息，请参阅<a href="https://huggingface.co/docs/api-inference/supported-models" rel="nofollow">这里</a>。',ol,A,jl,Z,Tl,G,Yl=`虽然我们可以使用已经存在的
<code>WebSearchTool</code>
工具作为谷歌搜索的平替进行网页浏览，然后我们也需要能够查看<code>WebSearchTool</code>找到的页面。为此，我
们可以直接导入库的内置
<code>VisitWebpageTool</code>。但是我们将重新构建它以了解其工作原理。`,il,k,zl="我们将使用<code>markdownify</code> 来从头构建我们的<code>VisitWebpageTool</code>工具。",Cl,S,cl,W,Fl="现在我们初始化这个工具并测试它！",rl,v,Il,V,dl,E,ql="现在我们有了所有工具<code>search</code>和<code>visit_webpage</code>，我们可以使用它们来创建web agent。",ml,$,Dl="我们该选取什么样的配置来构建这个agent呢？",ul,Q,Pl="<li>网页浏览是一个单线程任务，不需要并行工具调用，因此JSON工具调用对于这个任务非常有效。因此我们选择<code>ToolCallingAgent</code>。</li> <li>有时候网页搜索需要探索许多页面才能找到正确答案，所以我们更喜欢将 <code>max_steps</code> 增加到10。</li>",hl,_,bl,H,Kl="请注意，我们为这个代理赋予了 name（名称）和 description（描述）属性，这些是必需属性，以便让管理代理能够调用此代理。",gl,R,Ol="然后，我们创建一个管理代理，在初始化时，将受管代理作为 managed_agents 参数传递给它。",Bl,X,ls="由于这个代理的任务是进行规划和思考，高级推理能力会很有帮助，因此 CodeAgent（代码代理）将是最佳选择。",fl,x,ss="此外，我们要提出一个涉及当前年份并需要进行额外数据计算的问题：所以让我们添加 additional_authorized_imports=[“time”, “numpy”, “pandas”]，以防代理需要用到这些包。",Al,L,Zl,N,es="可以了！现在让我们运行我们的系统！我们选择一个需要一些计算和研究的问题：",Gl,Y,kl,z,ts="我们用这个report 来回答这个问题：",Sl,F,Wl,q,Ms='如果<a href="https://gwern.net/scaling-hypothesis" rel="nofollow">scaling hypothesis</a>持续成立的话，我们需要一些庞大的动力配置。我们的agent成功地协作解决了这个任务！✅',vl,D,ns="💡 你可以轻松地将这个编排扩展到更多的agent：一个执行代码，一个进行网页搜索，一个处理文件加载⋯⋯",Vl,P,El,O,$l;return c=new Ql({props:{title:"编排 multi-agent 系统 🤖🤝🤖",local:"编排-multi-agent-系统-",headingTag:"h1"}}),r=new is({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/zh/multiagents.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/zh/pytorch/multiagents.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/zh/tensorflow/multiagents.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/zh/multiagents.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/zh/pytorch/multiagents.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/zh/tensorflow/multiagents.ipynb"}]}}),m=new i({props:{code:"JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJCLS0tLS0tLS0tLS0tLS0tLSUyQiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QyUyME1hbmFnZXIlMjBhZ2VudCUyMCUyMCU3QyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyQi0tLS0tLS0tLS0tLS0tLS0lMkIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBfX19fX19fX19fX19fX18lN0NfX19fX19fX19fX19fXyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QyUwQSUyMCUyMENvZGUlMjBpbnRlcnByZXRlciUyMCUyMCUyMCUyQi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tJTJCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwdG9vbCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QyUyMCUyMCUyMCU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CUyMCUyMCU3QyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFZpc2l0JTIwd2VicGFnZSUyMHRvb2wlMjAlN0MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkItLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSUyQg==",highlighted:`              +----------------+
              |<span class="hljs-string"> Manager agent  </span>|
              +----------------+
                       |<span class="hljs-string">
        _______________</span>|______________
       |<span class="hljs-string">                              </span>|
  Code interpreter   +--------------------------------+
       tool          |<span class="hljs-string">         Managed agent          </span>|
                     |<span class="hljs-string">      +------------------+      </span>|
                     |<span class="hljs-string">      </span>|<span class="hljs-string"> Web Search agent </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">  Web Search tool     </span>|<span class="hljs-string">         </span>|
                     |<span class="hljs-string">             Visit webpage tool </span>|
                     +--------------------------------+`,wrap:!1}}),h=new i({props:{code:"IXBpcCUyMGluc3RhbGwlMjAnc21vbGFnZW50cyU1QnRvb2xraXQlNUQnJTIwLS11cGdyYWRlJTIwLXE=",highlighted:'!pip install <span class="hljs-symbol">&#x27;smolagents</span>[toolkit]&#x27; <span class="hljs-comment">--upgrade -q</span>',wrap:!1}}),g=new i({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGxvZ2luJTBBJTBBbG9naW4oKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> <span class="hljs-keyword">login</span>

<span class="hljs-keyword">login</span>()`,wrap:!1}}),A=new i({props:{code:"bW9kZWxfaWQlMjAlM0QlMjAlMjJRd2VuJTJGUXdlbjIuNS1Db2Rlci0zMkItSW5zdHJ1Y3QlMjI=",highlighted:'model_id = <span class="hljs-string">&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</span>',wrap:!1}}),Z=new Ql({props:{title:"🔍 创建网络搜索工具",local:"-创建网络搜索工具",headingTag:"h2"}}),S=new i({props:{code:"aW1wb3J0JTIwcmUlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBtYXJrZG93bmlmeSUyMGltcG9ydCUyMG1hcmtkb3duaWZ5JTBBZnJvbSUyMHJlcXVlc3RzLmV4Y2VwdGlvbnMlMjBpbXBvcnQlMjBSZXF1ZXN0RXhjZXB0aW9uJTBBZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjB0b29sJTBBJTBBJTBBJTQwdG9vbCUwQWRlZiUyMHZpc2l0X3dlYnBhZ2UodXJsJTNBJTIwc3RyKSUyMC0lM0UlMjBzdHIlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjJWaXNpdHMlMjBhJTIwd2VicGFnZSUyMGF0JTIwdGhlJTIwZ2l2ZW4lMjBVUkwlMjBhbmQlMjByZXR1cm5zJTIwaXRzJTIwY29udGVudCUyMGFzJTIwYSUyMG1hcmtkb3duJTIwc3RyaW5nLiUwQSUwQSUyMCUyMCUyMCUyMEFyZ3MlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB1cmwlM0ElMjBUaGUlMjBVUkwlMjBvZiUyMHRoZSUyMHdlYnBhZ2UlMjB0byUyMHZpc2l0LiUwQSUwQSUyMCUyMCUyMCUyMFJldHVybnMlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBUaGUlMjBjb250ZW50JTIwb2YlMjB0aGUlMjB3ZWJwYWdlJTIwY29udmVydGVkJTIwdG8lMjBNYXJrZG93biUyQyUyMG9yJTIwY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2VwdGlvbiUyMGFzJTIwZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMGYlMjJFcnJvciUyMGZldGNoaW5nJTIwdGhlJTIwd2VicGFnZSUzQSUyMCU3QnN0cihlKSU3RCUyMiUwQSUyMCUyMCUyMCUyMGV4Y2VwdCUyMEV4Y2VwdGlvbiUyMGFzJTIwZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMGYlMjJBbiUyMHVuZXhwZWN0ZWQlMjBlcnJvciUyMG9jY3VycmVkJTNBJTIwJTdCc3RyKGUpJTdEJTIy",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">from</span> requests.exceptions <span class="hljs-keyword">import</span> RequestException
<span class="hljs-keyword">from</span> smolagents <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 = markdownify(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}}),v=new i({props:{code:"cHJpbnQodmlzaXRfd2VicGFnZSglMjJodHRwcyUzQSUyRiUyRmVuLndpa2lwZWRpYS5vcmclMkZ3aWtpJTJGSHVnZ2luZ19GYWNlJTIyKSU1QiUzQTUwMCU1RCk=",highlighted:'<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}}),V=new Ql({props:{title:"构建我们的 multi-agent 系统 🤖🤝🤖",local:"构建我们的-multi-agent-系统-",headingTag:"h2"}}),_=new i({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjAoJTBBJTIwJTIwJTIwJTIwQ29kZUFnZW50JTJDJTBBJTIwJTIwJTIwJTIwVG9vbENhbGxpbmdBZ2VudCUyQyUwQSUyMCUyMCUyMCUyMEluZmVyZW5jZUNsaWVudE1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwTWFuYWdlZEFnZW50JTJDJTBBJTIwJTIwJTIwJTIwV2ViU2VhcmNoVG9vbCUyQyUwQSUyMCUyMCUyMCUyMExpdGVMTE1Nb2RlbCUyQyUwQSklMEElMEFtb2RlbCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudE1vZGVsKG1vZGVsX2lkJTNEbW9kZWxfaWQpJTBBJTBBd2ViX2FnZW50JTIwJTNEJTIwVG9vbENhbGxpbmdBZ2VudCglMEElMjAlMjAlMjAlMjB0b29scyUzRCU1QldlYlNlYXJjaFRvb2woKSUyQyUyMHZpc2l0X3dlYnBhZ2UlNUQlMkMlMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwbWF4X3N0ZXBzJTNEMTAlMkMlMEElMjAlMjAlMjAlMjBuYW1lJTNEJTIyc2VhcmNoJTIyJTJDJTBBJTIwJTIwJTIwJTIwZGVzY3JpcHRpb24lM0QlMjJSdW5zJTIwd2ViJTIwc2VhcmNoZXMlMjBmb3IlMjB5b3UuJTIwR2l2ZSUyMGl0JTIweW91ciUyMHF1ZXJ5JTIwYXMlMjBhbiUyMGFyZ3VtZW50LiUyMiUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> (
    CodeAgent,
    ToolCallingAgent,
    InferenceClientModel,
    ManagedAgent,
    WebSearchTool,
    LiteLLMModel,
)

model = InferenceClientModel(model_id=model_id)

web_agent = ToolCallingAgent(
    tools=[WebSearchTool(), visit_webpage],
    model=model,
    max_steps=<span class="hljs-number">10</span>,
    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}}),L=new i({props:{code:"bWFuYWdlcl9hZ2VudCUyMCUzRCUyMENvZGVBZ2VudCglMEElMjAlMjAlMjAlMjB0b29scyUzRCU1QiU1RCUyQyUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBtYW5hZ2VkX2FnZW50cyUzRCU1QndlYl9hZ2VudCU1RCUyQyUwQSUyMCUyMCUyMCUyMGFkZGl0aW9uYWxfYXV0aG9yaXplZF9pbXBvcnRzJTNEJTVCJTIydGltZSUyMiUyQyUyMCUyMm51bXB5JTIyJTJDJTIwJTIycGFuZGFzJTIyJTVEJTJDJTBBKQ==",highlighted:`manager_agent = CodeAgent(
    tools=[],
    model=model,
    managed_agents=[web_agent],
    additional_authorized_imports=[<span class="hljs-string">&quot;time&quot;</span>, <span class="hljs-string">&quot;numpy&quot;</span>, <span class="hljs-string">&quot;pandas&quot;</span>],
)`,wrap:!1}}),Y=new i({props:{code:"YW5zd2VyJTIwJTNEJTIwbWFuYWdlcl9hZ2VudC5ydW4oJTIySWYlMjBMTE0lMjB0cmFpbmluZyUyMGNvbnRpbnVlcyUyMHRvJTIwc2NhbGUlMjB1cCUyMGF0JTIwdGhlJTIwY3VycmVudCUyMHJoeXRobSUyMHVudGlsJTIwMjAzMCUyQyUyMHdoYXQlMjB3b3VsZCUyMGJlJTIwdGhlJTIwZWxlY3RyaWMlMjBwb3dlciUyMGluJTIwR1clMjByZXF1aXJlZCUyMHRvJTIwcG93ZXIlMjB0aGUlMjBiaWdnZXN0JTIwdHJhaW5pbmclMjBydW5zJTIwYnklMjAyMDMwJTNGJTIwV2hhdCUyMHdvdWxkJTIwdGhhdCUyMGNvcnJlc3BvbmQlMjB0byUyQyUyMGNvbXBhcmVkJTIwdG8lMjBzb21lJTIwY291bnRyaWVzJTNGJTIwUGxlYXNlJTIwcHJvdmlkZSUyMGElMjBzb3VyY2UlMjBmb3IlMjBhbnklMjBudW1iZXJzJTIwdXNlZC4lMjIp",highlighted:'answer = manager_agent.run(<span class="hljs-string">&quot;If LLM training continues to scale up at the current rhythm until 2030, what would be the electric power in GW required to power the biggest training runs by 2030? What would that correspond to, compared to some countries? Please provide a source for any numbers used.&quot;</span>)',wrap:!1}}),F=new i({props:{code:"QmFzZWQlMjBvbiUyMGN1cnJlbnQlMjBncm93dGglMjBwcm9qZWN0aW9ucyUyMGFuZCUyMGVuZXJneSUyMGNvbnN1bXB0aW9uJTIwZXN0aW1hdGVzJTJDJTIwaWYlMjBMTE0lMjB0cmFpbmluZ3MlMjBjb250aW51ZSUyMHRvJTIwc2NhbGUlMjB1cCUyMGF0JTIwdGhlJTBBY3VycmVudCUyMHJoeXRobSUyMHVudGlsJTIwMjAzMCUzQSUwQSUwQTEuJTIwVGhlJTIwZWxlY3RyaWMlMjBwb3dlciU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wZnJvbSUyMEFXUyUyMENFTyUyME1hdHQlMjBHYXJtYW4uJTBBJTIwJTIwJTIwLSUyMFRoZSUyMGdyb3d0aCUyMHByb2plY3Rpb24lMjB1c2VkJTIwYSUyMENBR1IlMjBvZiUyMDc5LjgwJTI1JTIwZnJvbSUyMG1hcmtldCUyMHJlc2VhcmNoJTIwYnklMjBTcHJpbmdzLiUwQSUyMCUyMCUyMC0lMjBDb3VudHJ5JTIwZWxlY3RyaWNpdHklMjBjb25zdW1wdGlvbiUyMGRhdGElMjBpcyUyMGZyb20lMjB0aGUlMjBVLlMuJTIwRW5lcmd5JTIwSW5mb3JtYXRpb24lMjBBZG1pbmlzdHJhdGlvbiUyQyUyMHByaW1hcmlseSUyMGZvciUyMHRoZSUyMHllYXIlMEEyMDIxLg==",highlighted:`Based <span class="hljs-keyword">on</span> current growth projections <span class="hljs-keyword">and</span> energy consumption estimates, <span class="hljs-keyword">if</span> LLM trainings <span class="hljs-keyword">continue</span> <span class="hljs-keyword">to</span> scale up <span class="hljs-keyword">at</span> <span class="hljs-keyword">the</span>
current rhythm <span class="hljs-keyword">until</span> <span class="hljs-number">2030</span>:

<span class="hljs-number">1.</span> The electric power required <span class="hljs-keyword">to</span> power <span class="hljs-keyword">the</span> biggest training runs <span class="hljs-keyword">by</span> <span class="hljs-number">2030</span> would be approximately <span class="hljs-number">303.74</span> GW, which
translates <span class="hljs-keyword">to</span> <span class="hljs-keyword">about</span> <span class="hljs-number">2</span>,<span class="hljs-number">660</span>,<span class="hljs-number">762</span> GWh/<span class="hljs-built_in">year</span>.

<span class="hljs-number">1.</span> Comparing this <span class="hljs-keyword">to</span> countries&#x27; electricity consumption:
   - It would be equivalent <span class="hljs-keyword">to</span> <span class="hljs-keyword">about</span> <span class="hljs-number">34</span>% <span class="hljs-keyword">of</span> China&#x27;s total electricity consumption.
   - It would exceed <span class="hljs-keyword">the</span> total electricity consumption <span class="hljs-keyword">of</span> India (<span class="hljs-number">184</span>%), Russia (<span class="hljs-number">267</span>%), <span class="hljs-keyword">and</span> Japan (<span class="hljs-number">291</span>%).
   - It would be nearly <span class="hljs-number">9</span> <span class="hljs-keyword">times</span> <span class="hljs-keyword">the</span> electricity consumption <span class="hljs-keyword">of</span> countries like Italy <span class="hljs-keyword">or</span> Mexico.

<span class="hljs-number">2.</span> Source <span class="hljs-keyword">of</span> numbers:
   - The initial estimate <span class="hljs-keyword">of</span> <span class="hljs-number">5</span> GW <span class="hljs-keyword">for</span> future LLM training comes <span class="hljs-keyword">from</span> AWS CEO Matt Garman.
   - The growth projection used a CAGR <span class="hljs-keyword">of</span> <span class="hljs-number">79.80</span>% <span class="hljs-keyword">from</span> market research <span class="hljs-keyword">by</span> Springs.
   - Country electricity consumption data <span class="hljs-keyword">is</span> <span class="hljs-keyword">from</span> <span class="hljs-keyword">the</span> U.S. Energy Information Administration, primarily <span class="hljs-keyword">for</span> <span class="hljs-keyword">the</span> <span class="hljs-built_in">year</span>
<span class="hljs-number">2021.</span>`,wrap:!1}}),P=new Cs({props:{source:"https://github.com/huggingface/smolagents/blob/main/docs/source/zh/examples/multiagents.md"}}),{c(){C=a("meta"),ll=M(),K=a("p"),sl=M(),p(c.$$.fragment),el=M(),p(r.$$.fragment),tl=M(),I=a("p"),I.innerHTML=Hl,Ml=M(),d=a("p"),d.innerHTML=Rl,nl=M(),p(m.$$.fragment),al=M(),u=a("p"),u.textContent=Xl,yl=M(),p(h.$$.fragment),Ul=M(),b=a("p"),b.textContent=xl,pl=M(),p(g.$$.fragment),wl=M(),B=a("p"),B.innerHTML=Ll,Jl=M(),f=a("p"),f.innerHTML=Nl,ol=M(),p(A.$$.fragment),jl=M(),p(Z.$$.fragment),Tl=M(),G=a("p"),G.innerHTML=Yl,il=M(),k=a("p"),k.innerHTML=zl,Cl=M(),p(S.$$.fragment),cl=M(),W=a("p"),W.textContent=Fl,rl=M(),p(v.$$.fragment),Il=M(),p(V.$$.fragment),dl=M(),E=a("p"),E.innerHTML=ql,ml=M(),$=a("p"),$.textContent=Dl,ul=M(),Q=a("ul"),Q.innerHTML=Pl,hl=M(),p(_.$$.fragment),bl=M(),H=a("p"),H.textContent=Kl,gl=M(),R=a("p"),R.textContent=Ol,Bl=M(),X=a("p"),X.textContent=ls,fl=M(),x=a("p"),x.textContent=ss,Al=M(),p(L.$$.fragment),Zl=M(),N=a("p"),N.textContent=es,Gl=M(),p(Y.$$.fragment),kl=M(),z=a("p"),z.textContent=ts,Sl=M(),p(F.$$.fragment),Wl=M(),q=a("p"),q.innerHTML=Ms,vl=M(),D=a("p"),D.textContent=ns,Vl=M(),p(P.$$.fragment),El=M(),O=a("p"),this.h()},l(l){const s=js("svelte-u9bgzb",document.head);C=y(s,"META",{name:!0,content:!0}),s.forEach(e),ll=n(l),K=y(l,"P",{}),as(K).forEach(e),sl=n(l),w(c.$$.fragment,l),el=n(l),w(r.$$.fragment,l),tl=n(l),I=y(l,"P",{"data-svelte-h":!0}),U(I)!=="svelte-amh8hc"&&(I.innerHTML=Hl),Ml=n(l),d=y(l,"P",{"data-svelte-h":!0}),U(d)!=="svelte-3jtog5"&&(d.innerHTML=Rl),nl=n(l),w(m.$$.fragment,l),al=n(l),u=y(l,"P",{"data-svelte-h":!0}),U(u)!=="svelte-158mc1z"&&(u.textContent=Xl),yl=n(l),w(h.$$.fragment,l),Ul=n(l),b=y(l,"P",{"data-svelte-h":!0}),U(b)!=="svelte-s0io30"&&(b.textContent=xl),pl=n(l),w(g.$$.fragment,l),wl=n(l),B=y(l,"P",{"data-svelte-h":!0}),U(B)!=="svelte-1o3zzdj"&&(B.innerHTML=Ll),Jl=n(l),f=y(l,"P",{"data-svelte-h":!0}),U(f)!=="svelte-1jij1lg"&&(f.innerHTML=Nl),ol=n(l),w(A.$$.fragment,l),jl=n(l),w(Z.$$.fragment,l),Tl=n(l),G=y(l,"P",{"data-svelte-h":!0}),U(G)!=="svelte-k6zb4p"&&(G.innerHTML=Yl),il=n(l),k=y(l,"P",{"data-svelte-h":!0}),U(k)!=="svelte-y90h5t"&&(k.innerHTML=zl),Cl=n(l),w(S.$$.fragment,l),cl=n(l),W=y(l,"P",{"data-svelte-h":!0}),U(W)!=="svelte-1n6x7jk"&&(W.textContent=Fl),rl=n(l),w(v.$$.fragment,l),Il=n(l),w(V.$$.fragment,l),dl=n(l),E=y(l,"P",{"data-svelte-h":!0}),U(E)!=="svelte-1rg4l0k"&&(E.innerHTML=ql),ml=n(l),$=y(l,"P",{"data-svelte-h":!0}),U($)!=="svelte-1jtsocj"&&($.textContent=Dl),ul=n(l),Q=y(l,"UL",{"data-svelte-h":!0}),U(Q)!=="svelte-996ypc"&&(Q.innerHTML=Pl),hl=n(l),w(_.$$.fragment,l),bl=n(l),H=y(l,"P",{"data-svelte-h":!0}),U(H)!=="svelte-zr8ob4"&&(H.textContent=Kl),gl=n(l),R=y(l,"P",{"data-svelte-h":!0}),U(R)!=="svelte-grh88z"&&(R.textContent=Ol),Bl=n(l),X=y(l,"P",{"data-svelte-h":!0}),U(X)!=="svelte-648qpi"&&(X.textContent=ls),fl=n(l),x=y(l,"P",{"data-svelte-h":!0}),U(x)!=="svelte-p7yvhi"&&(x.textContent=ss),Al=n(l),w(L.$$.fragment,l),Zl=n(l),N=y(l,"P",{"data-svelte-h":!0}),U(N)!=="svelte-1rgnks8"&&(N.textContent=es),Gl=n(l),w(Y.$$.fragment,l),kl=n(l),z=y(l,"P",{"data-svelte-h":!0}),U(z)!=="svelte-6e0l98"&&(z.textContent=ts),Sl=n(l),w(F.$$.fragment,l),Wl=n(l),q=y(l,"P",{"data-svelte-h":!0}),U(q)!=="svelte-1nr8ehj"&&(q.innerHTML=Ms),vl=n(l),D=y(l,"P",{"data-svelte-h":!0}),U(D)!=="svelte-1g0vlkz"&&(D.textContent=ns),Vl=n(l),w(P.$$.fragment,l),El=n(l),O=y(l,"P",{}),as(O).forEach(e),this.h()},h(){ys(C,"name","hf:doc:metadata"),ys(C,"content",rs)},m(l,s){Ts(document.head,C),t(l,ll,s),t(l,K,s),t(l,sl,s),J(c,l,s),t(l,el,s),J(r,l,s),t(l,tl,s),t(l,I,s),t(l,Ml,s),t(l,d,s),t(l,nl,s),J(m,l,s),t(l,al,s),t(l,u,s),t(l,yl,s),J(h,l,s),t(l,Ul,s),t(l,b,s),t(l,pl,s),J(g,l,s),t(l,wl,s),t(l,B,s),t(l,Jl,s),t(l,f,s),t(l,ol,s),J(A,l,s),t(l,jl,s),J(Z,l,s),t(l,Tl,s),t(l,G,s),t(l,il,s),t(l,k,s),t(l,Cl,s),J(S,l,s),t(l,cl,s),t(l,W,s),t(l,rl,s),J(v,l,s),t(l,Il,s),J(V,l,s),t(l,dl,s),t(l,E,s),t(l,ml,s),t(l,$,s),t(l,ul,s),t(l,Q,s),t(l,hl,s),J(_,l,s),t(l,bl,s),t(l,H,s),t(l,gl,s),t(l,R,s),t(l,Bl,s),t(l,X,s),t(l,fl,s),t(l,x,s),t(l,Al,s),J(L,l,s),t(l,Zl,s),t(l,N,s),t(l,Gl,s),J(Y,l,s),t(l,kl,s),t(l,z,s),t(l,Sl,s),J(F,l,s),t(l,Wl,s),t(l,q,s),t(l,vl,s),t(l,D,s),t(l,Vl,s),J(P,l,s),t(l,El,s),t(l,O,s),$l=!0},p:ps,i(l){$l||(o(c.$$.fragment,l),o(r.$$.fragment,l),o(m.$$.fragment,l),o(h.$$.fragment,l),o(g.$$.fragment,l),o(A.$$.fragment,l),o(Z.$$.fragment,l),o(S.$$.fragment,l),o(v.$$.fragment,l),o(V.$$.fragment,l),o(_.$$.fragment,l),o(L.$$.fragment,l),o(Y.$$.fragment,l),o(F.$$.fragment,l),o(P.$$.fragment,l),$l=!0)},o(l){j(c.$$.fragment,l),j(r.$$.fragment,l),j(m.$$.fragment,l),j(h.$$.fragment,l),j(g.$$.fragment,l),j(A.$$.fragment,l),j(Z.$$.fragment,l),j(S.$$.fragment,l),j(v.$$.fragment,l),j(V.$$.fragment,l),j(_.$$.fragment,l),j(L.$$.fragment,l),j(Y.$$.fragment,l),j(F.$$.fragment,l),j(P.$$.fragment,l),$l=!1},d(l){l&&(e(ll),e(K),e(sl),e(el),e(tl),e(I),e(Ml),e(d),e(nl),e(al),e(u),e(yl),e(Ul),e(b),e(pl),e(wl),e(B),e(Jl),e(f),e(ol),e(jl),e(Tl),e(G),e(il),e(k),e(Cl),e(cl),e(W),e(rl),e(Il),e(dl),e(E),e(ml),e($),e(ul),e(Q),e(hl),e(bl),e(H),e(gl),e(R),e(Bl),e(X),e(fl),e(x),e(Al),e(Zl),e(N),e(Gl),e(kl),e(z),e(Sl),e(Wl),e(q),e(vl),e(D),e(Vl),e(El),e(O)),e(C),T(c,l),T(r,l),T(m,l),T(h,l),T(g,l),T(A,l),T(Z,l),T(S,l),T(v,l),T(V,l),T(_,l),T(L,l),T(Y,l),T(F,l),T(P,l)}}}const rs='{"title":"编排 multi-agent 系统 🤖🤝🤖","local":"编排-multi-agent-系统-","sections":[{"title":"🔍 创建网络搜索工具","local":"-创建网络搜索工具","sections":[],"depth":2},{"title":"构建我们的 multi-agent 系统 🤖🤝🤖","local":"构建我们的-multi-agent-系统-","sections":[],"depth":2}],"depth":1}';function Is(_l){return ws(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class gs extends Js{constructor(C){super(),os(this,C,Is,cs,Us,{})}}export{gs as component};
