Buckets:

rtrm's picture
download
raw
20.8 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;액션: 에이전트가 환경과 상호작용할 수 있게 하기&quot;,&quot;local&quot;:&quot;actions-enabling-the-agent-to-engage-with-its-environment&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;에이전트 액션의 유형&quot;,&quot;local&quot;:&quot;types-of-agent-actions&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;중지 및 구문 분석 접근 방식&quot;,&quot;local&quot;:&quot;the-stop-and-parse-approach&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;코드 에이전트&quot;,&quot;local&quot;:&quot;code-agents&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/agents-course/pr_545/ko/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/entry/start.6bd6007b.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/scheduler.f6b352c8.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/singletons.d509bc8a.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/index.26cf6c5a.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/paths.ee75497a.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/entry/app.5df77bcf.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/index.7f38e934.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/nodes/0.e7b8cf8b.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/nodes/6.a02145d3.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/Tip.ae532637.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/CodeBlock.3ee8293b.js">
<link rel="modulepreload" href="/docs/agents-course/pr_545/ko/_app/immutable/chunks/getInferenceSnippets.1ddaa658.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;액션: 에이전트가 환경과 상호작용할 수 있게 하기&quot;,&quot;local&quot;:&quot;actions-enabling-the-agent-to-engage-with-its-environment&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;에이전트 액션의 유형&quot;,&quot;local&quot;:&quot;types-of-agent-actions&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;중지 및 구문 분석 접근 방식&quot;,&quot;local&quot;:&quot;the-stop-and-parse-approach&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;코드 에이전트&quot;,&quot;local&quot;:&quot;code-agents&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="actions-enabling-the-agent-to-engage-with-its-environment" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#actions-enabling-the-agent-to-engage-with-its-environment"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>액션: 에이전트가 환경과 상호작용할 수 있게 하기</span></h1> <div class="course-tip bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">이 섹션에서는 AI 에이전트가 환경과 상호작용하기 위해 취하는 구체적인 단계를 살펴봅니다.
액션이 어떻게 표현되는지(JSON 또는 코드 사용), 중지 및 구문 분석 접근 방식의 중요성, 그리고 다양한 유형의 에이전트를 소개합니다.</div> <p data-svelte-h="svelte-1aluky0">액션은 <strong>AI 에이전트가 환경과 상호작용하기 위해 취하는</strong> 구체적인 단계입니다.</p> <p data-svelte-h="svelte-as0c4a">정보를 위해 웹을 검색하든 물리적 장치를 제어하든, 각 액션은 에이전트가 실행하는 의도적인 작업입니다.</p> <p data-svelte-h="svelte-42d55y">예를 들어, 고객 서비스를 지원하는 에이전트는 고객 데이터를 검색하거나, 도움말 문서를 제공하거나, 문제를 인간 담당자에게 이관할 수 있습니다.</p> <h2 class="relative group"><a id="types-of-agent-actions" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#types-of-agent-actions"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>에이전트 액션의 유형</span></h2> <p data-svelte-h="svelte-898fmh">액션을 다르게 취하는 여러 유형의 에이전트가 있습니다:</p> <table data-svelte-h="svelte-19gxuln"><thead><tr><th>에이전트 유형</th> <th>설명</th></tr></thead> <tbody><tr><td>JSON 에이전트</td> <td>취할 액션이 JSON 형식으로 지정됩니다.</td></tr> <tr><td>코드 에이전트</td> <td>에이전트가 외부에서 해석되는 코드 블록을 작성합니다.</td></tr> <tr><td>함수 호출 에이전트</td> <td>JSON 에이전트의 하위 카테고리로, 각 액션마다 새로운 메시지를 생성하도록 미세 조정되었습니다.</td></tr></tbody></table> <p data-svelte-h="svelte-71uysp">액션 자체는 다양한 목적을 가질 수 있습니다:</p> <table data-svelte-h="svelte-40umr2"><thead><tr><th>액션 유형</th> <th>설명</th></tr></thead> <tbody><tr><td>정보 수집</td> <td>웹 검색 수행, 데이터베이스 쿼리, 문서 검색 등</td></tr> <tr><td>도구 사용</td> <td>API 호출, 계산 실행, 코드 실행</td></tr> <tr><td>환경 상호작용</td> <td>디지털 인터페이스 조작 또는 물리적 장치 제어</td></tr> <tr><td>의사소통</td> <td>채팅을 통한 사용자와의 상호작용 또는 다른 에이전트와의 협업</td></tr></tbody></table> <p data-svelte-h="svelte-1xeo1hn">모든 형식의 에이전트(JSON, 코드, 함수 호출)에 있어 중요한 부분은 <strong>액션이 완료되면 새로운 토큰 생성을 중지하는 능력</strong>입니다. 이는 의도하지 않은 출력을 방지하고 에이전트의 응답이 명확하고 정확하도록 보장합니다.</p> <p data-svelte-h="svelte-va3g75">LLM은 텍스트만 처리하며 이를 사용하여 취하고자 하는 액션과 도구에 제공할 매개변수를 설명합니다.</p> <h2 class="relative group"><a id="the-stop-and-parse-approach" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#the-stop-and-parse-approach"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>중지 및 구문 분석 접근 방식</span></h2> <p data-svelte-h="svelte-1a7p0d5">액션을 구현하는 핵심 방법 중 하나는 <strong>중지 및 구문 분석 접근 방식</strong>입니다. 이 방법은 에이전트의 출력이 구조화되고 예측 가능하도록 보장합니다:</p> <ol data-svelte-h="svelte-dnhf90"><li><strong>구조화된 형식으로 생성</strong>:</li></ol> <p data-svelte-h="svelte-udtimv">에이전트는 의도한 액션을 명확하고 미리 정의된 형식(JSON 또는 코드)으로 출력합니다.</p> <ol start="2" data-svelte-h="svelte-1xd19l0"><li><strong>추가 생성 중지</strong>:</li></ol> <p data-svelte-h="svelte-jsm0b9">액션이 완료되면 <strong>에이전트는 추가 토큰 생성을 중지</strong>합니다. 이는 불필요하거나 오류가 있는 출력을 방지합니다.</p> <ol start="3" data-svelte-h="svelte-b7xz2e"><li><strong>출력 구문 분석</strong>:</li></ol> <p data-svelte-h="svelte-x9n9km">외부 파서가 형식화된 액션을 읽고, 어떤 도구를 호출할지 결정하며, 필요한 매개변수를 추출합니다.</p> <p data-svelte-h="svelte-byfyzi">예를 들어, 날씨를 확인해야 하는 에이전트는 다음과 같이 출력할 수 있습니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->Thought<span class="hljs-punctuation">:</span> 서울의 현재 날씨를 확인해야 합니다.
Action <span class="hljs-punctuation">:</span>
<span class="hljs-punctuation">{</span>
<span class="hljs-attr">&quot;action&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;get_weather&quot;</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">&quot;action_input&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span><span class="hljs-attr">&quot;location&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Seoul&quot;</span><span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-o1icpx">프레임워크는 호출할 함수의 이름과 적용할 인자를 쉽게 구문 분석할 수 있습니다.</p> <p data-svelte-h="svelte-1bq2btw">이 명확하고 기계가 읽을 수 있는 형식은 오류를 최소화하고 외부 도구가 에이전트의 명령을 정확하게 처리할 수 있게 합니다.</p> <p data-svelte-h="svelte-1y6iiph">참고: 함수 호출 에이전트는 각 액션을 구조화하여 지정된 함수가 올바른 인수와 함께 호출되도록 하는 비슷한 방식으로 작동합니다.
이러한 유형의 에이전트에 대해서는 향후 유닛에서 더 자세히 살펴볼 것입니다.</p> <h2 class="relative group"><a id="code-agents" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#code-agents"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>코드 에이전트</span></h2> <p data-svelte-h="svelte-y1tr6p">대안적인 접근 방식은 <em>코드 에이전트</em>를 사용하는 것입니다.
핵심 아이디어는 <strong>단순한 JSON 객체를 출력하는 대신</strong>, 코드 에이전트가 <strong>실행 가능한 코드 블록(일반적으로 Python과 같은 고수준 언어로 작성)</strong>을 생성한다는 것입니다.</p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/code-vs-json-actions.png" alt="코드 에이전트"> <p data-svelte-h="svelte-1hp1alq">이 접근 방식은 여러 장점을 제공합니다:</p> <ul data-svelte-h="svelte-1msvsxq"><li><strong>표현력:</strong> 코드는 루프, 조건문, 중첩 함수를 포함한 복잡한 로직을 자연스럽게 표현할 수 있어 JSON보다 더 큰 유연성을 제공합니다.</li> <li><strong>모듈성 및 재사용성:</strong> 생성된 코드는 다양한 액션이나 작업에서 재사용할 수 있는 함수와 모듈을 포함할 수 있습니다.</li> <li><strong>향상된 디버깅 가능성:</strong> 잘 정의된 프로그래밍 구문을 통해 코드 오류를 감지하고 수정하기가 더 쉬운 경우가 많습니다.</li> <li><strong>직접 통합:</strong> 코드 에이전트는 외부 라이브러리 및 API와 직접 통합할 수 있어 데이터 처리나 실시간 의사 결정과 같은 복잡한 작업이 가능합니다.</li></ul> <p data-svelte-h="svelte-t451k5">예를 들어, 날씨 정보를 가져오는 임무를 맡은 코드 에이전트는 다음과 같은 Python 코드 조각을 생성할 수 있습니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment"># 코드 에이전트 예시: 날씨 정보 검색</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_weather</span>(<span class="hljs-params">city</span>):
<span class="hljs-keyword">import</span> requests
api_url = <span class="hljs-string">f&quot;https://api.weather.com/v1/location/<span class="hljs-subst">{city}</span>?apiKey=YOUR_API_KEY&quot;</span>
response = requests.get(api_url)
<span class="hljs-keyword">if</span> response.status_code == <span class="hljs-number">200</span>:
data = response.json()
<span class="hljs-keyword">return</span> data.get(<span class="hljs-string">&quot;weather&quot;</span>, <span class="hljs-string">&quot;날씨 정보가 없습니다&quot;</span>)
<span class="hljs-keyword">else</span>:
<span class="hljs-keyword">return</span> <span class="hljs-string">&quot;오류: 날씨 데이터를 가져올 수 없습니다.&quot;</span>
<span class="hljs-comment"># 함수 실행 및 최종 답변 준비</span>
result = get_weather(<span class="hljs-string">&quot;Seoul&quot;</span>)
final_answer = <span class="hljs-string">f&quot;서울의 현재 날씨는: <span class="hljs-subst">{result}</span>&quot;</span>
<span class="hljs-built_in">print</span>(final_answer)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1z022ba">이 예시에서 코드 에이전트는:</p> <ul data-svelte-h="svelte-t9e2pn"><li><strong>API 호출</strong>을 통해 날씨 데이터를 검색하고,</li> <li>응답을 처리하며,</li> <li>print() 함수를 사용하여 최종 답변을 출력합니다.</li></ul> <p data-svelte-h="svelte-4cmtmh">이 방법 <strong>또한 중지 및 구문 분석 접근 방식</strong>을 따르며, 코드 블록을 명확하게 구분하고 실행이 완료되었음을 신호합니다(여기서는 final_answer를 출력함으로써).</p> <hr> <p data-svelte-h="svelte-ku6eff">액션은 JSON, 코드 또는 함수 호출을 통해 명확하고 구조화된 작업을 실행함으로써 에이전트의 내부 추론과 실제 상호작용을 연결한다는 점을 배웠습니다.</p> <p data-svelte-h="svelte-1x7k891">이러한 의도적인 실행은 각 액션이 정확하고 중지 및 구문 분석 접근 방식을 통해 외부 처리가 가능하도록 보장합니다. 다음 섹션에서는 에이전트가 환경으로부터 피드백을 캡처하고 통합하는 방법을 알아보기 위해 관찰(Observations)에 대해 살펴볼 것입니다.</p> <p data-svelte-h="svelte-1eb8coz">이후에는 <strong>드디어 우리의 첫 번째 에이전트를 구축할 준비가 됩니다!</strong></p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/agents-course/blob/main/units/ko/unit1/actions.mdx" target="_blank"><span data-svelte-h="svelte-1kd6by1">&lt;</span> <span data-svelte-h="svelte-x0xyl0">&gt;</span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_wsuob5 = {
assets: "/docs/agents-course/pr_545/ko",
base: "/docs/agents-course/pr_545/ko",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/agents-course/pr_545/ko/_app/immutable/entry/start.6bd6007b.js"),
import("/docs/agents-course/pr_545/ko/_app/immutable/entry/app.5df77bcf.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 6],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
20.8 kB
·
Xet hash:
e731112a839dedd54e686465340038dcd94b90632c0b8372b637fe039e046219

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.