Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"๐ ์์ด์ ํธ ๋ฉ๋ชจ๋ฆฌ ๊ด๋ฆฌ","local":"-manage-your-agents-memory","sections":[{"title":"์์ด์ ํธ ๋ฉ๋ชจ๋ฆฌ ์ฌ์","local":"replay-your-agents-memory","sections":[],"depth":3},{"title":"์์ด์ ํธ ๋ฉ๋ชจ๋ฆฌ ๋์ ๋ณ๊ฒฝ","local":"dynamically-change-the-agents-memory","sections":[],"depth":3},{"title":"์์ด์ ํธ๋ฅผ ๋จ๊ณ๋ณ๋ก ์คํ","local":"run-agents-one-step-at-a-time","sections":[],"depth":3}],"depth":1}"> | |
| <link href="/docs/smolagents/pr_2060/ko/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/entry/start.f21eb17e.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/scheduler.00b97157.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/singletons.956410eb.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/index.78ea7f15.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/paths.0924b2d9.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/entry/app.43bd0d34.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/preload-helper.a0a022f1.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/index.a7c1a7a1.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/nodes/0.ab3c5f86.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/nodes/18.1fac388c.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.8d2aa6d9.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/CodeBlock.74fa11a7.js"> | |
| <link rel="modulepreload" href="/docs/smolagents/pr_2060/ko/_app/immutable/chunks/DocNotebookDropdown.be7b60e3.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"๐ ์์ด์ ํธ ๋ฉ๋ชจ๋ฆฌ ๊ด๋ฆฌ","local":"-manage-your-agents-memory","sections":[{"title":"์์ด์ ํธ ๋ฉ๋ชจ๋ฆฌ ์ฌ์","local":"replay-your-agents-memory","sections":[],"depth":3},{"title":"์์ด์ ํธ ๋ฉ๋ชจ๋ฆฌ ๋์ ๋ณ๊ฒฝ","local":"dynamically-change-the-agents-memory","sections":[],"depth":3},{"title":"์์ด์ ํธ๋ฅผ ๋จ๊ณ๋ณ๋ก ์คํ","local":"run-agents-one-step-at-a-time","sections":[],"depth":3}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" 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></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <div class="flex space-x-1 " style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"> <div class="relative colab-dropdown "> <button class=" " type="button"> <img alt="Open In Colab" class="!m-0" src="https://colab.research.google.com/assets/colab-badge.svg"> </button> </div> <div class="relative colab-dropdown "> <button class=" " type="button"> <img alt="Open In Studio Lab" class="!m-0" src="https://studiolab.sagemaker.aws/studiolab.svg"> </button> </div></div> <h1 class="relative group"><a id="-manage-your-agents-memory" 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="#-manage-your-agents-memory"><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> <p data-svelte-h="svelte-ton0ak">๊ฒฐ๊ตญ ์์ด์ ํธ๋ ๋๊ตฌ์ ํ๋กฌํํธ๋ก ์ด๋ฃจ์ด์ง ๋จ์ํ ๊ตฌ์ฑ์์๋ก ์ ์๋ฉ๋๋ค. | |
| ๊ทธ๋ฆฌ๊ณ ๋ฌด์๋ณด๋ค ์ค์ํ ๊ฒ์ ์์ด์ ํธ๊ฐ ๊ณผ๊ฑฐ ๋จ๊ณ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ฐ์ง๊ณ ์์ด ๊ณํ, ์คํ, ์ค๋ฅ์ ์ด๋ ฅ์ ์ถ์ ํ๋ค๋ ์ ์ ๋๋ค.</p> <h3 class="relative group"><a id="replay-your-agents-memory" 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="#replay-your-agents-memory"><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></h3> <p data-svelte-h="svelte-1h50h00">๊ณผ๊ฑฐ ์คํ๋ ์์ด์ ํธ๋ฅผ ํ์ธํ๊ธฐ ์ํ ๋ช ๊ฐ์ง ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.</p> <p data-svelte-h="svelte-dnn1cu"><a href="./inspect_runs">๊ณ์ธก ๊ฐ์ด๋</a>์์ ์ธ๊ธํ ๋ฐ์ ๊ฐ์ด, ์์ด์ ํธ ์คํ์ ๊ณ์ธกํ์ฌ ํน์ ๋จ๊ณ๋ฅผ ํ๋ํ๊ฑฐ๋ ์ถ์ํ ์ ์๋ ์ฐ์ํ UI๋ก ์๊ฐํํ ์ ์์ต๋๋ค.</p> <p data-svelte-h="svelte-iux67r">๋ํ ๋ค์๊ณผ ๊ฐ์ด <code>agent.replay()</code>๋ฅผ ์ฌ์ฉํ ์๋ ์์ต๋๋ค.</p> <p data-svelte-h="svelte-lh7ekp">์์ด์ ํธ๋ฅผ ์คํํ ํ,</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-keyword">from</span> smolagents <span class="hljs-keyword">import</span> InferenceClientModel, CodeAgent | |
| agent = CodeAgent(tools=[], model=InferenceClientModel(), verbosity_level=<span class="hljs-number">0</span>) | |
| result = agent.run(<span class="hljs-string">"What's the 20th Fibonacci number?"</span>)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-12x9pal">์ด ๋ง์ง๋ง ์คํ์ ๋ค์ ์ฌ์ํ๊ณ ์ถ๋ค๋ฉด, ๋ค์ ์ฝ๋๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค.</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 -->agent.replay()<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="dynamically-change-the-agents-memory" 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="#dynamically-change-the-agents-memory"><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></h3> <p data-svelte-h="svelte-1lq08uo">๋ง์ ๊ณ ๊ธ ์ฌ์ฉ ์ฌ๋ก์์๋ ์์ด์ ํธ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋์ ์ผ๋ก ์์ ํด์ผ ํฉ๋๋ค.</p> <p data-svelte-h="svelte-lnzmi9">์์ด์ ํธ์ ๋ฉ๋ชจ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ด ์ ๊ทผํ ์ ์์ต๋๋ค.</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-keyword">from</span> smolagents <span class="hljs-keyword">import</span> ActionStep | |
| system_prompt_step = agent.memory.system_prompt | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"The system prompt given to the agent was:"</span>) | |
| <span class="hljs-built_in">print</span>(system_prompt_step.system_prompt) | |
| task_step = agent.memory.steps[<span class="hljs-number">0</span>] | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"\n\nThe first task step was:"</span>) | |
| <span class="hljs-built_in">print</span>(task_step.task) | |
| <span class="hljs-keyword">for</span> step <span class="hljs-keyword">in</span> agent.memory.steps: | |
| <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(step, ActionStep): | |
| <span class="hljs-keyword">if</span> step.error <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">None</span>: | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"\nStep <span class="hljs-subst">{step.step_number}</span> got this error:\n<span class="hljs-subst">{step.error}</span>\n"</span>) | |
| <span class="hljs-keyword">else</span>: | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"\nStep <span class="hljs-subst">{step.step_number}</span> got these observations:\n<span class="hljs-subst">{step.observations}</span>\n"</span>)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-gjznic"><code>agent.memory.get_full_steps()</code>๋ฅผ ์ฌ์ฉํ์ฌ ์ ์ฒด ๋จ๊ณ๋ฅผ ๋์ ๋๋ฆฌ ํํ๋ก ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.</p> <p data-svelte-h="svelte-hasgpe">๋ํ ๋จ๊ณ ์ฝ๋ฐฑ์ ์ฌ์ฉํ์ฌ ์์ด์ ํธ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋์ ์ผ๋ก ๋ณ๊ฒฝํ ์๋ ์์ต๋๋ค.</p> <p data-svelte-h="svelte-hno0dy">๋จ๊ณ ์ฝ๋ฐฑ์ ์ธ์๋ก <code>agent</code> ๊ฐ์ฒด ์์ฒด์ ์ ๊ทผํ ์ ์์ผ๋ฏ๋ก, ์์์ ์ค๋ช ํ ๊ฒ์ฒ๋ผ ๋ชจ๋ ๋ฉ๋ชจ๋ฆฌ ๋จ๊ณ์ ์ ๊ทผํ์ฌ ํ์ํ ๊ฒฝ์ฐ ์์ ํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ์น ๋ธ๋ผ์ฐ์ ์์ด์ ํธ๊ฐ ์ํํ๋ ๊ฐ ๋จ๊ณ์ ์คํฌ๋ฆฐ์ท์ ๊ด์ฐฐํ๊ณ ์๋ค๊ณ ๊ฐ์ ํด ๋ณด๊ฒ ์ต๋๋ค. ์ด ๊ฒฝ์ฐ ์ต์ ์คํฌ๋ฆฐ์ท์ ์ ์งํ๋ฉด์ ํ ํฐ ๋น์ฉ์ ์ ์ฝํ๊ธฐ ์ํด ์ด์ ๋จ๊ณ์ ์ด๋ฏธ์ง๋ฅผ ๋ฉ๋ชจ๋ฆฌ์์ ์ ๊ฑฐํ ์ ์์ต๋๋ค.</p> <p data-svelte-h="svelte-1ie0c2b">์ด ๊ฒฝ์ฐ ๋ค์๊ณผ ๊ฐ์ ์ฝ๋๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. | |
| <em>์ฃผ์: ์ด ์ฝ๋๋ ๊ฐ๊ฒฐํจ์ ์ํด ์ผ๋ถ ์ํฌํธ ๋ฐ ๊ฐ์ฒด ์ ์๊ฐ ์๋ต๋ ๋ถ์์ ํ ์์์ ๋๋ค. ์ ์ฒด ์๋ ๋ฒ์ ์ ์ฝ๋๋ <a href="https://github.com/huggingface/smolagents/blob/main/src/smolagents/vision_web_browser.py" rel="nofollow">์๋ณธ ์คํฌ๋ฆฝํธ</a>์์ ํ์ธํ์ธ์.</em></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-keyword">import</span> helium | |
| <span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO | |
| <span class="hljs-keyword">from</span> time <span class="hljs-keyword">import</span> sleep | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">update_screenshot</span>(<span class="hljs-params">memory_step: ActionStep, agent: CodeAgent</span>) -> <span class="hljs-literal">None</span>: | |
| sleep(<span class="hljs-number">1.0</span>) <span class="hljs-comment"># JavaScript ์ ๋๋ฉ์ด์ ์ด ์๋ฃ๋ ํ์ ์คํฌ๋ฆฐ์ท์ ์ฐ๋๋ก ํฉ๋๋ค.</span> | |
| driver = helium.get_driver() | |
| latest_step = memory_step.step_number | |
| <span class="hljs-keyword">for</span> previous_memory_step <span class="hljs-keyword">in</span> agent.memory.steps: <span class="hljs-comment"># ์ด์ ์คํฌ๋ฆฐ์ท์ ๋ก๊ทธ์์ ์ ๊ฑฐํ์ฌ ์ฒ๋ฆฌ ๊ณผ์ ์ ๊ฐ์ํํฉ๋๋ค.</span> | |
| <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(previous_memory_step, ActionStep) <span class="hljs-keyword">and</span> previous_memory_step.step_number <= latest_step - <span class="hljs-number">2</span>: | |
| previous_memory_step.observations_images = <span class="hljs-literal">None</span> | |
| png_bytes = driver.get_screenshot_as_png() | |
| image = Image.<span class="hljs-built_in">open</span>(BytesIO(png_bytes)) | |
| memory_step.observations_images = [image.copy()]<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-v7yafc">๊ทธ ๋ค์ ์์ด์ ํธ๋ฅผ ์ด๊ธฐํํ ๋ ์ด ํจ์๋ฅผ ๋ค์๊ณผ ๊ฐ์ด <code>step_callbacks</code> ์ธ์์ ์ ๋ฌํด์ผ ํฉ๋๋ค.</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 -->CodeAgent( | |
| tools=[WebSearchTool(), go_back, close_popups, search_item_ctrl_f], | |
| model=model, | |
| additional_authorized_imports=[<span class="hljs-string">"helium"</span>], | |
| step_callbacks=[update_screenshot], | |
| max_steps=<span class="hljs-number">20</span>, | |
| verbosity_level=<span class="hljs-number">2</span>, | |
| )<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-luwqat">์ ์ฒด ์๋ ์์๋ <a href="https://github.com/huggingface/smolagents/blob/main/src/smolagents/vision_web_browser.py" rel="nofollow">๋น์ ์น ๋ธ๋ผ์ฐ์ ์ฝ๋</a>์์ ํ์ธํ ์ ์์ต๋๋ค.</p> <h3 class="relative group"><a id="run-agents-one-step-at-a-time" 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="#run-agents-one-step-at-a-time"><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></h3> <p data-svelte-h="svelte-3f8ynb">์ด ๊ธฐ๋ฅ์ ๋๊ตฌ ํธ์ถ์ ์ค๋ ์๊ฐ์ด ๊ฑธ๋ฆฌ๋ ๊ฒฝ์ฐ์ ์ ์ฉํฉ๋๋ค. | |
| ์์ด์ ํธ๋ฅผ ํ ๋จ๊ณ์ฉ ์คํํ๋ฉด์ ๊ฐ ๋จ๊ณ์์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ ๋ฐ์ดํธํ ์ ์์ต๋๋ค.</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-keyword">from</span> smolagents <span class="hljs-keyword">import</span> InferenceClientModel, CodeAgent, ActionStep, TaskStep | |
| agent = CodeAgent(tools=[], model=InferenceClientModel(), verbosity_level=<span class="hljs-number">1</span>) | |
| agent.python_executor.send_tools({**agent.tools}) | |
| <span class="hljs-built_in">print</span>(agent.memory.system_prompt) | |
| task = <span class="hljs-string">"What is the 20th Fibonacci number?"</span> | |
| <span class="hljs-comment"># ํ์์ ๋ฐ๋ผ ๋ค๋ฅธ ์์ด์ ํธ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋ถ๋ฌ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์์ ํ ์ ์์ต๋๋ค.</span> | |
| <span class="hljs-comment"># agent.memory.steps = previous_agent.memory.steps</span> | |
| <span class="hljs-comment"># ์๋ก์ด ์์ ์ ์์ํฉ๋๋ค!</span> | |
| agent.memory.steps.append(TaskStep(task=task, task_images=[])) | |
| final_answer = <span class="hljs-literal">None</span> | |
| step_number = <span class="hljs-number">1</span> | |
| <span class="hljs-keyword">while</span> final_answer <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">and</span> step_number <= <span class="hljs-number">10</span>: | |
| memory_step = ActionStep( | |
| step_number=step_number, | |
| observations_images=[], | |
| ) | |
| <span class="hljs-comment"># ํ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค.</span> | |
| final_answer = agent.step(memory_step) | |
| agent.memory.steps.append(memory_step) | |
| step_number += <span class="hljs-number">1</span> | |
| <span class="hljs-comment"># ํ์ํ ๊ฒฝ์ฐ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์์ ํ ์๋ ์์ต๋๋ค</span> | |
| <span class="hljs-comment"># ์๋ฅผ ๋ค์ด ์ต์ ๋จ๊ณ๋ฅผ ์ ๋ฐ์ดํธ ํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด ์ฒ๋ฆฌํฉ๋๋ค:</span> | |
| <span class="hljs-comment"># agent.memory.steps[-1] = ...</span> | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"The final answer is:"</span>, final_answer)<!-- HTML_TAG_END --></pre></div> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/smolagents/blob/main/docs/source/ko/tutorials/memory.md" target="_blank"><svg class="mr-1" 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="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_9tuyt9 = { | |
| assets: "/docs/smolagents/pr_2060/ko", | |
| base: "/docs/smolagents/pr_2060/ko", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/smolagents/pr_2060/ko/_app/immutable/entry/start.f21eb17e.js"), | |
| import("/docs/smolagents/pr_2060/ko/_app/immutable/entry/app.43bd0d34.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 18], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 27.6 kB
- Xet hash:
- ca0151c41d35445f2d16870019e5be0870d2a84647d9faf5037e2074540d1cee
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.