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

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

주 메뉴

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

 둘러보기
 

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

 사용자 모임
 

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

 편집 안내
 

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

[![](
`,Ll,N,vl,W,uM="이제 <code>search</code>와 <code>visit_webpage</code> 도구를 모두 갖추었으니, 이를 이용해 웹 에이전트를 만들 수 있습니다.",xl,H,fM="이 에이전트를 어떻게 구성하는 것이 좋을까요?",Dl,X,RM="<li>웹 브라우징은 병렬 도구 호출이 필요 없는 단일 타임라인 작업이므로, JSON 도구 호출이 적합합니다. 따라서 <code>ReactJsonAgent</code>를 선택합니다.</li> <li>또한, 웹 검색은 때때로 정확한 답변을 찾기 위해 여러 페이지를 탐색해야 할 수 있으므로, <code>max_iterations</code>를 10으로 늘리는 것이 좋습니다.</li>",Zl,G,Fl,q,gM="그런 다음 이 웹 검색 에이전트를 <code>ManagedAgent</code>로 감싸줍니다. 이렇게 하면 상위의 관리자 에이전트가 이 에이전트를 쉽게 제어할 수 있습니다.",Nl,Y,Wl,z,kM="이제 관리자 에이전트를 생성합니다. 이때 <code>managed_agents</code> 매개변수에 우리가 만든 관리 받는 에이전트를 전달합니다.",Hl,P,dM="관리자 에이전트는 전체적인 계획 수립과 복잡한 사고를 담당해야 하므로, 고급 추론 능력이 필요합니다. 이런 이유로 <code>ReactCodeAgent</code>를 사용하는 것이 가장 적합할 것 같습니다.",Xl,K,VM="마지막으로, 현재 연도와 관련된 질문을 처리하기 위해 <code>additional_authorized_imports=[&quot;time&quot;, &quot;datetime&quot;]</code>을 설정에 추가합니다. 이렇게 하면 에이전트가 시간과 관련 정보를 다룰 수 있게 됩니다.",Gl,ll,ql,Ml,bM=`이것으로 모든 준비가 끝났습니다! 이제 우리의 시스템을 실행해봅시다.
계산이 필요한 질문을 던져보겠습니다.`,Yl,tl,zl,el,EM="이렇게 에이전트들이 협력하여 과제를 해결했습니다! ✅",Pl,sl,hM="💡 이 시스템은 쉽게 더 많은 에이전트로 확장될 수 있습니다. 예를 들어, 한 에이전트는 코드 실행을 담당하고, 다른 에이전트는 웹 검색을, 또 다른 에이전트는 파일 로딩을 처리하는 식으로 말이죠.",Kl,jl,BM="🤔💭 더 나아가 복잡한 트리 구조의 계층을 생각해볼 수도 있습니다. 최고 경영자(CEO) 에이전트가 여러 중간 관리자를 관리하고, 각 중간 관리자는 다시 여러 부하 직원을 관리하는 구조를 만들 수 있죠.",lM,nl,OM="심지어 더 많은 중간 관리 계층을 추가하고, 매일 여러 번의 회의를 하고, 스크럼 마스터와 함께 애자일 방식을 도입할 수도 있습니다. 그리고 각 새로운 구성 요소는 충분한 마찰을 추가하여 결국 아무 일도 완수되지 않도록 할 수 있겠죠… 음, 잠깐만요. 그건 아니겠네요. 우리의 단순한 구조를 유지하는 것이 좋겠습니다.",MM,Jl,tM,Tl,eM;return C=new HM({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"}]}}),Q=new NM({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),o=new sM({props:{title:"다중 에이전트 계층 구조에서 여러 에이전트가 협업하도록 하기",local:"다중-에이전트-계층-구조에서-여러-에이전트가-협업하도록-하기",headingTag:"h1"}}),f=new I({props:{code:"JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJCLS0tLS0tLS0tLS0tLS0tLS0lMkIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMjAlMjAlMjAlRUElQjQlODAlRUIlQTYlQUMlRUMlOUUlOTAlMjAlRUMlOTclOTAlRUMlOUQlQjQ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jAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0MlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlRUMlOUIlQjklRUQlOEUlOTglRUMlOUQlQjQlRUMlQTclODAlMjAlRUIlQjAlQTklRUIlQUMlQjglMjAlRUIlOEYlODQlRUElQjUlQUMlMjAlMjAlMjAlMjAlN0MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkItLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSUyQiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUwQQ==",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 I({props:{code:"IXBpcCUyMGluc3RhbGwlMjBtYXJrZG93bmlmeSUyMGR1Y2tkdWNrZ28tc2VhcmNoJTIwJTIydHJhbnNmb3JtZXJzJTVCYWdlbnRzJTVEJTIyJTIwLS11cGdyYWRlJTIwLXE=",highlighted:'!pip install markdownify duckduckgo-search <span class="hljs-string">&quot;transformers[agents]&quot;</span> --upgrade -q',wrap:!1}}),b=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}}),O=new I({props:{code:"bW9kZWwlMjAlM0QlMjAlMjJRd2VuJTJGUXdlbjIuNS03MkItSW5zdHJ1Y3QlMjI=",highlighted:'model = <span class="hljs-string">&quot;Qwen/Qwen2.5-72B-Instruct&quot;</span>',wrap:!1}}),$=new sM({props:{title:"🔍 웹 검색 도구 만들기",local:"-웹-검색-도구-만들기",headingTag:"h3"}}),v=new I({props:{code:"aW1wb3J0JTIwcmUlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBtYXJrZG93bmlmeSUyMGltcG9ydCUyMG1hcmtkb3duaWZ5JTIwYXMlMjBtZCUwQWZyb20lMjByZXF1ZXN0cy5leGNlcHRpb25zJTIwaW1wb3J0JTIwUmVxdWVzdEV4Y2VwdGlvbiUwQWZyb20lMjB0cmFuc2Zvcm1lcnMuYWdlbnRzJTIwaW1wb3J0JTIwdG9vbCUwQWZyb20lMjB1cmxsaWIucGFyc2UlMjBpbXBvcnQlMjB1bnF1b3RlJTBBJTBBJTBBJTQwdG9vbCUwQWRlZiUyMHZpc2l0X3dlYnBhZ2UodXJsJTNBJTIwc3RyKSUyMC0lM0UlMjBzdHIlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlRUMlQTMlQkMlRUMlOTYlQjQlRUMlQTclODQlMjBVUkwlMjAlRUMlOUIlQjklRUQlOEUlOTglRUMlOUQlQjQlRUMlQTclODAlRUIlQTUlQkMlMjAlRUIlQjAlQTklRUIlQUMlQjglRUQlOTUlOTglRUElQjMlQTAlMjAlRUElQjclQjglMjAlRUIlODIlQjQlRUMlOUElQTklRUMlOUQlODQlMjAlR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JTk1JTk4JUVBJUI4JUIwJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWFya2Rvd25fY29udGVudCUyMCUzRCUyMHJlLnN1YihyJyU1QygoLiolM0YpJTVDKSclMkMlMjBsYW1iZGElMjBtJTNBJTIwJygnJTIwJTJCJTIwdW5xdW90ZShtLmdyb3VwKDEpKSUyMCUyQiUyMCcpJyUyQyUyMG1hcmtkb3duX2NvbnRlbnQpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWFya2Rvd25fY29udGVudCUwQSUwQSUyMCUyMCUyMCUyMGV4Y2VwdCUyMFJlcXVlc3RFeGNlcHRpb24lMjBhcyUyMGUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBmJTIyJUVDJTlCJUI5JUVEJThFJTk4JUVDJTlEJUI0JUVDJUE3JTgwJTIwJUVBJUIwJTgwJUVDJUEwJUI4JUVDJTk4JUE0JUVBJUI4JUIwJTIwJUVDJTk4JUE0JUVCJUE1JTk4JTNBJTIwJTdCc3RyKGUpJTdEJTIyJTBBJTIwJTIwJTIwJTIwZXhjZXB0JTIwRXhjZXB0aW9uJTIwYXMlMjBlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwZiUyMiVFQyU5OCU4OCVFQyU4MyU4MSVFQyVCOSU5OCUyMCVFQiVBQSVCQiVFRCU5NSU5QyUyMCVFQyU5OCVBNCVFQiVBNSU5OCUyMCVFQiVCMCU5QyVFQyU4MyU5RCUzQSUyMCU3QnN0cihlKSU3RCUyMg==",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&#x27;\\((.*?)\\)&#x27;</span>, <span class="hljs-keyword">lambda</span> m: <span class="hljs-string">&#x27;(&#x27;</span> + unquote(m.group(<span class="hljs-number">1</span>)) + <span class="hljs-string">&#x27;)&#x27;</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}}),Z=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 sM({props:{title:"다중 에이전트 시스템 구축하기 🤖🤝🤖",local:"다중-에이전트-시스템-구축하기-",headingTag:"h2"}}),G=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}}),Y=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}}),ll=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}}),tl=new I({props:{code:"bWFuYWdlcl9hZ2VudC5ydW4oJTIyU3RyaXBlJUVCJThBJTk0JTIwJUVCJUFBJTg3JTIwJUVCJTg1JTg0JTIwJUVDJUEwJTg0JUVDJTk3JTkwJTIwJUVDJTg0JUE0JUVCJUE2JUJEJUVCJTkwJTk4JUVDJTk3JTg4JUVCJTgyJTk4JUVDJTlBJTk0JTNGJTIyKQ==",highlighted:'manager_agent.run(<span class="hljs-string">&quot;Stripe는 몇 년 전에 설립되었나요?&quot;</span>)',wrap:!1}}),Jl=new WM({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/ko/multiagent_web_assistant.md"}}),{c(){y=n("meta"),Al=s(),Ul=n("p"),al=s(),T(C.$$.fragment),pl=s(),T(Q.$$.fragment),wl=s(),T(o.$$.fragment),il=s(),m=n("p"),m.innerHTML=nM,Il=s(),r=n("blockquote"),r.innerHTML=JM,yl=s(),c=n("p"),c.innerHTML=UM,Cl=s(),u=n("p"),u.innerHTML=TM,Ql=s(),T(f.$$.fragment),ol=s(),R=n("p"),R.textContent=AM,ml=s(),g=n("p"),g.textContent=aM,rl=s(),T(k.$$.fragment),cl=s(),d=n("p"),d.textContent=pM,ul=s(),V=n("p"),V.textContent=wM,fl=s(),T(b.$$.fragment),Rl=s(),E=n("p"),E.innerHTML=iM,gl=s(),h=n("p"),h.innerHTML=IM,kl=s(),B=n("p"),B.innerHTML=yM,dl=s(),T(O.$$.fragment),Vl=s(),T($.$$.fragment),bl=s(),_=n("p"),_.innerHTML=CM,El=s(),S=n("p"),S.innerHTML=QM,hl=s(),L=n("p"),L.innerHTML=oM,Bl=s(),T(v.$$.fragment),Ol=s(),x=n("p"),x.textContent=mM,$l=s(),D=n("p"),D.innerHTML=rM,_l=s(),T(Z.$$.fragment),Sl=s(),F=n("pre"),F.textContent=cM,Ll=s(),T(N.$$.fragment),vl=s(),W=n("p"),W.innerHTML=uM,xl=s(),H=n("p"),H.textContent=fM,Dl=s(),X=n("ul"),X.innerHTML=RM,Zl=s(),T(G.$$.fragment),Fl=s(),q=n("p"),q.innerHTML=gM,Nl=s(),T(Y.$$.fragment),Wl=s(),z=n("p"),z.innerHTML=kM,Hl=s(),P=n("p"),P.innerHTML=dM,Xl=s(),K=n("p"),K.innerHTML=VM,Gl=s(),T(ll.$$.fragment),ql=s(),Ml=n("p"),Ml.textContent=bM,Yl=s(),T(tl.$$.fragment),zl=s(),el=n("p"),el.textContent=EM,Pl=s(),sl=n("p"),sl.textContent=hM,Kl=s(),jl=n("p"),jl.textContent=BM,lM=s(),nl=n("p"),nl.textContent=OM,MM=s(),T(Jl.$$.fragment),tM=s(),Tl=n("p"),this.h()},l(l){const M=ZM("svelte-u9bgzb",document.head);y=J(M,"META",{name:!0,content:!0}),M.forEach(t),Al=j(l),Ul=J(l,"P",{}),$M(Ul).forEach(t),al=j(l),A(C.$$.fragment,l),pl=j(l),A(Q.$$.fragment,l),wl=j(l),A(o.$$.fragment,l),il=j(l),m=J(l,"P",{"data-svelte-h":!0}),U(m)!=="svelte-151a8cs"&&(m.innerHTML=nM),Il=j(l),r=J(l,"BLOCKQUOTE",{"data-svelte-h":!0}),U(r)!=="svelte-1jzmr1c"&&(r.innerHTML=JM),yl=j(l),c=J(l,"P",{"data-svelte-h":!0}),U(c)!=="svelte-1rq6psu"&&(c.innerHTML=UM),Cl=j(l),u=J(l,"P",{"data-svelte-h":!0}),U(u)!=="svelte-1cm8dk5"&&(u.innerHTML=TM),Ql=j(l),A(f.$$.fragment,l),ol=j(l),R=J(l,"P",{"data-svelte-h":!0}),U(R)!=="svelte-1qh6bl4"&&(R.textContent=AM),ml=j(l),g=J(l,"P",{"data-svelte-h":!0}),U(g)!=="svelte-1mqxkgx"&&(g.textContent=aM),rl=j(l),A(k.$$.fragment,l),cl=j(l),d=J(l,"P",{"data-svelte-h":!0}),U(d)!=="svelte-uc9qvf"&&(d.textContent=pM),ul=j(l),V=J(l,"P",{"data-svelte-h":!0}),U(V)!=="svelte-1y3bx5h"&&(V.textContent=wM),fl=j(l),A(b.$$.fragment,l),Rl=j(l),E=J(l,"P",{"data-svelte-h":!0}),U(E)!=="svelte-8qemab"&&(E.innerHTML=iM),gl=j(l),h=J(l,"P",{"data-svelte-h":!0}),U(h)!=="svelte-d3h3oh"&&(h.innerHTML=IM),kl=j(l),B=J(l,"P",{"data-svelte-h":!0}),U(B)!=="svelte-9blwox"&&(B.innerHTML=yM),dl=j(l),A(O.$$.fragment,l),Vl=j(l),A($.$$.fragment,l),bl=j(l),_=J(l,"P",{"data-svelte-h":!0}),U(_)!=="svelte-1d96w2l"&&(_.innerHTML=CM),El=j(l),S=J(l,"P",{"data-svelte-h":!0}),U(S)!=="svelte-a9vu1x"&&(S.innerHTML=QM),hl=j(l),L=J(l,"P",{"data-svelte-h":!0}),U(L)!=="svelte-3svhn6"&&(L.innerHTML=oM),Bl=j(l),A(v.$$.fragment,l),Ol=j(l),x=J(l,"P",{"data-svelte-h":!0}),U(x)!=="svelte-54f9ee"&&(x.textContent=mM),$l=j(l),D=J(l,"P",{"data-svelte-h":!0}),U(D)!=="svelte-1330jez"&&(D.innerHTML=rM),_l=j(l),A(Z.$$.fragment,l),Sl=j(l),F=J(l,"PRE",{"data-svelte-h":!0}),U(F)!=="svelte-1mmwo4j"&&(F.textContent=cM),Ll=j(l),A(N.$$.fragment,l),vl=j(l),W=J(l,"P",{"data-svelte-h":!0}),U(W)!=="svelte-1l9poz6"&&(W.innerHTML=uM),xl=j(l),H=J(l,"P",{"data-svelte-h":!0}),U(H)!=="svelte-1o9d5th"&&(H.textContent=fM),Dl=j(l),X=J(l,"UL",{"data-svelte-h":!0}),U(X)!=="svelte-12g3itt"&&(X.innerHTML=RM),Zl=j(l),A(G.$$.fragment,l),Fl=j(l),q=J(l,"P",{"data-svelte-h":!0}),U(q)!=="svelte-12x4qmq"&&(q.innerHTML=gM),Nl=j(l),A(Y.$$.fragment,l),Wl=j(l),z=J(l,"P",{"data-svelte-h":!0}),U(z)!=="svelte-1edug1w"&&(z.innerHTML=kM),Hl=j(l),P=J(l,"P",{"data-svelte-h":!0}),U(P)!=="svelte-n9p3mq"&&(P.innerHTML=dM),Xl=j(l),K=J(l,"P",{"data-svelte-h":!0}),U(K)!=="svelte-gnjyuk"&&(K.innerHTML=VM),Gl=j(l),A(ll.$$.fragment,l),ql=j(l),Ml=J(l,"P",{"data-svelte-h":!0}),U(Ml)!=="svelte-iplqe1"&&(Ml.textContent=bM),Yl=j(l),A(tl.$$.fragment,l),zl=j(l),el=J(l,"P",{"data-svelte-h":!0}),U(el)!=="svelte-1c1jqbg"&&(el.textContent=EM),Pl=j(l),sl=J(l,"P",{"data-svelte-h":!0}),U(sl)!=="svelte-1n4xu6m"&&(sl.textContent=hM),Kl=j(l),jl=J(l,"P",{"data-svelte-h":!0}),U(jl)!=="svelte-id0r8g"&&(jl.textContent=BM),lM=j(l),nl=J(l,"P",{"data-svelte-h":!0}),U(nl)!=="svelte-12eyo28"&&(nl.textContent=OM),MM=j(l),A(Jl.$$.fragment,l),tM=j(l),Tl=J(l,"P",{}),$M(Tl).forEach(t),this.h()},h(){_M(y,"name","hf:doc:metadata"),_M(y,"content",GM)},m(l,M){FM(document.head,y),e(l,Al,M),e(l,Ul,M),e(l,al,M),a(C,l,M),e(l,pl,M),a(Q,l,M),e(l,wl,M),a(o,l,M),e(l,il,M),e(l,m,M),e(l,Il,M),e(l,r,M),e(l,yl,M),e(l,c,M),e(l,Cl,M),e(l,u,M),e(l,Ql,M),a(f,l,M),e(l,ol,M),e(l,R,M),e(l,ml,M),e(l,g,M),e(l,rl,M),a(k,l,M),e(l,cl,M),e(l,d,M),e(l,ul,M),e(l,V,M),e(l,fl,M),a(b,l,M),e(l,Rl,M),e(l,E,M),e(l,gl,M),e(l,h,M),e(l,kl,M),e(l,B,M),e(l,dl,M),a(O,l,M),e(l,Vl,M),a($,l,M),e(l,bl,M),e(l,_,M),e(l,El,M),e(l,S,M),e(l,hl,M),e(l,L,M),e(l,Bl,M),a(v,l,M),e(l,Ol,M),e(l,x,M),e(l,$l,M),e(l,D,M),e(l,_l,M),a(Z,l,M),e(l,Sl,M),e(l,F,M),e(l,Ll,M),a(N,l,M),e(l,vl,M),e(l,W,M),e(l,xl,M),e(l,H,M),e(l,Dl,M),e(l,X,M),e(l,Zl,M),a(G,l,M),e(l,Fl,M),e(l,q,M),e(l,Nl,M),a(Y,l,M),e(l,Wl,M),e(l,z,M),e(l,Hl,M),e(l,P,M),e(l,Xl,M),e(l,K,M),e(l,Gl,M),a(ll,l,M),e(l,ql,M),e(l,Ml,M),e(l,Yl,M),a(tl,l,M),e(l,zl,M),e(l,el,M),e(l,Pl,M),e(l,sl,M),e(l,Kl,M),e(l,jl,M),e(l,lM,M),e(l,nl,M),e(l,MM,M),a(Jl,l,M),e(l,tM,M),e(l,Tl,M),eM=!0},p:LM,i(l){eM||(p(C.$$.fragment,l),p(Q.$$.fragment,l),p(o.$$.fragment,l),p(f.$$.fragment,l),p(k.$$.fragment,l),p(b.$$.fragment,l),p(O.$$.fragment,l),p($.$$.fragment,l),p(v.$$.fragment,l),p(Z.$$.fragment,l),p(N.$$.fragment,l),p(G.$$.fragment,l),p(Y.$$.fragment,l),p(ll.$$.fragment,l),p(tl.$$.fragment,l),p(Jl.$$.fragment,l),eM=!0)},o(l){w(C.$$.fragment,l),w(Q.$$.fragment,l),w(o.$$.fragment,l),w(f.$$.fragment,l),w(k.$$.fragment,l),w(b.$$.fragment,l),w(O.$$.fragment,l),w($.$$.fragment,l),w(v.$$.fragment,l),w(Z.$$.fragment,l),w(N.$$.fragment,l),w(G.$$.fragment,l),w(Y.$$.fragment,l),w(ll.$$.fragment,l),w(tl.$$.fragment,l),w(Jl.$$.fragment,l),eM=!1},d(l){l&&(t(Al),t(Ul),t(al),t(pl),t(wl),t(il),t(m),t(Il),t(r),t(yl),t(c),t(Cl),t(u),t(Ql),t(ol),t(R),t(ml),t(g),t(rl),t(cl),t(d),t(ul),t(V),t(fl),t(Rl),t(E),t(gl),t(h),t(kl),t(B),t(dl),t(Vl),t(bl),t(_),t(El),t(S),t(hl),t(L),t(Bl),t(Ol),t(x),t($l),t(D),t(_l),t(Sl),t(F),t(Ll),t(vl),t(W),t(xl),t(H),t(Dl),t(X),t(Zl),t(Fl),t(q),t(Nl),t(Wl),t(z),t(Hl),t(P),t(Xl),t(K),t(Gl),t(ql),t(Ml),t(Yl),t(zl),t(el),t(Pl),t(sl),t(Kl),t(jl),t(lM),t(nl),t(MM),t(tM),t(Tl)),t(y),i(C,l),i(Q,l),i(o,l),i(f,l),i(k,l),i(b,l),i(O,l),i($,l),i(v,l),i(Z,l),i(N,l),i(G,l),i(Y,l),i(ll,l),i(tl,l),i(Jl,l)}}}const GM='{"title":"다중 에이전트 계층 구조에서 여러 에이전트가 협업하도록 하기","local":"다중-에이전트-계층-구조에서-여러-에이전트가-협업하도록-하기","sections":[{"title":"🔍 웹 검색 도구 만들기","local":"-웹-검색-도구-만들기","sections":[],"depth":3},{"title":"다중 에이전트 시스템 구축하기 🤖🤝🤖","local":"다중-에이전트-시스템-구축하기-","sections":[],"depth":2}],"depth":1}';function qM(jM){return vM(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class lt extends xM{constructor(y){super(),DM(this,y,qM,XM,SM,{})}}export{lt as component};
