import{s as _M,n as SM,o as $M}from"../chunks/scheduler.39a43cde.js";import{S as vM,i as LM,g as n,s as j,r as T,A as DM,h as J,f as t,c as s,j as BM,u as A,x as U,k as OM,y as xM,a as e,v as a,d as p,t as w,w as i}from"../chunks/index.23ec2204.js";import{D as FM,C as I}from"../chunks/DocNotebookDropdown.21a75b74.js";import{H as tM,E as NM}from"../chunks/EditOnGithub.f2d09226.js";function ZM(eM){let y,Tl,Jl,Al,C,al,o,pl,Q,jM='<em>작성자: <a href="https://huggingface.co/m-ric" rel="nofollow">Aymeric Roucher</a>, 번역: <a href="https://github.com/harheem" rel="nofollow">김하림</a></em>',wl,m,sM='<p>이 튜토리얼은 고급 수준이므로, 시작하기 전에 <a href="agents">이 에이전트 쿡북</a>에서 다루는 기본 개념을 알고가는 것이 좋습니다!</p>',il,u,nM="우리는 이 노트북에서 <strong>다중 에이전트 웹 브라우저를 만들 것입니다. 여러 에이전트가 웹을 사용하여 문제를 해결하기 위해 협업하는 에이전트 시스템입니다!</strong>",Il,c,JM="이 시스템은 간단한 계층 구조로 되어있습니다. 여기서 <code>ManagedAgent</code> 객체를 사용하여 웹 검색 에이전트를 관리합니다. 이 구조를 통해 웹 검색 에이전트의 기능을 효과적으로 제어하고 조정할 수 있습니다.",yl,r,Cl,R,UM="환경 구성부터 시작해보겠습니다.",ol,f,TM="다음 명령어를 실행하여 필요한 패키지를 설치하세요.",Ql,g,ml,k,AM="Hugging Face Hub API를 사용하기 위해서는 로그인이 필요합니다.",ul,d,aM="아래 코드를 실행하여 로그인해주세요.",cl,V,rl,b,pM='⚡️ 우리의 에이전트는 <a href="https://huggingface.co/Qwen/Qwen2.5-72B-Instruct" rel="nofollow">Qwen/Qwen2.5-72B-Instruct</a> 모델을 사용합니다. 이 모델은 <code>HfApiEngine</code> 클래스를 통해 Hugging Face의 Inference API로 호출됩니다. Inference API를 활용하면 다양한 오픈 소스 모델을 빠르고 쉽게 실행할 수 있습니다.',Rl,E,wM='<em>Note:</em> Inference API는 다양한 기준에 따라 모델을 호스팅하며, 배포된 모델은 사전 통지 없이 업데이트되거나 교체될 수 있으므로 <a href="https://huggingface.co/docs/api-inference/supported-models" rel="nofollow">여기</a>에서 자세한 내용을 확인해보세요.',fl,h,iM="<em>역주:</em> 이 노트북을 실행하려면 Hugging Face에서 발급받은 HF_TOKEN을 Google Colab의 보안 변수(Secrets)로 등록해야 합니다. 또한, 여기서 사용되는 모델들은 Hugging Face의 Pro 구독이 필요합니다. 무료 계정으로는 접근이 제한될 수 있으니 주의해 주세요.",gl,B,kl,O,dl,_,IM='웹 브라우징을 위해 우리는 기존에 있는 <a href="https://github.com/huggingface/transformers/blob/main/src/transformers/agents/search.py" rel="nofollow"><code>DuckDuckGoSearchTool</code></a> 도구를 사용할 것입니다. 이 도구는 Google 검색과 비슷한 기능을 제공합니다.',Vl,S,yM=`그러나 <code>DuckDuckGoSearchTool</code>이 찾은 웹페이지의 내용을 자세히 볼 수 있는 기능도 필요합니다.
이를 위해 라이브러리에 있는 <code>VisitWebpageTool</code>을 사용할 수도 있지만, 우리는 이 도구를 직접 만들어보며 그 과정을 이해해 보려고 합니다.`,bl,$,CM="그래서 <code>markdownify</code>를 사용하여 <code>VisitWebpageTool</code> 도구를 처음부터 만들어 보도록 하겠습니다.",El,v,hl,L,oM="이제, 우리의 도구를 테스트해봅시다!",Bl,D,QM="<em>역주:</em> 한글이 포함된 URL의 디코딩을 처리하기 위해 코드를 추가하였습니다.",Ol,x,_l,F,mM=`허깅 페이스 \\- 위키백과, 우리 모두의 백과사전

[본문으로 이동](#bodyContent)

주 메뉴

주 메뉴
사이드바로 이동
숨기기

 둘러보기
 

* [대문](/wiki/위키백과:대문 "대문으로 가기 [z]")
* [최근 바뀜](/wiki/특수:최근바뀜 "위키의 최근 바뀐 목록 [r]")
* [요즘 화제](/wiki/포털:요즘_화제 "최근의 소식 알아 보기")
* [임의의 문서로](/wiki/특수:임의문서 "무작위로 선택된 문서 불러오기 [x]")

 사용자 모임
 

* [사랑방](/wiki/위키백과:사랑방)
* [사용자 모임](/wiki/위키백과:사용자_모임 "위키백과 참여자를 위한 토론/대화 공간입니다.")
* [관리 요청](/wiki/위키백과:요청)

 편집 안내
 

* [소개](/wiki/도움말:소개)
* [도움말](/wiki/위키백과:도움말 "도움말")
* [정책과 지침](/wiki/위키백과:정책과_지침)
* [질문방](/wiki/위키백과:질문방)

[![](
`,Sl,N,$l,Z,uM="이제 <code>search</code>와 <code>visit_webpage</code> 도구를 모두 갖추었으니, 이를 이용해 웹 에이전트를 만들 수 있습니다.",vl,W,cM="이 에이전트를 어떻게 구성하는 것이 좋을까요?",Ll,H,rM="<li>웹 브라우징은 병렬 도구 호출이 필요 없는 단일 타임라인 작업이므로, JSON 도구 호출이 적합합니다. 따라서 <code>ReactJsonAgent</code>를 선택합니다.</li> <li>또한, 웹 검색은 때때로 정확한 답변을 찾기 위해 여러 페이지를 탐색해야 할 수 있으므로, <code>max_iterations</code>를 10으로 늘리는 것이 좋습니다.</li>",Dl,X,xl,G,RM="그런 다음 이 웹 검색 에이전트를 <code>ManagedAgent</code>로 감싸줍니다. 이렇게 하면 상위의 관리자 에이전트가 이 에이전트를 쉽게 제어할 수 있습니다.",Fl,q,Nl,Y,fM="이제 관리자 에이전트를 생성합니다. 이때 <code>managed_agents</code> 매개변수에 우리가 만든 관리 받는 에이전트를 전달합니다.",Zl,z,gM="관리자 에이전트는 전체적인 계획 수립과 복잡한 사고를 담당해야 하므로, 고급 추론 능력이 필요합니다. 이런 이유로 <code>ReactCodeAgent</code>를 사용하는 것이 가장 적합할 것 같습니다.",Wl,P,kM="마지막으로, 현재 연도와 관련된 질문을 처리하기 위해 <code>additional_authorized_imports=[&quot;time&quot;, &quot;datetime&quot;]</code>을 설정에 추가합니다. 이렇게 하면 에이전트가 시간과 관련 정보를 다룰 수 있게 됩니다.",Hl,K,Xl,ll,dM=`이것으로 모든 준비가 끝났습니다! 이제 우리의 시스템을 실행해봅시다.
계산이 필요한 질문을 던져보겠습니다.`,Gl,Ml,ql,tl,VM="이렇게 에이전트들이 협력하여 과제를 해결했습니다! ✅",Yl,el,bM="💡 이 시스템은 쉽게 더 많은 에이전트로 확장될 수 있습니다. 예를 들어, 한 에이전트는 코드 실행을 담당하고, 다른 에이전트는 웹 검색을, 또 다른 에이전트는 파일 로딩을 처리하는 식으로 말이죠.",zl,jl,EM="🤔💭 더 나아가 복잡한 트리 구조의 계층을 생각해볼 수도 있습니다. 최고 경영자(CEO) 에이전트가 여러 중간 관리자를 관리하고, 각 중간 관리자는 다시 여러 부하 직원을 관리하는 구조를 만들 수 있죠.",Pl,sl,hM="심지어 더 많은 중간 관리 계층을 추가하고, 매일 여러 번의 회의를 하고, 스크럼 마스터와 함께 애자일 방식을 도입할 수도 있습니다. 그리고 각 새로운 구성 요소는 충분한 마찰을 추가하여 결국 아무 일도 완수되지 않도록 할 수 있겠죠… 음, 잠깐만요. 그건 아니겠네요. 우리의 단순한 구조를 유지하는 것이 좋겠습니다.",Kl,nl,lM,Ul,MM;return C=new FM({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/ko/multiagent_web_assistant.ipynb"}]}}),o=new tM({props:{title:"다중 에이전트 계층 구조에서 여러 에이전트가 협업하도록 하기",local:"다중-에이전트-계층-구조에서-여러-에이전트가-협업하도록-하기",headingTag:"h1"}}),r=new I({props:{code:"JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJCLS0tLS0tLS0tLS0tLS0tLS0lMkIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMjAlMjAlMjAlRUElQjQlODAlRUIlQTYlQUMlRUMlOUUlOTAlMjAlRUMlOTclOTAlRUMlOUQlQjQlRUMlQTAlODQlRUQlOEElQjglMjAlMjAlMjAlN0MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAl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AlMjAlMjAlMjAlMjAlRUMlOUIlQjklRUQlOEUlOTglRUMlOUQlQjQlRUMlQTclODAlMjAlRUIlQjAlQTklRUIlQUMlQjglMjAlRUIlOEYlODQlRUElQjUlQUMlMjAlMjAlMjAlMjAlN0MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkItLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSUyQiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUwQQ==",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}}),g=new I({props:{code:"IXBpcCUyMGluc3RhbGwlMjBtYXJrZG93bmlmeSUyMGR1Y2tkdWNrZ28tc2VhcmNoJTIwJTIydHJhbnNmb3JtZXJzJTVCYWdlbnRzJTVEJTIyJTIwLS11cGdyYWRlJTIwLXE=",highlighted:'!pip install markdownify duckduckgo-search <span class="hljs-string">&quot;transformers[agents]&quot;</span> --upgrade -q',wrap:!1}}),V=new I({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

notebook_login()`,wrap:!1}}),B=new I({props:{code:"bW9kZWwlMjAlM0QlMjAlMjJRd2VuJTJGUXdlbjIuNS03MkItSW5zdHJ1Y3QlMjI=",highlighted:'model = <span class="hljs-string">&quot;Qwen/Qwen2.5-72B-Instruct&quot;</span>',wrap:!1}}),O=new tM({props:{title:"🔍 웹 검색 도구 만들기",local:"-웹-검색-도구-만들기",headingTag:"h3"}}),v=new I({props:{code:"aW1wb3J0JTIwcmUlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBtYXJrZG93bmlmeSUyMGltcG9ydCUyMG1hcmtkb3duaWZ5JTIwYXMlMjBtZCUwQWZyb20lMjByZXF1ZXN0cy5leGNlcHRpb25zJTIwaW1wb3J0JTIwUmVxdWVzdEV4Y2VwdGlvbiUwQWZyb20lMjB0cmFuc2Zvcm1lcnMuYWdlbnRzJTIwaW1wb3J0JTIwdG9vbCUwQWZyb20lMjB1cmxsaWIucGFyc2UlMjBpbXBvcnQlMjB1bnF1b3RlJTBBJTBBJTBBJTQwdG9vbCUwQWRlZiUyMHZpc2l0X3dlYnBhZ2UodXJsJTNBJTIwc3RyKSUyMC0lM0UlMjBzdHIlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlRUMlQTMlQkMlRUMlOTYlQjQlRUMlQTclODQlMjBVUkwlMjAlRUMlOUIlQjklRUQlOEUlOTglRUMlOUQlQjQlRUMlQTclODAlRUIlQTUlQkMlMjAlRUIlQjAlQTklRUIlQUMlQjglRUQlOTUlOTglRUElQjMlQTAlMjAlRUElQjclQjglMjAlRUIlODIlQjQlRUMlOUElQTklRUMlOUQlODQlMjAlRUIlQTclODglRUQlODElQUMlRUIlOEIlQTQlRUMlOUElQjQlMjAlRUIlQUMlQjglRUMlOUUlOTAlRUMlOTclQj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CUzRCUyMHJlLnN1YihyJTIyJTVDKCguKiUzRiklNUMpJTIyJTJDJTIwbGFtYmRhJTIwbSUzQSUyMCUyMiglMjIlMjAlMkIlMjB1bnF1b3RlKG0uZ3JvdXAoMSkpJTIwJTJCJTIwJTIyKSUyMiUyQyUyMG1hcmtkb3duX2NvbnRlbnQpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWFya2Rvd25fY29udGVudCUwQSUwQSUyMCUyMCUyMCUyMGV4Y2VwdCUyMFJlcXVlc3RFeGNlcHRpb24lMjBhcyUyMGUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBmJTIyJUVDJTlCJUI5JUVEJThFJTk4JUVDJTlEJUI0JUVDJUE3JTgwJTIwJUVBJUIwJTgwJUVDJUEwJUI4JUVDJTk4JUE0JUVBJUI4JUIwJTIwJUVDJTk4JUE0JUVCJUE1JTk4JTNBJTIwJTdCc3RyKGUpJTdEJTIyJTBBJTIwJTIwJTIwJTIwZXhjZXB0JTIwRXhjZXB0aW9uJTIwYXMlMjBlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwZiUyMiVFQyU5OCU4OCVFQyU4MyU4MSVFQyVCOSU5OCUyMCVFQiVBQSVCQiVFRCU5NSU5QyUyMCVFQyU5OCVBNCVFQiVBNSU5OCUyMCVFQiVCMCU5QyVFQyU4MyU5RCUzQSUyMCU3QnN0cihlKSU3RCUyMg==",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-keyword">from</span> urllib.parse <span class="hljs-keyword">import</span> unquote


<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;주어진 URL 웹페이지를 방문하고 그 내용을 마크다운 문자열로 반환합니다.

    Args:
        url: 방문할 웹페이지의 URL

    Returns:
        마크다운으로 변환된 웹페이지 내용, 또는 요청 실패 시 오류 메시지
    &quot;&quot;&quot;</span>
    <span class="hljs-keyword">try</span>:
        <span class="hljs-comment"># URL로 GET 요청 보내기</span>
        response = requests.get(url)
        response.raise_for_status()  <span class="hljs-comment"># 잘못된 상태 코드에 대한 예외 처리</span>

        <span class="hljs-comment"># HTML 내용을 마크다운으로 변환하기</span>
        markdown_content = md(response.text).strip()

        <span class="hljs-comment"># 중복된 개행 문자 제거하기</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-comment"># URL 디코딩하기</span>
        markdown_content = re.sub(<span class="hljs-string">r&quot;\\((.*?)\\)&quot;</span>, <span class="hljs-keyword">lambda</span> m: <span class="hljs-string">&quot;(&quot;</span> + unquote(m.group(<span class="hljs-number">1</span>)) + <span class="hljs-string">&quot;)&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;웹페이지 가져오기 오류: <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;예상치 못한 오류 발생: <span class="hljs-subst">{<span class="hljs-built_in">str</span>(e)}</span>&quot;</span>`,wrap:!1}}),x=new I({props:{code:"cHJpbnQodmlzaXRfd2VicGFnZSglMjJodHRwcyUzQSUyRiUyRmtvLndpa2lwZWRpYS5vcmclMkZ3aWtpJTJGSHVnZ2luZ19GYWNlJTIyKSU1QiUzQTUwMCU1RCk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(visit_webpage(<span class="hljs-string">&quot;https://ko.wikipedia.org/wiki/Hugging_Face&quot;</span>)[:<span class="hljs-number">500</span>])',wrap:!1}}),N=new tM({props:{title:"다중 에이전트 시스템 구축하기 🤖🤝🤖",local:"다중-에이전트-시스템-구축하기-",headingTag:"h2"}}),X=new I({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}}),q=new I({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}}),K=new I({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}}),Ml=new I({props:{code:"bWFuYWdlcl9hZ2VudC5ydW4oJTIyU3RyaXBlJUVCJThBJTk0JTIwJUVCJUFBJTg3JTIwJUVCJTg1JTg0JTIwJUVDJUEwJTg0JUVDJTk3JTkwJTIwJUVDJTg0JUE0JUVCJUE2JUJEJUVCJTkwJTk4JUVDJTk3JTg4JUVCJTgyJTk4JUVDJTlBJTk0JTNGJTIyKQ==",highlighted:'manager_agent.run(<span class="hljs-string">&quot;Stripe는 몇 년 전에 설립되었나요?&quot;</span>)',wrap:!1}}),nl=new NM({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/ko/multiagent_web_assistant.md"}}),{c(){y=n("meta"),Tl=j(),Jl=n("p"),Al=j(),T(C.$$.fragment),al=j(),T(o.$$.fragment),pl=j(),Q=n("p"),Q.innerHTML=jM,wl=j(),m=n("blockquote"),m.innerHTML=sM,il=j(),u=n("p"),u.innerHTML=nM,Il=j(),c=n("p"),c.innerHTML=JM,yl=j(),T(r.$$.fragment),Cl=j(),R=n("p"),R.textContent=UM,ol=j(),f=n("p"),f.textContent=TM,Ql=j(),T(g.$$.fragment),ml=j(),k=n("p"),k.textContent=AM,ul=j(),d=n("p"),d.textContent=aM,cl=j(),T(V.$$.fragment),rl=j(),b=n("p"),b.innerHTML=pM,Rl=j(),E=n("p"),E.innerHTML=wM,fl=j(),h=n("p"),h.innerHTML=iM,gl=j(),T(B.$$.fragment),kl=j(),T(O.$$.fragment),dl=j(),_=n("p"),_.innerHTML=IM,Vl=j(),S=n("p"),S.innerHTML=yM,bl=j(),$=n("p"),$.innerHTML=CM,El=j(),T(v.$$.fragment),hl=j(),L=n("p"),L.textContent=oM,Bl=j(),D=n("p"),D.innerHTML=QM,Ol=j(),T(x.$$.fragment),_l=j(),F=n("pre"),F.textContent=mM,Sl=j(),T(N.$$.fragment),$l=j(),Z=n("p"),Z.innerHTML=uM,vl=j(),W=n("p"),W.textContent=cM,Ll=j(),H=n("ul"),H.innerHTML=rM,Dl=j(),T(X.$$.fragment),xl=j(),G=n("p"),G.innerHTML=RM,Fl=j(),T(q.$$.fragment),Nl=j(),Y=n("p"),Y.innerHTML=fM,Zl=j(),z=n("p"),z.innerHTML=gM,Wl=j(),P=n("p"),P.innerHTML=kM,Hl=j(),T(K.$$.fragment),Xl=j(),ll=n("p"),ll.textContent=dM,Gl=j(),T(Ml.$$.fragment),ql=j(),tl=n("p"),tl.textContent=VM,Yl=j(),el=n("p"),el.textContent=bM,zl=j(),jl=n("p"),jl.textContent=EM,Pl=j(),sl=n("p"),sl.textContent=hM,Kl=j(),T(nl.$$.fragment),lM=j(),Ul=n("p"),this.h()},l(l){const M=DM("svelte-u9bgzb",document.head);y=J(M,"META",{name:!0,content:!0}),M.forEach(t),Tl=s(l),Jl=J(l,"P",{}),BM(Jl).forEach(t),Al=s(l),A(C.$$.fragment,l),al=s(l),A(o.$$.fragment,l),pl=s(l),Q=J(l,"P",{"data-svelte-h":!0}),U(Q)!=="svelte-151a8cs"&&(Q.innerHTML=jM),wl=s(l),m=J(l,"BLOCKQUOTE",{"data-svelte-h":!0}),U(m)!=="svelte-1jzmr1c"&&(m.innerHTML=sM),il=s(l),u=J(l,"P",{"data-svelte-h":!0}),U(u)!=="svelte-1rq6psu"&&(u.innerHTML=nM),Il=s(l),c=J(l,"P",{"data-svelte-h":!0}),U(c)!=="svelte-1cm8dk5"&&(c.innerHTML=JM),yl=s(l),A(r.$$.fragment,l),Cl=s(l),R=J(l,"P",{"data-svelte-h":!0}),U(R)!=="svelte-1qh6bl4"&&(R.textContent=UM),ol=s(l),f=J(l,"P",{"data-svelte-h":!0}),U(f)!=="svelte-1mqxkgx"&&(f.textContent=TM),Ql=s(l),A(g.$$.fragment,l),ml=s(l),k=J(l,"P",{"data-svelte-h":!0}),U(k)!=="svelte-uc9qvf"&&(k.textContent=AM),ul=s(l),d=J(l,"P",{"data-svelte-h":!0}),U(d)!=="svelte-1y3bx5h"&&(d.textContent=aM),cl=s(l),A(V.$$.fragment,l),rl=s(l),b=J(l,"P",{"data-svelte-h":!0}),U(b)!=="svelte-8qemab"&&(b.innerHTML=pM),Rl=s(l),E=J(l,"P",{"data-svelte-h":!0}),U(E)!=="svelte-d3h3oh"&&(E.innerHTML=wM),fl=s(l),h=J(l,"P",{"data-svelte-h":!0}),U(h)!=="svelte-9blwox"&&(h.innerHTML=iM),gl=s(l),A(B.$$.fragment,l),kl=s(l),A(O.$$.fragment,l),dl=s(l),_=J(l,"P",{"data-svelte-h":!0}),U(_)!=="svelte-1d96w2l"&&(_.innerHTML=IM),Vl=s(l),S=J(l,"P",{"data-svelte-h":!0}),U(S)!=="svelte-a9vu1x"&&(S.innerHTML=yM),bl=s(l),$=J(l,"P",{"data-svelte-h":!0}),U($)!=="svelte-3svhn6"&&($.innerHTML=CM),El=s(l),A(v.$$.fragment,l),hl=s(l),L=J(l,"P",{"data-svelte-h":!0}),U(L)!=="svelte-54f9ee"&&(L.textContent=oM),Bl=s(l),D=J(l,"P",{"data-svelte-h":!0}),U(D)!=="svelte-1330jez"&&(D.innerHTML=QM),Ol=s(l),A(x.$$.fragment,l),_l=s(l),F=J(l,"PRE",{"data-svelte-h":!0}),U(F)!=="svelte-1mmwo4j"&&(F.textContent=mM),Sl=s(l),A(N.$$.fragment,l),$l=s(l),Z=J(l,"P",{"data-svelte-h":!0}),U(Z)!=="svelte-1l9poz6"&&(Z.innerHTML=uM),vl=s(l),W=J(l,"P",{"data-svelte-h":!0}),U(W)!=="svelte-1o9d5th"&&(W.textContent=cM),Ll=s(l),H=J(l,"UL",{"data-svelte-h":!0}),U(H)!=="svelte-12g3itt"&&(H.innerHTML=rM),Dl=s(l),A(X.$$.fragment,l),xl=s(l),G=J(l,"P",{"data-svelte-h":!0}),U(G)!=="svelte-12x4qmq"&&(G.innerHTML=RM),Fl=s(l),A(q.$$.fragment,l),Nl=s(l),Y=J(l,"P",{"data-svelte-h":!0}),U(Y)!=="svelte-1edug1w"&&(Y.innerHTML=fM),Zl=s(l),z=J(l,"P",{"data-svelte-h":!0}),U(z)!=="svelte-n9p3mq"&&(z.innerHTML=gM),Wl=s(l),P=J(l,"P",{"data-svelte-h":!0}),U(P)!=="svelte-gnjyuk"&&(P.innerHTML=kM),Hl=s(l),A(K.$$.fragment,l),Xl=s(l),ll=J(l,"P",{"data-svelte-h":!0}),U(ll)!=="svelte-iplqe1"&&(ll.textContent=dM),Gl=s(l),A(Ml.$$.fragment,l),ql=s(l),tl=J(l,"P",{"data-svelte-h":!0}),U(tl)!=="svelte-1c1jqbg"&&(tl.textContent=VM),Yl=s(l),el=J(l,"P",{"data-svelte-h":!0}),U(el)!=="svelte-1n4xu6m"&&(el.textContent=bM),zl=s(l),jl=J(l,"P",{"data-svelte-h":!0}),U(jl)!=="svelte-id0r8g"&&(jl.textContent=EM),Pl=s(l),sl=J(l,"P",{"data-svelte-h":!0}),U(sl)!=="svelte-12eyo28"&&(sl.textContent=hM),Kl=s(l),A(nl.$$.fragment,l),lM=s(l),Ul=J(l,"P",{}),BM(Ul).forEach(t),this.h()},h(){OM(y,"name","hf:doc:metadata"),OM(y,"content",WM)},m(l,M){xM(document.head,y),e(l,Tl,M),e(l,Jl,M),e(l,Al,M),a(C,l,M),e(l,al,M),a(o,l,M),e(l,pl,M),e(l,Q,M),e(l,wl,M),e(l,m,M),e(l,il,M),e(l,u,M),e(l,Il,M),e(l,c,M),e(l,yl,M),a(r,l,M),e(l,Cl,M),e(l,R,M),e(l,ol,M),e(l,f,M),e(l,Ql,M),a(g,l,M),e(l,ml,M),e(l,k,M),e(l,ul,M),e(l,d,M),e(l,cl,M),a(V,l,M),e(l,rl,M),e(l,b,M),e(l,Rl,M),e(l,E,M),e(l,fl,M),e(l,h,M),e(l,gl,M),a(B,l,M),e(l,kl,M),a(O,l,M),e(l,dl,M),e(l,_,M),e(l,Vl,M),e(l,S,M),e(l,bl,M),e(l,$,M),e(l,El,M),a(v,l,M),e(l,hl,M),e(l,L,M),e(l,Bl,M),e(l,D,M),e(l,Ol,M),a(x,l,M),e(l,_l,M),e(l,F,M),e(l,Sl,M),a(N,l,M),e(l,$l,M),e(l,Z,M),e(l,vl,M),e(l,W,M),e(l,Ll,M),e(l,H,M),e(l,Dl,M),a(X,l,M),e(l,xl,M),e(l,G,M),e(l,Fl,M),a(q,l,M),e(l,Nl,M),e(l,Y,M),e(l,Zl,M),e(l,z,M),e(l,Wl,M),e(l,P,M),e(l,Hl,M),a(K,l,M),e(l,Xl,M),e(l,ll,M),e(l,Gl,M),a(Ml,l,M),e(l,ql,M),e(l,tl,M),e(l,Yl,M),e(l,el,M),e(l,zl,M),e(l,jl,M),e(l,Pl,M),e(l,sl,M),e(l,Kl,M),a(nl,l,M),e(l,lM,M),e(l,Ul,M),MM=!0},p:SM,i(l){MM||(p(C.$$.fragment,l),p(o.$$.fragment,l),p(r.$$.fragment,l),p(g.$$.fragment,l),p(V.$$.fragment,l),p(B.$$.fragment,l),p(O.$$.fragment,l),p(v.$$.fragment,l),p(x.$$.fragment,l),p(N.$$.fragment,l),p(X.$$.fragment,l),p(q.$$.fragment,l),p(K.$$.fragment,l),p(Ml.$$.fragment,l),p(nl.$$.fragment,l),MM=!0)},o(l){w(C.$$.fragment,l),w(o.$$.fragment,l),w(r.$$.fragment,l),w(g.$$.fragment,l),w(V.$$.fragment,l),w(B.$$.fragment,l),w(O.$$.fragment,l),w(v.$$.fragment,l),w(x.$$.fragment,l),w(N.$$.fragment,l),w(X.$$.fragment,l),w(q.$$.fragment,l),w(K.$$.fragment,l),w(Ml.$$.fragment,l),w(nl.$$.fragment,l),MM=!1},d(l){l&&(t(Tl),t(Jl),t(Al),t(al),t(pl),t(Q),t(wl),t(m),t(il),t(u),t(Il),t(c),t(yl),t(Cl),t(R),t(ol),t(f),t(Ql),t(ml),t(k),t(ul),t(d),t(cl),t(rl),t(b),t(Rl),t(E),t(fl),t(h),t(gl),t(kl),t(dl),t(_),t(Vl),t(S),t(bl),t($),t(El),t(hl),t(L),t(Bl),t(D),t(Ol),t(_l),t(F),t(Sl),t($l),t(Z),t(vl),t(W),t(Ll),t(H),t(Dl),t(xl),t(G),t(Fl),t(Nl),t(Y),t(Zl),t(z),t(Wl),t(P),t(Hl),t(Xl),t(ll),t(Gl),t(ql),t(tl),t(Yl),t(el),t(zl),t(jl),t(Pl),t(sl),t(Kl),t(lM),t(Ul)),t(y),i(C,l),i(o,l),i(r,l),i(g,l),i(V,l),i(B,l),i(O,l),i(v,l),i(x,l),i(N,l),i(X,l),i(q,l),i(K,l),i(Ml,l),i(nl,l)}}}const WM='{"title":"다중 에이전트 계층 구조에서 여러 에이전트가 협업하도록 하기","local":"다중-에이전트-계층-구조에서-여러-에이전트가-협업하도록-하기","sections":[{"title":"🔍 웹 검색 도구 만들기","local":"-웹-검색-도구-만들기","sections":[],"depth":3},{"title":"다중 에이전트 시스템 구축하기 🤖🤝🤖","local":"다중-에이전트-시스템-구축하기-","sections":[],"depth":2}],"depth":1}';function HM(eM){return $M(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zM extends vM{constructor(y){super(),LM(this,y,HM,ZM,_M,{})}}export{zM as component};
