import{s as Is,o as Cs,n as O}from"../chunks/scheduler.f6319a2a.js";import{S as js,i as ks,g as T,s as o,r as m,m as gs,A as $s,h as J,f as l,c as a,j as L,u as g,x as U,n as hs,k as fs,y as V,a as t,v as h,d as f,t as b,w as I}from"../chunks/index.85aa684c.js";import{T as Zl}from"../chunks/Tip.3d397a88.js";import{C as Q}from"../chunks/CodeBlock.3400fc53.js";import{D as vs}from"../chunks/DocNotebookDropdown.3fc3604b.js";import{H as E,E as Bs}from"../chunks/getInferenceSnippets.743412b2.js";import{H as bs,a as z}from"../chunks/HfOption.bd631572.js";function Vs(B){let s,d="The LLM can generate arbitrary code that will then be executed: do not add any unsafe imports!";return{c(){s=T("p"),s.textContent=d},l(i){s=J(i,"P",{"data-svelte-h":!0}),U(s)!=="svelte-sjm8o2"&&(s.textContent=d)},m(i,p){t(i,s,p)},p:O,d(i){i&&l(s)}}}function As(B){let s,d='Learn more about code execution <a href="tutorials/secure_code_execution">in this tutorial</a>.';return{c(){s=T("p"),s.innerHTML=d},l(i){s=J(i,"P",{"data-svelte-h":!0}),U(s)!=="svelte-1c04ue1"&&(s.innerHTML=d)},m(i,p){t(i,s,p)},p:O,d(i){i&&l(s)}}}function Rs(B){let s,d="Inference Providers need a <code>HF_TOKEN</code> to authenticate, but a free HF account already comes with included credits. Upgrade to PRO to raise your included credits.",i,p,u='To access gated models or rise your rate limits with a PRO account, you need to set the environment variable <code>HF_TOKEN</code> or pass <code>token</code> variable upon initialization of <code>InferenceClientModel</code>. You can get your token from your <a href="https://huggingface.co/settings/tokens" rel="nofollow">settings page</a>',w,C,$;return C=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIybWV0YS1sbGFtYSUyRkxsYW1hLTMuMy03MEItSW5zdHJ1Y3QlMjIlMjAlMEElMEFtb2RlbCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudE1vZGVsKG1vZGVsX2lkJTNEbW9kZWxfaWQlMkMlMjB0b2tlbiUzRCUyMiUzQ1lPVVJfSFVHR0lOR0ZBQ0VIVUJfQVBJX1RPS0VOJTNFJTIyKSUyMCUyMyUyMFlvdSUyMGNhbiUyMGNob29zZSUyMHRvJTIwbm90JTIwcGFzcyUyMGFueSUyMG1vZGVsX2lkJTIwdG8lMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUyMHRvJTIwdXNlJTIwYSUyMGRlZmF1bHQlMjBtb2RlbCUwQSUyMyUyMHlvdSUyMGNhbiUyMGFsc28lMjBzcGVjaWZ5JTIwYSUyMHBhcnRpY3VsYXIlMjBwcm92aWRlciUyMGUuZy4lMjBwcm92aWRlciUzRCUyMnRvZ2V0aGVyJTIyJTIwb3IlMjBwcm92aWRlciUzRCUyMnNhbWJhbm92YSUyMiUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCJTVEJTJDJTIwbW9kZWwlM0Rtb2RlbCUyQyUyMGFkZF9iYXNlX3Rvb2xzJTNEVHJ1ZSklMEElMEFhZ2VudC5ydW4oJTBBJTIwJTIwJTIwJTIwJTIyQ291bGQlMjB5b3UlMjBnaXZlJTIwbWUlMjB0aGUlMjAxMTh0aCUyMG51bWJlciUyMGluJTIwdGhlJTIwRmlib25hY2NpJTIwc2VxdWVuY2UlM0YlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, InferenceClientModel

model_id = <span class="hljs-string">&quot;meta-llama/Llama-3.3-70B-Instruct&quot;</span> 

model = InferenceClientModel(model_id=model_id, token=<span class="hljs-string">&quot;&lt;YOUR_HUGGINGFACEHUB_API_TOKEN&gt;&quot;</span>) <span class="hljs-comment"># You can choose to not pass any model_id to InferenceClientModel to use a default model</span>
<span class="hljs-comment"># you can also specify a particular provider e.g. provider=&quot;together&quot; or provider=&quot;sambanova&quot;</span>
agent = CodeAgent(tools=[], model=model, add_base_tools=<span class="hljs-literal">True</span>)

agent.run(
    <span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>,
)`,wrap:!1}}),{c(){s=T("p"),s.innerHTML=d,i=o(),p=T("p"),p.innerHTML=u,w=o(),m(C.$$.fragment)},l(r){s=J(r,"P",{"data-svelte-h":!0}),U(s)!=="svelte-1wdptq1"&&(s.innerHTML=d),i=a(r),p=J(r,"P",{"data-svelte-h":!0}),U(p)!=="svelte-bsbjyv"&&(p.innerHTML=u),w=a(r),g(C.$$.fragment,r)},m(r,A){t(r,s,A),t(r,i,A),t(r,p,A),t(r,w,A),h(C,r,A),$=!0},p:O,i(r){$||(f(C.$$.fragment,r),$=!0)},o(r){b(C.$$.fragment,r),$=!1},d(r){r&&(l(s),l(i),l(p),l(w)),I(C,r)}}}function Zs(B){let s,d;return s=new Q({props:{code:"JTIzJTIwIXBpcCUyMGluc3RhbGwlMjBzbW9sYWdlbnRzJTVCdHJhbnNmb3JtZXJzJTVEJTBBZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBUcmFuc2Zvcm1lcnNNb2RlbCUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIybWV0YS1sbGFtYSUyRkxsYW1hLTMuMi0zQi1JbnN0cnVjdCUyMiUwQSUwQW1vZGVsJTIwJTNEJTIwVHJhbnNmb3JtZXJzTW9kZWwobW9kZWxfaWQlM0Rtb2RlbF9pZCklMEFhZ2VudCUyMCUzRCUyMENvZGVBZ2VudCh0b29scyUzRCU1QiU1RCUyQyUyMG1vZGVsJTNEbW9kZWwlMkMlMjBhZGRfYmFzZV90b29scyUzRFRydWUpJTBBJTBBYWdlbnQucnVuKCUwQSUyMCUyMCUyMCUyMCUyMkNvdWxkJTIweW91JTIwZ2l2ZSUyMG1lJTIwdGhlJTIwMTE4dGglMjBudW1iZXIlMjBpbiUyMHRoZSUyMEZpYm9uYWNjaSUyMHNlcXVlbmNlJTNGJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-comment"># !pip install smolagents[transformers]</span>
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, TransformersModel

model_id = <span class="hljs-string">&quot;meta-llama/Llama-3.2-3B-Instruct&quot;</span>

model = TransformersModel(model_id=model_id)
agent = CodeAgent(tools=[], model=model, add_base_tools=<span class="hljs-literal">True</span>)

agent.run(
    <span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>,
)`,wrap:!1}}),{c(){m(s.$$.fragment)},l(i){g(s.$$.fragment,i)},m(i,p){h(s,i,p),d=!0},p:O,i(i){d||(f(s.$$.fragment,i),d=!0)},o(i){b(s.$$.fragment,i),d=!1},d(i){I(s,i)}}}function Ns(B){let s,d="To use <code>LiteLLMModel</code>, you need to set the environment variable <code>ANTHROPIC_API_KEY</code> or <code>OPENAI_API_KEY</code>, or pass <code>api_key</code> variable upon initialization.",i,p,u;return p=new Q({props:{code:"JTIzJTIwIXBpcCUyMGluc3RhbGwlMjBzbW9sYWdlbnRzJTVCbGl0ZWxsbSU1RCUwQWZyb20lMjBzbW9sYWdlbnRzJTIwaW1wb3J0JTIwQ29kZUFnZW50JTJDJTIwTGl0ZUxMTU1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBMaXRlTExNTW9kZWwobW9kZWxfaWQlM0QlMjJhbnRocm9waWMlMkZjbGF1ZGUtMy01LXNvbm5ldC1sYXRlc3QlMjIlMkMlMjBhcGlfa2V5JTNEJTIyWU9VUl9BTlRIUk9QSUNfQVBJX0tFWSUyMiklMjAlMjMlMjBDb3VsZCUyMHVzZSUyMCdncHQtNG8nJTBBYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQodG9vbHMlM0QlNUIlNUQlMkMlMjBtb2RlbCUzRG1vZGVsJTJDJTIwYWRkX2Jhc2VfdG9vbHMlM0RUcnVlKSUwQSUwQWFnZW50LnJ1biglMEElMjAlMjAlMjAlMjAlMjJDb3VsZCUyMHlvdSUyMGdpdmUlMjBtZSUyMHRoZSUyMDExOHRoJTIwbnVtYmVyJTIwaW4lMjB0aGUlMjBGaWJvbmFjY2klMjBzZXF1ZW5jZSUzRiUyMiUyQyUwQSk=",highlighted:`<span class="hljs-comment"># !pip install smolagents[litellm]</span>
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, LiteLLMModel

model = LiteLLMModel(model_id=<span class="hljs-string">&quot;anthropic/claude-3-5-sonnet-latest&quot;</span>, api_key=<span class="hljs-string">&quot;YOUR_ANTHROPIC_API_KEY&quot;</span>) <span class="hljs-comment"># Could use &#x27;gpt-4o&#x27;</span>
agent = CodeAgent(tools=[], model=model, add_base_tools=<span class="hljs-literal">True</span>)

agent.run(
    <span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>,
)`,wrap:!1}}),{c(){s=T("p"),s.innerHTML=d,i=o(),m(p.$$.fragment)},l(w){s=J(w,"P",{"data-svelte-h":!0}),U(s)!=="svelte-1iplh0r"&&(s.innerHTML=d),i=a(w),g(p.$$.fragment,w)},m(w,C){t(w,s,C),t(w,i,C),h(p,w,C),u=!0},p:O,i(w){u||(f(p.$$.fragment,w),u=!0)},o(w){b(p.$$.fragment,w),u=!1},d(w){w&&(l(s),l(i)),I(p,w)}}}function Ws(B){let s,d;return s=new Q({props:{code:"JTIzJTIwIXBpcCUyMGluc3RhbGwlMjBzbW9sYWdlbnRzJTVCbGl0ZWxsbSU1RCUwQWZyb20lMjBzbW9sYWdlbnRzJTIwaW1wb3J0JTIwQ29kZUFnZW50JTJDJTIwTGl0ZUxMTU1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBMaXRlTExNTW9kZWwoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlM0QlMjJvbGxhbWFfY2hhdCUyRmxsYW1hMy4yJTIyJTJDJTIwJTIzJTIwVGhpcyUyMG1vZGVsJTIwaXMlMjBhJTIwYml0JTIwd2VhayUyMGZvciUyMGFnZW50aWMlMjBiZWhhdmlvdXJzJTIwdGhvdWdoJTBBJTIwJTIwJTIwJTIwYXBpX2Jhc2UlM0QlMjJodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBMTE0MzQlMjIlMkMlMjAlMjMlMjByZXBsYWNlJTIwd2l0aCUyMDEyNy4wLjAuMSUzQTExNDM0JTIwb3IlMjByZW1vdGUlMjBvcGVuLWFpJTIwY29tcGF0aWJsZSUyMHNlcnZlciUyMGlmJTIwbmVjZXNzYXJ5JTBBJTIwJTIwJTIwJTIwYXBpX2tleSUzRCUyMllPVVJfQVBJX0tFWSUyMiUyQyUyMCUyMyUyMHJlcGxhY2UlMjB3aXRoJTIwQVBJJTIwa2V5JTIwaWYlMjBuZWNlc3NhcnklMEElMjAlMjAlMjAlMjBudW1fY3R4JTNEODE5MiUyQyUyMCUyMyUyMG9sbGFtYSUyMGRlZmF1bHQlMjBpcyUyMDIwNDglMjB3aGljaCUyMHdpbGwlMjBmYWlsJTIwaG9ycmlibHkuJTIwODE5MiUyMHdvcmtzJTIwZm9yJTIwZWFzeSUyMHRhc2tzJTJDJTIwbW9yZSUyMGlzJTIwYmV0dGVyLiUyMENoZWNrJTIwaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRnNwYWNlcyUyRk55eEtyYWdlJTJGTExNLU1vZGVsLVZSQU0tQ2FsY3VsYXRvciUyMHRvJTIwY2FsY3VsYXRlJTIwaG93JTIwbXVjaCUyMFZSQU0lMjB0aGlzJTIwd2lsbCUyMG5lZWQlMjBmb3IlMjB0aGUlMjBzZWxlY3RlZCUyMG1vZGVsLiUwQSklMEElMEFhZ2VudCUyMCUzRCUyMENvZGVBZ2VudCh0b29scyUzRCU1QiU1RCUyQyUyMG1vZGVsJTNEbW9kZWwlMkMlMjBhZGRfYmFzZV90b29scyUzRFRydWUpJTBBJTBBYWdlbnQucnVuKCUwQSUyMCUyMCUyMCUyMCUyMkNvdWxkJTIweW91JTIwZ2l2ZSUyMG1lJTIwdGhlJTIwMTE4dGglMjBudW1iZXIlMjBpbiUyMHRoZSUyMEZpYm9uYWNjaSUyMHNlcXVlbmNlJTNGJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-comment"># !pip install smolagents[litellm]</span>
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, LiteLLMModel

model = LiteLLMModel(
    model_id=<span class="hljs-string">&quot;ollama_chat/llama3.2&quot;</span>, <span class="hljs-comment"># This model is a bit weak for agentic behaviours though</span>
    api_base=<span class="hljs-string">&quot;http://localhost:11434&quot;</span>, <span class="hljs-comment"># replace with 127.0.0.1:11434 or remote open-ai compatible server if necessary</span>
    api_key=<span class="hljs-string">&quot;YOUR_API_KEY&quot;</span>, <span class="hljs-comment"># replace with API key if necessary</span>
    num_ctx=<span class="hljs-number">8192</span>, <span class="hljs-comment"># ollama default is 2048 which will fail horribly. 8192 works for easy tasks, more is better. Check https://huggingface.co/spaces/NyxKrage/LLM-Model-VRAM-Calculator to calculate how much VRAM this will need for the selected model.</span>
)

agent = CodeAgent(tools=[], model=model, add_base_tools=<span class="hljs-literal">True</span>)

agent.run(
    <span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>,
)`,wrap:!1}}),{c(){m(s.$$.fragment)},l(i){g(s.$$.fragment,i)},m(i,p){h(s,i,p),d=!0},p:O,i(i){d||(f(s.$$.fragment,i),d=!0)},o(i){b(s.$$.fragment,i),d=!1},d(i){I(s,i)}}}function Qs(B){let s,d="To connect to Azure OpenAI, you can either use <code>AzureOpenAIServerModel</code> directly, or use <code>LiteLLMModel</code> and configure it accordingly.",i,p,u="To initialize an instance of <code>AzureOpenAIServerModel</code>, you need to pass your model deployment name and then either pass the <code>azure_endpoint</code>, <code>api_key</code>, and <code>api_version</code> arguments, or set the environment variables <code>AZURE_OPENAI_ENDPOINT</code>, <code>AZURE_OPENAI_API_KEY</code>, and <code>OPENAI_API_VERSION</code>.",w,C,$,r,A="Similarly, you can configure <code>LiteLLMModel</code> to connect to Azure OpenAI as follows:",R,v,Z="<li>pass your model deployment name as <code>model_id</code>, and make sure to prefix it with <code>azure/</code></li> <li>make sure to set the environment variable <code>AZURE_API_VERSION</code></li> <li>either pass the <code>api_base</code> and <code>api_key</code> arguments, or set the environment variables <code>AZURE_API_KEY</code>, and <code>AZURE_API_BASE</code></li>",c,M,k;return C=new Q({props:{code:"JTIzJTIwIXBpcCUyMGluc3RhbGwlMjBzbW9sYWdlbnRzJTVCb3BlbmFpJTVEJTBBZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBBenVyZU9wZW5BSVNlcnZlck1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBBenVyZU9wZW5BSVNlcnZlck1vZGVsKG1vZGVsX2lkJTNEJTIyZ3B0LTRvLW1pbmklMjIpJTBBYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQodG9vbHMlM0QlNUIlNUQlMkMlMjBtb2RlbCUzRG1vZGVsJTJDJTIwYWRkX2Jhc2VfdG9vbHMlM0RUcnVlKSUwQSUwQWFnZW50LnJ1biglMEElMjAlMjAlMjAlMjAlMjJDb3VsZCUyMHlvdSUyMGdpdmUlMjBtZSUyMHRoZSUyMDExOHRoJTIwbnVtYmVyJTIwaW4lMjB0aGUlMjBGaWJvbmFjY2klMjBzZXF1ZW5jZSUzRiUyMiUyQyUwQSk=",highlighted:`<span class="hljs-comment"># !pip install smolagents[openai]</span>
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, AzureOpenAIServerModel

model = AzureOpenAIServerModel(model_id=<span class="hljs-string">&quot;gpt-4o-mini&quot;</span>)
agent = CodeAgent(tools=[], model=model, add_base_tools=<span class="hljs-literal">True</span>)

agent.run(
    <span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>,
)`,wrap:!1}}),M=new Q({props:{code:"aW1wb3J0JTIwb3MlMEFmcm9tJTIwc21vbGFnZW50cyUyMGltcG9ydCUyMENvZGVBZ2VudCUyQyUyMExpdGVMTE1Nb2RlbCUwQSUwQUFaVVJFX09QRU5BSV9DSEFUX0RFUExPWU1FTlRfTkFNRSUzRCUyMmdwdC0zNS10dXJiby0xNmstZGVwbG95bWVudCUyMiUyMCUyMyUyMGV4YW1wbGUlMjBvZiUyMGRlcGxveW1lbnQlMjBuYW1lJTBBJTBBb3MuZW52aXJvbiU1QiUyMkFaVVJFX0FQSV9LRVklMjIlNUQlMjAlM0QlMjAlMjIlMjIlMjAlMjMlMjBhcGlfa2V5JTBBb3MuZW52aXJvbiU1QiUyMkFaVVJFX0FQSV9CQVNFJTIyJTVEJTIwJTNEJTIwJTIyJTIyJTIwJTIzJTIwJTIyaHR0cHMlM0ElMkYlMkZleGFtcGxlLWVuZHBvaW50Lm9wZW5haS5henVyZS5jb20lMjIlMEFvcy5lbnZpcm9uJTVCJTIyQVpVUkVfQVBJX1ZFUlNJT04lMjIlNUQlMjAlM0QlMjAlMjIlMjIlMjAlMjMlMjAlMjIyMDI0LTEwLTAxLXByZXZpZXclMjIlMEElMEFtb2RlbCUyMCUzRCUyMExpdGVMTE1Nb2RlbChtb2RlbF9pZCUzRCUyMmF6dXJlJTJGJTIyJTIwJTJCJTIwQVpVUkVfT1BFTkFJX0NIQVRfREVQTE9ZTUVOVF9OQU1FKSUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCJTVEJTJDJTIwbW9kZWwlM0Rtb2RlbCUyQyUyMGFkZF9iYXNlX3Rvb2xzJTNEVHJ1ZSklMEElMEFhZ2VudC5ydW4oJTBBJTIwJTIwJTIwJTIyQ291bGQlMjB5b3UlMjBnaXZlJTIwbWUlMjB0aGUlMjAxMTh0aCUyMG51bWJlciUyMGluJTIwdGhlJTIwRmlib25hY2NpJTIwc2VxdWVuY2UlM0YlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, LiteLLMModel

AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=<span class="hljs-string">&quot;gpt-35-turbo-16k-deployment&quot;</span> <span class="hljs-comment"># example of deployment name</span>

os.environ[<span class="hljs-string">&quot;AZURE_API_KEY&quot;</span>] = <span class="hljs-string">&quot;&quot;</span> <span class="hljs-comment"># api_key</span>
os.environ[<span class="hljs-string">&quot;AZURE_API_BASE&quot;</span>] = <span class="hljs-string">&quot;&quot;</span> <span class="hljs-comment"># &quot;https://example-endpoint.openai.azure.com&quot;</span>
os.environ[<span class="hljs-string">&quot;AZURE_API_VERSION&quot;</span>] = <span class="hljs-string">&quot;&quot;</span> <span class="hljs-comment"># &quot;2024-10-01-preview&quot;</span>

model = LiteLLMModel(model_id=<span class="hljs-string">&quot;azure/&quot;</span> + AZURE_OPENAI_CHAT_DEPLOYMENT_NAME)
agent = CodeAgent(tools=[], model=model, add_base_tools=<span class="hljs-literal">True</span>)

agent.run(
   <span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>,
)`,wrap:!1}}),{c(){s=T("p"),s.innerHTML=d,i=o(),p=T("p"),p.innerHTML=u,w=o(),m(C.$$.fragment),$=o(),r=T("p"),r.innerHTML=A,R=o(),v=T("ul"),v.innerHTML=Z,c=o(),m(M.$$.fragment)},l(j){s=J(j,"P",{"data-svelte-h":!0}),U(s)!=="svelte-1hxxlnu"&&(s.innerHTML=d),i=a(j),p=J(j,"P",{"data-svelte-h":!0}),U(p)!=="svelte-1q2js0j"&&(p.innerHTML=u),w=a(j),g(C.$$.fragment,j),$=a(j),r=J(j,"P",{"data-svelte-h":!0}),U(r)!=="svelte-116rusl"&&(r.innerHTML=A),R=a(j),v=J(j,"UL",{"data-svelte-h":!0}),U(v)!=="svelte-1nzt61u"&&(v.innerHTML=Z),c=a(j),g(M.$$.fragment,j)},m(j,N){t(j,s,N),t(j,i,N),t(j,p,N),t(j,w,N),h(C,j,N),t(j,$,N),t(j,r,N),t(j,R,N),t(j,v,N),t(j,c,N),h(M,j,N),k=!0},p:O,i(j){k||(f(C.$$.fragment,j),f(M.$$.fragment,j),k=!0)},o(j){b(C.$$.fragment,j),b(M.$$.fragment,j),k=!1},d(j){j&&(l(s),l(i),l(p),l(w),l($),l(r),l(R),l(v),l(c)),I(C,j),I(M,j)}}}function Fs(B){let s,d="The <code>AmazonBedrockServerModel</code> class provides native integration with Amazon Bedrock, allowing for direct API calls and comprehensive configuration.",i,p,u="Basic Usage:",w,C,$,r,A="Advanced Configuration:",R,v,Z,c,M="Using LiteLLMModel:",k,j,N="Alternatively, you can use <code>LiteLLMModel</code> with Bedrock models:",F,G,H;return C=new Q({props:{code:"JTIzJTIwIXBpcCUyMGluc3RhbGwlMjBzbW9sYWdlbnRzJTVCYXdzX3NkayU1RCUwQWZyb20lMjBzbW9sYWdlbnRzJTIwaW1wb3J0JTIwQ29kZUFnZW50JTJDJTIwQW1hem9uQmVkcm9ja1NlcnZlck1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBBbWF6b25CZWRyb2NrU2VydmVyTW9kZWwobW9kZWxfaWQlM0QlMjJhbnRocm9waWMuY2xhdWRlLTMtc29ubmV0LTIwMjQwMjI5LXYxJTNBMCUyMiklMEFhZ2VudCUyMCUzRCUyMENvZGVBZ2VudCh0b29scyUzRCU1QiU1RCUyQyUyMG1vZGVsJTNEbW9kZWwlMkMlMjBhZGRfYmFzZV90b29scyUzRFRydWUpJTBBJTBBYWdlbnQucnVuKCUwQSUyMCUyMCUyMCUyMCUyMkNvdWxkJTIweW91JTIwZ2l2ZSUyMG1lJTIwdGhlJTIwMTE4dGglMjBudW1iZXIlMjBpbiUyMHRoZSUyMEZpYm9uYWNjaSUyMHNlcXVlbmNlJTNGJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-comment"># !pip install smolagents[aws_sdk]</span>
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, AmazonBedrockServerModel

model = AmazonBedrockServerModel(model_id=<span class="hljs-string">&quot;anthropic.claude-3-sonnet-20240229-v1:0&quot;</span>)
agent = CodeAgent(tools=[], model=model, add_base_tools=<span class="hljs-literal">True</span>)

agent.run(
    <span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>,
)`,wrap:!1}}),v=new Q({props:{code:"aW1wb3J0JTIwYm90bzMlMEFmcm9tJTIwc21vbGFnZW50cyUyMGltcG9ydCUyMEFtYXpvbkJlZHJvY2tTZXJ2ZXJNb2RlbCUwQSUwQSUyMyUyMENyZWF0ZSUyMGElMjBjdXN0b20lMjBCZWRyb2NrJTIwY2xpZW50JTBBYmVkcm9ja19jbGllbnQlMjAlM0QlMjBib3RvMy5jbGllbnQoJTBBJTIwJTIwJTIwJTIwJ2JlZHJvY2stcnVudGltZSclMkMlMEElMjAlMjAlMjAlMjByZWdpb25fbmFtZSUzRCd1cy1lYXN0LTEnJTJDJTBBJTIwJTIwJTIwJTIwYXdzX2FjY2Vzc19rZXlfaWQlM0QnWU9VUl9BQ0NFU1NfS0VZJyUyQyUwQSUyMCUyMCUyMCUyMGF3c19zZWNyZXRfYWNjZXNzX2tleSUzRCdZT1VSX1NFQ1JFVF9LRVknJTBBKSUwQSUwQWFkZGl0aW9uYWxfYXBpX2NvbmZpZyUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMmluZmVyZW5jZUNvbmZpZyUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1heFRva2VucyUyMiUzQSUyMDMwMDAlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjJndWFyZHJhaWxDb25maWclMjIlM0ElMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJndWFyZHJhaWxJZGVudGlmaWVyJTIyJTNBJTIwJTIyaWRlbnRpZnkxJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZ3VhcmRyYWlsVmVyc2lvbiUyMiUzQSUyMCd2MSclMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElN0QlMEElMEElMjMlMjBJbml0aWFsaXplJTIwd2l0aCUyMGNvbXByZWhlbnNpdmUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBBbWF6b25CZWRyb2NrU2VydmVyTW9kZWwoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlM0QlMjJ1cy5hbWF6b24ubm92YS1wcm8tdjElM0EwJTIyJTJDJTBBJTIwJTIwJTIwJTIwY2xpZW50JTNEYmVkcm9ja19jbGllbnQlMkMlMjAlMjAlMjMlMjBVc2UlMjBjdXN0b20lMjBjbGllbnQlMEElMjAlMjAlMjAlMjAqKmFkZGl0aW9uYWxfYXBpX2NvbmZpZyUwQSklMEElMEFhZ2VudCUyMCUzRCUyMENvZGVBZ2VudCh0b29scyUzRCU1QiU1RCUyQyUyMG1vZGVsJTNEbW9kZWwlMkMlMjBhZGRfYmFzZV90b29scyUzRFRydWUpJTBBJTBBYWdlbnQucnVuKCUwQSUyMCUyMCUyMCUyMCUyMkNvdWxkJTIweW91JTIwZ2l2ZSUyMG1lJTIwdGhlJTIwMTE4dGglMjBudW1iZXIlMjBpbiUyMHRoZSUyMEZpYm9uYWNjaSUyMHNlcXVlbmNlJTNGJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> boto3
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> AmazonBedrockServerModel

<span class="hljs-comment"># Create a custom Bedrock client</span>
bedrock_client = boto3.client(
    <span class="hljs-string">&#x27;bedrock-runtime&#x27;</span>,
    region_name=<span class="hljs-string">&#x27;us-east-1&#x27;</span>,
    aws_access_key_id=<span class="hljs-string">&#x27;YOUR_ACCESS_KEY&#x27;</span>,
    aws_secret_access_key=<span class="hljs-string">&#x27;YOUR_SECRET_KEY&#x27;</span>
)

additional_api_config = {
    <span class="hljs-string">&quot;inferenceConfig&quot;</span>: {
        <span class="hljs-string">&quot;maxTokens&quot;</span>: <span class="hljs-number">3000</span>
    },
    <span class="hljs-string">&quot;guardrailConfig&quot;</span>: {
        <span class="hljs-string">&quot;guardrailIdentifier&quot;</span>: <span class="hljs-string">&quot;identify1&quot;</span>,
        <span class="hljs-string">&quot;guardrailVersion&quot;</span>: <span class="hljs-string">&#x27;v1&#x27;</span>
    },
}

<span class="hljs-comment"># Initialize with comprehensive configuration</span>
model = AmazonBedrockServerModel(
    model_id=<span class="hljs-string">&quot;us.amazon.nova-pro-v1:0&quot;</span>,
    client=bedrock_client,  <span class="hljs-comment"># Use custom client</span>
    **additional_api_config
)

agent = CodeAgent(tools=[], model=model, add_base_tools=<span class="hljs-literal">True</span>)

agent.run(
    <span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>,
)`,wrap:!1}}),G=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBMaXRlTExNTW9kZWwlMkMlMjBDb2RlQWdlbnQlMEElMEFtb2RlbCUyMCUzRCUyMExpdGVMTE1Nb2RlbChtb2RlbF9uYW1lJTNEJTIyYmVkcm9jayUyRmFudGhyb3BpYy5jbGF1ZGUtMy1zb25uZXQtMjAyNDAyMjktdjElM0EwJTIyKSUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCJTVEJTJDJTIwbW9kZWwlM0Rtb2RlbCklMEElMEFhZ2VudC5ydW4oJTIyRXhwbGFpbiUyMHRoZSUyMGNvbmNlcHQlMjBvZiUyMHF1YW50dW0lMjBjb21wdXRpbmclMjIp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> LiteLLMModel, CodeAgent

model = LiteLLMModel(model_name=<span class="hljs-string">&quot;bedrock/anthropic.claude-3-sonnet-20240229-v1:0&quot;</span>)
agent = CodeAgent(tools=[], model=model)

agent.run(<span class="hljs-string">&quot;Explain the concept of quantum computing&quot;</span>)`,wrap:!1}}),{c(){s=T("p"),s.innerHTML=d,i=o(),p=T("p"),p.textContent=u,w=o(),m(C.$$.fragment),$=o(),r=T("p"),r.textContent=A,R=o(),m(v.$$.fragment),Z=o(),c=T("p"),c.textContent=M,k=o(),j=T("p"),j.innerHTML=N,F=o(),m(G.$$.fragment)},l(y){s=J(y,"P",{"data-svelte-h":!0}),U(s)!=="svelte-1t09vg6"&&(s.innerHTML=d),i=a(y),p=J(y,"P",{"data-svelte-h":!0}),U(p)!=="svelte-16zanz3"&&(p.textContent=u),w=a(y),g(C.$$.fragment,y),$=a(y),r=J(y,"P",{"data-svelte-h":!0}),U(r)!=="svelte-e5fqn2"&&(r.textContent=A),R=a(y),g(v.$$.fragment,y),Z=a(y),c=J(y,"P",{"data-svelte-h":!0}),U(c)!=="svelte-121tojm"&&(c.textContent=M),k=a(y),j=J(y,"P",{"data-svelte-h":!0}),U(j)!=="svelte-zwun4n"&&(j.innerHTML=N),F=a(y),g(G.$$.fragment,y)},m(y,W){t(y,s,W),t(y,i,W),t(y,p,W),t(y,w,W),h(C,y,W),t(y,$,W),t(y,r,W),t(y,R,W),h(v,y,W),t(y,Z,W),t(y,c,W),t(y,k,W),t(y,j,W),t(y,F,W),h(G,y,W),H=!0},p:O,i(y){H||(f(C.$$.fragment,y),f(v.$$.fragment,y),f(G.$$.fragment,y),H=!0)},o(y){b(C.$$.fragment,y),b(v.$$.fragment,y),b(G.$$.fragment,y),H=!1},d(y){y&&(l(s),l(i),l(p),l(w),l($),l(r),l(R),l(Z),l(c),l(k),l(j),l(F)),I(C,y),I(v,y),I(G,y)}}}function Es(B){let s,d;return s=new Q({props:{code:"JTIzJTIwIXBpcCUyMGluc3RhbGwlMjBzbW9sYWdlbnRzJTVCbWx4LWxtJTVEJTBBZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBNTFhNb2RlbCUwQSUwQW1seF9tb2RlbCUyMCUzRCUyME1MWE1vZGVsKCUyMm1seC1jb21tdW5pdHklMkZRd2VuMi41LUNvZGVyLTMyQi1JbnN0cnVjdC00Yml0JTIyKSUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KG1vZGVsJTNEbWx4X21vZGVsJTJDJTIwdG9vbHMlM0QlNUIlNUQlMkMlMjBhZGRfYmFzZV90b29scyUzRFRydWUpJTBBJTBBYWdlbnQucnVuKCUyMkNvdWxkJTIweW91JTIwZ2l2ZSUyMG1lJTIwdGhlJTIwMTE4dGglMjBudW1iZXIlMjBpbiUyMHRoZSUyMEZpYm9uYWNjaSUyMHNlcXVlbmNlJTNGJTIyKQ==",highlighted:`<span class="hljs-comment"># !pip install smolagents[mlx-lm]</span>
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, MLXModel

mlx_model = MLXModel(<span class="hljs-string">&quot;mlx-community/Qwen2.5-Coder-32B-Instruct-4bit&quot;</span>)
agent = CodeAgent(model=mlx_model, tools=[], add_base_tools=<span class="hljs-literal">True</span>)

agent.run(<span class="hljs-string">&quot;Could you give me the 118th number in the Fibonacci sequence?&quot;</span>)`,wrap:!1}}),{c(){m(s.$$.fragment)},l(i){g(s.$$.fragment,i)},m(i,p){h(s,i,p),d=!0},p:O,i(i){d||(f(s.$$.fragment,i),d=!0)},o(i){b(s.$$.fragment,i),d=!1},d(i){I(s,i)}}}function Gs(B){let s,d,i,p,u,w,C,$,r,A,R,v,Z,c;return s=new z({props:{id:"Pick a LLM",option:"Inference Providers",$$slots:{default:[Rs]},$$scope:{ctx:B}}}),i=new z({props:{id:"Pick a LLM",option:"Local Transformers Model",$$slots:{default:[Zs]},$$scope:{ctx:B}}}),u=new z({props:{id:"Pick a LLM",option:"OpenAI or Anthropic API",$$slots:{default:[Ns]},$$scope:{ctx:B}}}),C=new z({props:{id:"Pick a LLM",option:"Ollama",$$slots:{default:[Ws]},$$scope:{ctx:B}}}),r=new z({props:{id:"Pick a LLM",option:"Azure OpenAI",$$slots:{default:[Qs]},$$scope:{ctx:B}}}),R=new z({props:{id:"Pick a LLM",option:"Amazon Bedrock",$$slots:{default:[Fs]},$$scope:{ctx:B}}}),Z=new z({props:{id:"Pick a LLM",option:"mlx-lm",$$slots:{default:[Es]},$$scope:{ctx:B}}}),{c(){m(s.$$.fragment),d=o(),m(i.$$.fragment),p=o(),m(u.$$.fragment),w=o(),m(C.$$.fragment),$=o(),m(r.$$.fragment),A=o(),m(R.$$.fragment),v=o(),m(Z.$$.fragment)},l(M){g(s.$$.fragment,M),d=a(M),g(i.$$.fragment,M),p=a(M),g(u.$$.fragment,M),w=a(M),g(C.$$.fragment,M),$=a(M),g(r.$$.fragment,M),A=a(M),g(R.$$.fragment,M),v=a(M),g(Z.$$.fragment,M)},m(M,k){h(s,M,k),t(M,d,k),h(i,M,k),t(M,p,k),h(u,M,k),t(M,w,k),h(C,M,k),t(M,$,k),h(r,M,k),t(M,A,k),h(R,M,k),t(M,v,k),h(Z,M,k),c=!0},p(M,k){const j={};k&2&&(j.$$scope={dirty:k,ctx:M}),s.$set(j);const N={};k&2&&(N.$$scope={dirty:k,ctx:M}),i.$set(N);const F={};k&2&&(F.$$scope={dirty:k,ctx:M}),u.$set(F);const G={};k&2&&(G.$$scope={dirty:k,ctx:M}),C.$set(G);const H={};k&2&&(H.$$scope={dirty:k,ctx:M}),r.$set(H);const y={};k&2&&(y.$$scope={dirty:k,ctx:M}),R.$set(y);const W={};k&2&&(W.$$scope={dirty:k,ctx:M}),Z.$set(W)},i(M){c||(f(s.$$.fragment,M),f(i.$$.fragment,M),f(u.$$.fragment,M),f(C.$$.fragment,M),f(r.$$.fragment,M),f(R.$$.fragment,M),f(Z.$$.fragment,M),c=!0)},o(M){b(s.$$.fragment,M),b(i.$$.fragment,M),b(u.$$.fragment,M),b(C.$$.fragment,M),b(r.$$.fragment,M),b(R.$$.fragment,M),b(Z.$$.fragment,M),c=!1},d(M){M&&(l(d),l(p),l(w),l($),l(A),l(v)),I(s,M),I(i,M),I(u,M),I(C,M),I(r,M),I(R,M),I(Z,M)}}}function _s(B){let s,d='This definition format is the same as tool schemas used in <code>apply_chat_template</code>, the only difference is the added <code>tool</code> decorator: read more on our tool use API <a href="https://huggingface.co/blog/unified-tool-use#passing-tools-to-a-chat-template" rel="nofollow">here</a>.';return{c(){s=T("p"),s.innerHTML=d},l(i){s=J(i,"P",{"data-svelte-h":!0}),U(s)!=="svelte-1qhpksd"&&(s.innerHTML=d)},m(i,p){t(i,s,p)},p:O,d(i){i&&l(s)}}}function xs(B){let s,d,i,p="The function needs:",u,w,C="<li>A clear name. The name should be descriptive enough of what this tool does to help the LLM brain powering the agent. Since this tool returns the model with the most downloads for a task, let’s name it <code>model_download_tool</code>.</li> <li>Type hints on both inputs and output</li> <li>A description, that includes an ‘Args:’ part where each argument is described (without a type indication this time, it will be pulled from the type hint). Same as for the tool name, this description is an instruction manual for the LLM powering your agent, so do not neglect it.</li>",$,r,A="All these elements will be automatically baked into the agent’s system prompt upon initialization: so strive to make them as clear as possible!",R,v,Z;return s=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjB0b29sJTBBJTBBJTQwdG9vbCUwQWRlZiUyMG1vZGVsX2Rvd25sb2FkX3Rvb2wodGFzayUzQSUyMHN0ciklMjAtJTNFJTIwc3RyJTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyJTBBJTIwJTIwJTIwJTIwVGhpcyUyMGlzJTIwYSUyMHRvb2wlMjB0aGF0JTIwcmV0dXJucyUyMHRoZSUyMG1vc3QlMjBkb3dubG9hZGVkJTIwbW9kZWwlMjBvZiUyMGElMjBnaXZlbiUyMHRhc2slMjBvbiUyMHRoZSUyMEh1Z2dpbmclMjBGYWNlJTIwSHViLiUwQSUyMCUyMCUyMCUyMEl0JTIwcmV0dXJucyUyMHRoZSUyMG5hbWUlMjBvZiUyMHRoZSUyMGNoZWNrcG9pbnQuJTBBJTBBJTIwJTIwJTIwJTIwQXJncyUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRhc2slM0ElMjBUaGUlMjB0YXNrJTIwZm9yJTIwd2hpY2glMjB0byUyMGdldCUyMHRoZSUyMGRvd25sb2FkJTIwY291bnQuJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyJTBBJTIwJTIwJTIwJTIwbW9zdF9kb3dubG9hZGVkX21vZGVsJTIwJTNEJTIwbmV4dChpdGVyKGxpc3RfbW9kZWxzKGZpbHRlciUzRHRhc2slMkMlMjBzb3J0JTNEJTIyZG93bmxvYWRzJTIyJTJDJTIwZGlyZWN0aW9uJTNELTEpKSklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBtb3N0X2Rvd25sb2FkZWRfbW9kZWwuaWQ=",highlighted:`<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_">model_download_tool</span>(<span class="hljs-params">task: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
    <span class="hljs-string">&quot;&quot;&quot;
    This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub.
    It returns the name of the checkpoint.

    Args:
        task: The task for which to get the download count.
    &quot;&quot;&quot;</span>
    most_downloaded_model = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(list_models(<span class="hljs-built_in">filter</span>=task, sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>)))
    <span class="hljs-keyword">return</span> most_downloaded_model.<span class="hljs-built_in">id</span>`,wrap:!1}}),v=new Zl({props:{warning:!1,$$slots:{default:[_s]},$$scope:{ctx:B}}}),{c(){m(s.$$.fragment),d=o(),i=T("p"),i.textContent=p,u=o(),w=T("ul"),w.innerHTML=C,$=o(),r=T("p"),r.textContent=A,R=o(),m(v.$$.fragment)},l(c){g(s.$$.fragment,c),d=a(c),i=J(c,"P",{"data-svelte-h":!0}),U(i)!=="svelte-10btble"&&(i.textContent=p),u=a(c),w=J(c,"UL",{"data-svelte-h":!0}),U(w)!=="svelte-1uouvtx"&&(w.innerHTML=C),$=a(c),r=J(c,"P",{"data-svelte-h":!0}),U(r)!=="svelte-1prqddm"&&(r.textContent=A),R=a(c),g(v.$$.fragment,c)},m(c,M){h(s,c,M),t(c,d,M),t(c,i,M),t(c,u,M),t(c,w,M),t(c,$,M),t(c,r,M),t(c,R,M),h(v,c,M),Z=!0},p(c,M){const k={};M&2&&(k.$$scope={dirty:M,ctx:c}),v.$set(k)},i(c){Z||(f(s.$$.fragment,c),f(v.$$.fragment,c),Z=!0)},o(c){b(s.$$.fragment,c),b(v.$$.fragment,c),Z=!1},d(c){c&&(l(d),l(i),l(u),l(w),l($),l(r),l(R)),I(s,c),I(v,c)}}}function Ss(B){let s,d,i,p="The subclass needs the following attributes:",u,w,C=`<li>A clear <code>name</code>. The name should be descriptive enough of what this tool does to help the LLM brain powering the agent. Since this tool returns the model with the most downloads for a task, let’s name it <code>model_download_tool</code>.</li> <li>A <code>description</code>. Same as for the <code>name</code>, this description is an instruction manual for the LLM powering your agent, so do not neglect it.</li> <li>Input types and descriptions</li> <li>Output type
All these attributes will be automatically baked into the agent’s system prompt upon initialization: so strive to make them as clear as possible!</li>`,$;return s=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBUb29sJTBBJTBBY2xhc3MlMjBNb2RlbERvd25sb2FkVG9vbChUb29sKSUzQSUwQSUyMCUyMCUyMCUyMG5hbWUlMjAlM0QlMjAlMjJtb2RlbF9kb3dubG9hZF90b29sJTIyJTBBJTIwJTIwJTIwJTIwZGVzY3JpcHRpb24lMjAlM0QlMjAlMjJUaGlzJTIwaXMlMjBhJTIwdG9vbCUyMHRoYXQlMjByZXR1cm5zJTIwdGhlJTIwbW9zdCUyMGRvd25sb2FkZWQlMjBtb2RlbCUyMG9mJTIwYSUyMGdpdmVuJTIwdGFzayUyMG9uJTIwdGhlJTIwSHVnZ2luZyUyMEZhY2UlMjBIdWIuJTIwSXQlMjByZXR1cm5zJTIwdGhlJTIwbmFtZSUyMG9mJTIwdGhlJTIwY2hlY2twb2ludC4lMjIlMEElMjAlMjAlMjAlMjBpbnB1dHMlMjAlM0QlMjAlN0IlMjJ0YXNrJTIyJTNBJTIwJTdCJTIydHlwZSUyMiUzQSUyMCUyMnN0cmluZyUyMiUyQyUyMCUyMmRlc2NyaXB0aW9uJTIyJTNBJTIwJTIyVGhlJTIwdGFzayUyMGZvciUyMHdoaWNoJTIwdG8lMjBnZXQlMjB0aGUlMjBkb3dubG9hZCUyMGNvdW50LiUyMiU3RCU3RCUwQSUyMCUyMCUyMCUyMG91dHB1dF90eXBlJTIwJTNEJTIwJTIyc3RyaW5nJTIyJTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwZm9yd2FyZChzZWxmJTJDJTIwdGFzayUzQSUyMHN0ciklMjAtJTNFJTIwc3RyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbW9zdF9kb3dubG9hZGVkX21vZGVsJTIwJTNEJTIwbmV4dChpdGVyKGxpc3RfbW9kZWxzKGZpbHRlciUzRHRhc2slMkMlMjBzb3J0JTNEJTIyZG93bmxvYWRzJTIyJTJDJTIwZGlyZWN0aW9uJTNELTEpKSklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBtb3N0X2Rvd25sb2FkZWRfbW9kZWwuaWQ=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> Tool

<span class="hljs-keyword">class</span> <span class="hljs-title class_">ModelDownloadTool</span>(<span class="hljs-title class_ inherited__">Tool</span>):
    name = <span class="hljs-string">&quot;model_download_tool&quot;</span>
    description = <span class="hljs-string">&quot;This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub. It returns the name of the checkpoint.&quot;</span>
    inputs = {<span class="hljs-string">&quot;task&quot;</span>: {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>, <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;The task for which to get the download count.&quot;</span>}}
    output_type = <span class="hljs-string">&quot;string&quot;</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, task: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
        most_downloaded_model = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(list_models(<span class="hljs-built_in">filter</span>=task, sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>)))
        <span class="hljs-keyword">return</span> most_downloaded_model.<span class="hljs-built_in">id</span>`,wrap:!1}}),{c(){m(s.$$.fragment),d=o(),i=T("p"),i.textContent=p,u=o(),w=T("ul"),w.innerHTML=C},l(r){g(s.$$.fragment,r),d=a(r),i=J(r,"P",{"data-svelte-h":!0}),U(i)!=="svelte-1axnp6t"&&(i.textContent=p),u=a(r),w=J(r,"UL",{"data-svelte-h":!0}),U(w)!=="svelte-1e7an1b"&&(w.innerHTML=C)},m(r,A){h(s,r,A),t(r,d,A),t(r,i,A),t(r,u,A),t(r,w,A),$=!0},p:O,i(r){$||(f(s.$$.fragment,r),$=!0)},o(r){b(s.$$.fragment,r),$=!1},d(r){r&&(l(d),l(i),l(u),l(w)),I(s,r)}}}function Os(B){let s,d,i,p;return s=new z({props:{id:"build-a-tool",option:"Decorate a function with @tool",$$slots:{default:[xs]},$$scope:{ctx:B}}}),i=new z({props:{id:"build-a-tool",option:"Subclass Tool",$$slots:{default:[Ss]},$$scope:{ctx:B}}}),{c(){m(s.$$.fragment),d=o(),m(i.$$.fragment)},l(u){g(s.$$.fragment,u),d=a(u),g(i.$$.fragment,u)},m(u,w){h(s,u,w),t(u,d,w),h(i,u,w),p=!0},p(u,w){const C={};w&2&&(C.$$scope={dirty:w,ctx:u}),s.$set(C);const $={};w&2&&($.$$scope={dirty:w,ctx:u}),i.$set($)},i(u){p||(f(s.$$.fragment,u),f(i.$$.fragment,u),p=!0)},o(u){b(s.$$.fragment,u),b(i.$$.fragment,u),p=!1},d(u){u&&l(d),I(s,u),I(i,u)}}}function Hs(B){let s,d='Read more on tools in the <a href="./tutorials/tools#what-is-a-tool-and-how-to-build-one">dedicated tutorial</a>.';return{c(){s=T("p"),s.innerHTML=d},l(i){s=J(i,"P",{"data-svelte-h":!0}),U(s)!=="svelte-y9zy3b"&&(s.innerHTML=d)},m(i,p){t(i,s,p)},p:O,d(i){i&&l(s)}}}function Ls(B){let s,d='For an in-depth example of an efficient multi-agent implementation, see <a href="https://huggingface.co/blog/beating-gaia" rel="nofollow">how we pushed our multi-agent system to the top of the GAIA leaderboard</a>.';return{c(){s=T("p"),s.innerHTML=d},l(i){s=J(i,"P",{"data-svelte-h":!0}),U(s)!=="svelte-1d151kq"&&(s.innerHTML=d)},m(i,p){t(i,s,p)},p:O,d(i){i&&l(s)}}}function zs(B){let s,d,i,p,u,w,C,$,r,A="In this guided visit, you will learn how to build an agent, how to run it, and how to customize it to make it work better for your use-case.",R,v,Z,c,M=`<code>smolagents</code> comes with two agent classes: <a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.CodeAgent">CodeAgent</a> and <a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.ToolCallingAgent">ToolCallingAgent</a>, which represent two different paradigms for how agents interact with tools.
The key difference lies in how actions are specified and executed: code generation vs structured tool calling.`,k,j,N,F,G='<a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.CodeAgent">CodeAgent</a> generates tool calls as Python code snippets.',H,y,W,mn="The code is executed either locally (potentially unsecure) or in a secure sandbox.",on,fl,gn="Tools are exposed as Python functions (via bindings).",an,bl,Tn,ee,Jn,Il,hn="Strengths:<ul><li>Highly expressive: Allows for complex logic and control flow and can combine tools, loop, transform, reason.</li> <li>Flexible: No need to predefine every possible action, can dynamically generate new actions/tools.</li> <li>Emergent reasoning: Ideal for multi-step problems or dynamic logic.</li></ul>",Mn,Cl,fn="Limitations<ul><li>Risk of errors: Must handle syntax errors, exceptions.</li> <li>Less predictable: More prone to unexpected or unsafe outputs.</li> <li>Requires secure execution environment.</li></ul>",Un,le,jl,bn='<a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.ToolCallingAgent">ToolCallingAgent</a> writes tool calls as structured JSON.',rn,_,kl,In="This is the common format used in many frameworks (OpenAI API), allowing for structured tool interactions without code execution.",pn,$l,Cn="Tools are defined with a JSON schema: name, description, parameter types, etc.",dn,vl,wn,te,un,Bl,jn="Strengths:<ul><li>Reliable: Less prone to hallucination, outputs are structured and validated.</li> <li>Safe: Arguments are strictly validated, no risk of arbitrary code running.</li> <li>Interoperable: Easy to map to external APIs or services.</li></ul>",yn,Vl,kn="Limitations:<ul><li>Low expressivity: Can’t easily combine or transform results dynamically, or perform complex logic or control flow.</li> <li>Inflexible: Must define all possible actions in advance, limited to predefined tools.</li> <li>No code synthesis: Limited to tool capabilities.</li></ul>",Nl,ne,$n="When to use which agent type:",Wl,se,vn='<li><p>Use <a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.CodeAgent">CodeAgent</a> when:</p> <ul><li>You need reasoning, chaining, or dynamic composition.</li> <li>Tools are functions that can be combined (e.g., parsing + math + querying).</li> <li>Your agent is a problem solver or programmer.</li></ul></li> <li><p>Use <a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.ToolCallingAgent">ToolCallingAgent</a> when:</p> <ul><li>You have simple, atomic tools (e.g., call an API, fetch a document).</li> <li>You want high reliability and clear validation.</li> <li>Your agent is like a dispatcher or controller.</li></ul></li>',Ql,oe,Fl,ae,Bn='<a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.CodeAgent">CodeAgent</a> generates Python code snippets to perform actions and solve tasks.',El,ie,Vn=`By default, the Python code execution is done in your local environment.
This should be safe because the only functions that can be called are the tools you provided (especially if it’s only tools by Hugging Face) and a set of predefined safe functions like <code>print</code> or functions from the <code>math</code> module, so you’re already limited in what can be executed.`,Gl,Te,An=`The Python interpreter also doesn’t allow imports by default outside of a safe list, so all the most obvious attacks shouldn’t be an issue.
You can authorize additional imports by passing the authorized modules as a list of strings in argument <code>additional_authorized_imports</code> upon initialization of your <a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.CodeAgent">CodeAgent</a>:`,_l,Je,xl,Me,Rn=`Additionally, as an extra security layer, access to submodule is forbidden by default, unless explicitly authorized within the import list.
For instance, to access the <code>numpy.random</code> submodule, you need to add <code>&#39;numpy.random&#39;</code> to the <code>additional_authorized_imports</code> list.
This could also be authorized by using <code>numpy.*</code>, which will allow <code>numpy</code> as well as any subpackage like <code>numpy.random</code> and its own subpackages.`,Sl,Y,Ol,Ue,Zn="The execution will stop at any code trying to perform an illegal operation or if there is a regular Python error with the code generated by the agent.",Hl,re,Nn='You can also use <a href="https://e2b.dev/docs#what-is-e2-b" rel="nofollow">E2B code executor</a> or Docker instead of a local Python interpreter. For E2B, first <a href="https://e2b.dev/dashboard?tab=keys" rel="nofollow">set the <code>E2B_API_KEY</code> environment variable</a> and then pass <code>executor_type=&quot;e2b&quot;</code> upon agent initialization. For Docker, pass <code>executor_type=&quot;docker&quot;</code> during initialization.',Ll,D,zl,pe,Yl,de,Wn='<a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.ToolCallingAgent">ToolCallingAgent</a> outputs JSON tool calls, which is the common format used in many frameworks (OpenAI API), allowing for structured tool interactions without code execution.',Dl,we,Qn='It works much in the same way like <a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.CodeAgent">CodeAgent</a>, of course without <code>additional_authorized_imports</code> since it doesn’t execute code:',Xl,ue,ql,ye,Pl,ce,Fn="To initialize a minimal agent, you need at least these two arguments:",Kl,me,En='<li><p><code>model</code>, a text-generation model to power your agent - because the agent is different from a simple LLM, it is a system that uses a LLM as its engine. You can use any of these options:</p> <ul><li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.TransformersModel">TransformersModel</a> takes a pre-initialized <code>transformers</code> pipeline to run inference on your local machine using <code>transformers</code>.</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.InferenceClientModel">InferenceClientModel</a> leverages a <code>huggingface_hub.InferenceClient</code> under the hood and supports all Inference Providers on the Hub: Cerebras, Cohere, Fal, Fireworks, HF-Inference, Hyperbolic, Nebius, Novita, Replicate, SambaNova, Together, and more.</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.LiteLLMModel">LiteLLMModel</a> similarly lets you call 100+ different models and providers through <a href="https://docs.litellm.ai/" rel="nofollow">LiteLLM</a>!</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.AzureOpenAIServerModel">AzureOpenAIServerModel</a> allows you to use OpenAI models deployed in <a href="https://azure.microsoft.com/en-us/products/ai-services/openai-service" rel="nofollow">Azure</a>.</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.AmazonBedrockServerModel">AmazonBedrockServerModel</a> allows you to use Amazon Bedrock in <a href="https://aws.amazon.com/bedrock/?nc1=h_ls" rel="nofollow">AWS</a>.</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.MLXModel">MLXModel</a> creates a <a href="https://pypi.org/project/mlx-lm/" rel="nofollow">mlx-lm</a> pipeline to run inference on your local machine.</li></ul></li> <li><p><code>tools</code>, a list of <code>Tools</code> that the agent can use to solve the task. It can be an empty list. You can also add the default toolbox on top of your <code>tools</code> list by defining the optional argument <code>add_base_tools=True</code>.</p></li>',et,ge,Gn='Once you have these two arguments, <code>tools</code> and <code>model</code>,  you can create an agent and run it. You can use any LLM you’d like, either through <a href="https://huggingface.co/blog/inference-providers" rel="nofollow">Inference Providers</a>, <a href="https://github.com/huggingface/transformers/" rel="nofollow">transformers</a>, <a href="https://ollama.com/" rel="nofollow">ollama</a>, <a href="https://www.litellm.ai/" rel="nofollow">LiteLLM</a>, <a href="https://azure.microsoft.com/en-us/products/ai-services/openai-service" rel="nofollow">Azure OpenAI</a>, <a href="https://aws.amazon.com/bedrock/?nc1=h_ls" rel="nofollow">Amazon Bedrock</a>, or <a href="https://pypi.org/project/mlx-lm/" rel="nofollow">mlx-lm</a>.',lt,X,tt,he,nt,fe,st,be,_n=`By default, an agent continues running until it calls the <code>final_answer</code> function or reaches the maximum number of steps.
The <code>final_answer_checks</code> parameter gives you more control over when and how an agent terminates its execution:`,ot,Ie,at,Ce,xn="The <code>final_answer_checks</code> parameter accepts a list of functions that each:",it,je,Sn="<li>Take the agent’s final_answer string the agent’s memory as parameters</li> <li>Return a boolean indicating whether the final_answer is valid (True) or not (False)</li>",Tt,ke,On=`If any function returns <code>False</code>, the agent will log the error message and continue the run.
This validation mechanism enables:`,Jt,$e,Hn="<li>Enforcing output format requirements (e.g., ensuring numeric answers for math problems)</li> <li>Implementing domain-specific validation rules</li> <li>Creating more robust agents that validate their own outputs</li>",Mt,ve,Ut,Be,Ln="Here are a few useful attributes to inspect what happened after a run:",rt,Ve,zn="<li><code>agent.logs</code> stores the fine-grained logs of the agent. At every step of the agent’s run, everything gets stored in a dictionary that then is appended to <code>agent.logs</code>.</li> <li>Running <code>agent.write_memory_to_messages()</code> writes the agent’s memory as list of chat messages for the Model to view. This method goes over each step of the log and only stores what it’s interested in as a message: for instance, it will save the system prompt and task in separate messages, then for each step it will store the LLM output as a message, and the tool call output as another message. Use this if you want a higher-level view of what has happened - but not every log will be transcripted by this method.</li>",pt,Ae,dt,Re,Yn="A tool is an atomic function to be used by an agent. To be used by an LLM, it also needs a few attributes that constitute its API and will be used to describe to the LLM how to call this tool:",wt,Ze,Dn="<li>A name</li> <li>A description</li> <li>Input types and descriptions</li> <li>An output type</li>",ut,Ne,Xn='You can for instance check the <a href="/docs/smolagents/v1.21.1/en/reference/default_tools#smolagents.PythonInterpreterTool">PythonInterpreterTool</a>: it has a name, a description, input descriptions, an output type, and a <code>forward</code> method to perform the action.',yt,We,qn="When the agent is initialized, the tool attributes are used to generate a tool description which is baked into the agent’s system prompt. This lets the agent know which tools it can use and why.",ct,Qe,mt,Fe,Pn="If you install <code>smolagents</code> with the “toolkit” extra, it comes with a default toolbox for empowering agents, that you can add to your agent upon initialization with argument <code>add_base_tools=True</code>:",gt,Ee,Kn='<li><strong>DuckDuckGo web search*</strong>: performs a web search using DuckDuckGo browser.</li> <li><strong>Python code interpreter</strong>: runs your LLM generated Python code in a secure environment. This tool will only be added to <a href="/docs/smolagents/v1.21.1/en/reference/agents#smolagents.ToolCallingAgent">ToolCallingAgent</a> if you initialize it with <code>add_base_tools=True</code>, since code-based agent can already natively execute Python code</li> <li><strong>Transcriber</strong>: a speech-to-text pipeline built on Whisper-Turbo that transcribes an audio to text.</li>',ht,Ge,es="You can manually use a tool by calling it with its arguments.",ft,_e,bt,xe,It,Se,ls=`You can create your own tool for use cases not covered by the default tools from Hugging Face.
For example, let’s create a tool that returns the most downloaded model for a given task from the Hub.`,Ct,Oe,ts="You’ll start with the code below.",jt,He,kt,Le,ns=`This code can quickly be converted into a tool, just by wrapping it in a function and adding the <code>tool</code> decorator:
This is not the only way to build the tool: you can directly define it as a subclass of <a href="/docs/smolagents/v1.21.1/en/reference/tools#smolagents.Tool">Tool</a>, which gives you more flexibility, for instance the possibility to initialize heavy class attributes.`,$t,ze,ss="Let’s see how it works for both options:",vt,q,Bt,Ye,os="Then you can directly initialize your agent:",Vt,De,At,Xe,as="You get the following logs:",Rt,qe,Zt,P,Nt,Pe,Wt,Ke,is='Multi-agent systems have been introduced with Microsoft’s framework <a href="https://huggingface.co/papers/2308.08155" rel="nofollow">Autogen</a>.',Qt,el,Ts=`In this type of framework, you have several agents working together to solve your task instead of only one.
It empirically yields better performance on most benchmarks. The reason for this better performance is conceptually simple: for many tasks, rather than using a do-it-all system, you would prefer to specialize units on sub-tasks. Here, having agents with separate tool sets and memories allows to achieve efficient specialization. For instance, why fill the memory of the code generating agent with all the content of webpages visited by the web search agent? It’s better to keep them separate.`,Ft,ll,Js="You can easily build hierarchical multi-agent systems with <code>smolagents</code>.",Et,tl,Ms=`To do so, just ensure your agent has <code>name</code> and<code>description</code> attributes, which will then be embedded in the manager agent’s system prompt to let it know how to call this managed agent, as we also do for tools.
Then you can pass this managed agent in the parameter managed_agents upon initialization of the manager agent.`,Gt,nl,Us='Here’s an example of making an agent that managed a specific web search agent using our native <a href="/docs/smolagents/v1.21.1/en/reference/default_tools#smolagents.WebSearchTool">WebSearchTool</a>:',_t,sl,xt,K,St,ol,Ot,al,rs="You can use <code>GradioUI</code> to interactively submit tasks to your agent and observe its thought and execution process, here is an example:",Ht,il,Lt,Tl,ps=`Under the hood, when the user types a new answer, the agent is launched with <code>agent.run(user_request, reset=False)</code>.
The <code>reset=False</code> flag means the agent’s memory is not flushed before launching this new task, which lets the conversation go on.`,zt,Jl,ds="You can also use this <code>reset=False</code> argument to keep the conversation going in any other agentic application.",Yt,Ml,ws=`In gradio UIs, if you want to allow users to interrupt a running agent, you could do this with a button that triggers method <code>agent.interrupt()</code>.
This will stop the agent at the end of its current step, then raise an error.`,Dt,Ul,Xt,rl,us="Finally, when you’ve configured your agent to your needs, you can share it to the Hub!",qt,pl,Pt,dl,ys="Similarly, to load an agent that has been pushed to hub, if you trust the code from its tools, use:",Kt,wl,en,ul,cs="For more in-depth usage, you will then want to check out our tutorials:",ln,yl,ms='<li><a href="./tutorials/secure_code_execution">the explanation of how our code agents work</a></li> <li><a href="./tutorials/building_good_agents">this guide on how to build good agents</a>.</li> <li><a href="./tutorials/building_good_agents">the in-depth guide for tool usage</a>.</li>',tn,cl,nn,Rl,sn;return u=new E({props:{title:"Agents - Guided tour",local:"agents---guided-tour",headingTag:"h1"}}),C=new vs({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/en/guided_tour.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/en/pytorch/guided_tour.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/en/tensorflow/guided_tour.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/en/guided_tour.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/en/pytorch/guided_tour.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/en/tensorflow/guided_tour.ipynb"}]}}),v=new E({props:{title:"Choosing an agent type: CodeAgent or ToolCallingAgent",local:"choosing-an-agent-type-codeagent-or-toolcallingagent",headingTag:"h2"}}),ee=new Q({props:{code:"cmVzdWx0JTIwJTNEJTIwc2VhcmNoX2RvY3MoJTIyV2hhdCUyMGlzJTIwdGhlJTIwY2FwaXRhbCUyMG9mJTIwRnJhbmNlJTNGJTIyKSUwQXByaW50KHJlc3VsdCk=",highlighted:`result = search_docs(<span class="hljs-string">&quot;What is the capital of France?&quot;</span>)
<span class="hljs-built_in">print</span>(result)`,wrap:!1}}),te=new Q({props:{code:"JTdCJTBBJTIwJTIwJTIydG9vbF9jYWxsJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIybmFtZSUyMiUzQSUyMCUyMnNlYXJjaF9kb2NzJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyYXJndW1lbnRzJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIycXVlcnklMjIlM0ElMjAlMjJXaGF0JTIwaXMlMjB0aGUlMjBjYXBpdGFsJTIwb2YlMjBGcmFuY2UlM0YlMjIlMEElMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlN0QlMEElN0Q=",highlighted:`<span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;tool_call&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;name&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;search_docs&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;arguments&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">&quot;query&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;What is the capital of France?&quot;</span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span>`,wrap:!1}}),oe=new E({props:{title:"CodeAgent",local:"codeagent",headingTag:"h2"}}),Je=new Q({props:{code:"bW9kZWwlMjAlM0QlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCgpJTBBYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQodG9vbHMlM0QlNUIlNUQlMkMlMjBtb2RlbCUzRG1vZGVsJTJDJTIwYWRkaXRpb25hbF9hdXRob3JpemVkX2ltcG9ydHMlM0QlNUIncmVxdWVzdHMnJTJDJTIwJ2JzNCclNUQpJTBBYWdlbnQucnVuKCUyMkNvdWxkJTIweW91JTIwZ2V0JTIwbWUlMjB0aGUlMjB0aXRsZSUyMG9mJTIwdGhlJTIwcGFnZSUyMGF0JTIwdXJsJTIwJ2h0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZibG9nJyUzRiUyMik=",highlighted:`model = InferenceClientModel()
agent = CodeAgent(tools=[], model=model, additional_authorized_imports=[<span class="hljs-string">&#x27;requests&#x27;</span>, <span class="hljs-string">&#x27;bs4&#x27;</span>])
agent.run(<span class="hljs-string">&quot;Could you get me the title of the page at url &#x27;https://huggingface.co/blog&#x27;?&quot;</span>)`,wrap:!1}}),Y=new Zl({props:{warning:!0,$$slots:{default:[Vs]},$$scope:{ctx:B}}}),D=new Zl({props:{warning:!1,$$slots:{default:[As]},$$scope:{ctx:B}}}),pe=new E({props:{title:"ToolCallingAgent",local:"toolcallingagent",headingTag:"h3"}}),ue=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBUb29sQ2FsbGluZ0FnZW50JTBBJTBBYWdlbnQlMjAlM0QlMjBUb29sQ2FsbGluZ0FnZW50KHRvb2xzJTNEJTVCJTVEJTJDJTIwbW9kZWwlM0Rtb2RlbCklMEFhZ2VudC5ydW4oJTIyQ291bGQlMjB5b3UlMjBnZXQlMjBtZSUyMHRoZSUyMHRpdGxlJTIwb2YlMjB0aGUlMjBwYWdlJTIwYXQlMjB1cmwlMjAnaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmJsb2cnJTNGJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> ToolCallingAgent

agent = ToolCallingAgent(tools=[], model=model)
agent.run(<span class="hljs-string">&quot;Could you get me the title of the page at url &#x27;https://huggingface.co/blog&#x27;?&quot;</span>)`,wrap:!1}}),ye=new E({props:{title:"Building your agent",local:"building-your-agent",headingTag:"h2"}}),X=new bs({props:{id:"Pick a LLM",options:["Inference Providers","Local Transformers Model","OpenAI or Anthropic API","Ollama","Azure OpenAI","Amazon Bedrock","mlx-lm"],$$slots:{default:[Gs]},$$scope:{ctx:B}}}),he=new E({props:{title:"Advanced agent configuration",local:"advanced-agent-configuration",headingTag:"h2"}}),fe=new E({props:{title:"Customizing agent termination conditions",local:"customizing-agent-termination-conditions",headingTag:"h3"}}),Ie=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUwQSUwQSUyMyUyMERlZmluZSUyMGElMjBjdXN0b20lMjBmaW5hbCUyMGFuc3dlciUyMGNoZWNrJTIwZnVuY3Rpb24lMEFkZWYlMjBpc19pbnRlZ2VyKGZpbmFsX2Fuc3dlciUzQSUyMHN0ciUyQyUyMGFnZW50X21lbW9yeSUzRE5vbmUpJTIwLSUzRSUyMGJvb2wlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjJSZXR1cm4lMjBUcnVlJTIwaWYlMjBmaW5hbF9hbnN3ZXIlMjBpcyUyMGFuJTIwaW50ZWdlci4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjB0cnklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnQoZmluYWxfYW5zd2VyKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMFRydWUlMEElMjAlMjAlMjAlMjBleGNlcHQlMjBWYWx1ZUVycm9yJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwRmFsc2UlMEElMEElMjMlMjBJbml0aWFsaXplJTIwYWdlbnQlMjB3aXRoJTIwY3VzdG9tJTIwZmluYWwlMjBhbnN3ZXIlMjBjaGVjayUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KCUwQSUyMCUyMCUyMCUyMHRvb2xzJTNEJTVCJTVEJTJDJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0RJbmZlcmVuY2VDbGllbnRNb2RlbCgpJTJDJTBBJTIwJTIwJTIwJTIwZmluYWxfYW5zd2VyX2NoZWNrcyUzRCU1QmlzX2ludGVnZXIlNUQlMEEpJTBBJTBBYWdlbnQucnVuKCUyMkNhbGN1bGF0ZSUyMHRoZSUyMGxlYXN0JTIwY29tbW9uJTIwbXVsdGlwbGUlMjBvZiUyMDMlMjBhbmQlMjA3JTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, InferenceClientModel

<span class="hljs-comment"># Define a custom final answer check function</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">is_integer</span>(<span class="hljs-params">final_answer: <span class="hljs-built_in">str</span>, agent_memory=<span class="hljs-literal">None</span></span>) -&gt; <span class="hljs-built_in">bool</span>:
    <span class="hljs-string">&quot;&quot;&quot;Return True if final_answer is an integer.&quot;&quot;&quot;</span>
    <span class="hljs-keyword">try</span>:
        <span class="hljs-built_in">int</span>(final_answer)
        <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span>
    <span class="hljs-keyword">except</span> ValueError:
        <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span>

<span class="hljs-comment"># Initialize agent with custom final answer check</span>
agent = CodeAgent(
    tools=[],
    model=InferenceClientModel(),
    final_answer_checks=[is_integer]
)

agent.run(<span class="hljs-string">&quot;Calculate the least common multiple of 3 and 7&quot;</span>)`,wrap:!1}}),ve=new E({props:{title:"Inspecting an agent run",local:"inspecting-an-agent-run",headingTag:"h2"}}),Ae=new E({props:{title:"Tools",local:"tools",headingTag:"h2"}}),Qe=new E({props:{title:"Default toolbox",local:"default-toolbox",headingTag:"h3"}}),_e=new Q({props:{code:"JTIzJTIwIXBpcCUyMGluc3RhbGwlMjBzbW9sYWdlbnRzJTVCdG9vbGtpdCU1RCUwQWZyb20lMjBzbW9sYWdlbnRzJTIwaW1wb3J0JTIwV2ViU2VhcmNoVG9vbCUwQSUwQXNlYXJjaF90b29sJTIwJTNEJTIwV2ViU2VhcmNoVG9vbCgpJTBBcHJpbnQoc2VhcmNoX3Rvb2woJTIyV2hvJ3MlMjB0aGUlMjBjdXJyZW50JTIwcHJlc2lkZW50JTIwb2YlMjBSdXNzaWElM0YlMjIpKQ==",highlighted:`<span class="hljs-comment"># !pip install smolagents[toolkit]</span>
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> WebSearchTool

search_tool = WebSearchTool()
<span class="hljs-built_in">print</span>(search_tool(<span class="hljs-string">&quot;Who&#x27;s the current president of Russia?&quot;</span>))`,wrap:!1}}),xe=new E({props:{title:"Create a new tool",local:"create-a-new-tool",headingTag:"h3"}}),He=new Q({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGxpc3RfbW9kZWxzJTBBJTBBdGFzayUyMCUzRCUyMCUyMnRleHQtY2xhc3NpZmljYXRpb24lMjIlMEElMEFtb3N0X2Rvd25sb2FkZWRfbW9kZWwlMjAlM0QlMjBuZXh0KGl0ZXIobGlzdF9tb2RlbHMoZmlsdGVyJTNEdGFzayUyQyUyMHNvcnQlM0QlMjJkb3dubG9hZHMlMjIlMkMlMjBkaXJlY3Rpb24lM0QtMSkpKSUwQXByaW50KG1vc3RfZG93bmxvYWRlZF9tb2RlbC5pZCk=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> list_models

task = <span class="hljs-string">&quot;text-classification&quot;</span>

most_downloaded_model = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(list_models(<span class="hljs-built_in">filter</span>=task, sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>)))
<span class="hljs-built_in">print</span>(most_downloaded_model.<span class="hljs-built_in">id</span>)`,wrap:!1}}),q=new bs({props:{id:"build-a-tool",options:["Decorate a function with @tool","Subclass Tool"],$$slots:{default:[Os]},$$scope:{ctx:B}}}),De=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCbW9kZWxfZG93bmxvYWRfdG9vbCU1RCUyQyUyMG1vZGVsJTNESW5mZXJlbmNlQ2xpZW50TW9kZWwoKSklMEFhZ2VudC5ydW4oJTBBJTIwJTIwJTIwJTIwJTIyQ2FuJTIweW91JTIwZ2l2ZSUyMG1lJTIwdGhlJTIwbmFtZSUyMG9mJTIwdGhlJTIwbW9kZWwlMjB0aGF0JTIwaGFzJTIwdGhlJTIwbW9zdCUyMGRvd25sb2FkcyUyMGluJTIwdGhlJTIwJ3RleHQtdG8tdmlkZW8nJTIwdGFzayUyMG9uJTIwdGhlJTIwSHVnZ2luZyUyMEZhY2UlMjBIdWIlM0YlMjIlMEEp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, InferenceClientModel
agent = CodeAgent(tools=[model_download_tool], model=InferenceClientModel())
agent.run(
    <span class="hljs-string">&quot;Can you give me the name of the model that has the most downloads in the &#x27;text-to-video&#x27; task on the Hugging Face Hub?&quot;</span>
)`,wrap:!1}}),qe=new Q({props:{code:" ",highlighted:`╭──────────────────────────────────────── New run ─────────────────────────────────────────╮
│                                                                                          │
│ Can you give me the name of the model that has the most downloads in the &#x27;text-to-video&#x27; │
│ task on the Hugging Face Hub?                                                            │
│                                                                                          │
╰─ InferenceClientModel - Qwen/Qwen2.5-Coder-32B-Instruct ───────────────────────────────────────────╯
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 0 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╭─ Executing this code: ───────────────────────────────────────────────────────────────────╮
│   1 model_name = model_download_tool(task=&quot;text-to-video&quot;)                               │
│   2 print(model_name)                                                                    │
╰──────────────────────────────────────────────────────────────────────────────────────────╯
Execution logs:
ByteDance/AnimateDiff-Lightning

Out: None
[Step 0: Duration 0.27 seconds| Input tokens: 2,069 | Output tokens: 60]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╭─ Executing this code: ───────────────────────────────────────────────────────────────────╮
│   1 final_answer(&quot;ByteDance/AnimateDiff-Lightning&quot;)                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────╯
Out - Final answer: ByteDance/AnimateDiff-Lightning
[Step 1: Duration 0.10 seconds| Input tokens: 4,288 | Output tokens: 148]
Out[20]: &#x27;ByteDance/AnimateDiff-Lightning&#x27;`,wrap:!1}}),P=new Zl({props:{warning:!1,$$slots:{default:[Hs]},$$scope:{ctx:B}}}),Pe=new E({props:{title:"Multi-agents",local:"multi-agents",headingTag:"h2"}}),sl=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBDb2RlQWdlbnQlMkMlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUyQyUyMFdlYlNlYXJjaFRvb2wlMEElMEFtb2RlbCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudE1vZGVsKCklMEElMEF3ZWJfYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQoJTBBJTIwJTIwJTIwJTIwdG9vbHMlM0QlNUJXZWJTZWFyY2hUb29sKCklNUQlMkMlMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwbmFtZSUzRCUyMndlYl9zZWFyY2hfYWdlbnQlMjIlMkMlMEElMjAlMjAlMjAlMjBkZXNjcmlwdGlvbiUzRCUyMlJ1bnMlMjB3ZWIlMjBzZWFyY2hlcyUyMGZvciUyMHlvdS4lMjBHaXZlJTIwaXQlMjB5b3VyJTIwcXVlcnklMjBhcyUyMGFuJTIwYXJndW1lbnQuJTIyJTBBKSUwQSUwQW1hbmFnZXJfYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQoJTBBJTIwJTIwJTIwJTIwdG9vbHMlM0QlNUIlNUQlMkMlMjBtb2RlbCUzRG1vZGVsJTJDJTIwbWFuYWdlZF9hZ2VudHMlM0QlNUJ3ZWJfYWdlbnQlNUQlMEEpJTBBJTBBbWFuYWdlcl9hZ2VudC5ydW4oJTIyV2hvJTIwaXMlMjB0aGUlMjBDRU8lMjBvZiUyMEh1Z2dpbmclMjBGYWNlJTNGJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> CodeAgent, InferenceClientModel, WebSearchTool

model = InferenceClientModel()

web_agent = CodeAgent(
    tools=[WebSearchTool()],
    model=model,
    name=<span class="hljs-string">&quot;web_search_agent&quot;</span>,
    description=<span class="hljs-string">&quot;Runs web searches for you. Give it your query as an argument.&quot;</span>
)

manager_agent = CodeAgent(
    tools=[], model=model, managed_agents=[web_agent]
)

manager_agent.run(<span class="hljs-string">&quot;Who is the CEO of Hugging Face?&quot;</span>)`,wrap:!1}}),K=new Zl({props:{warning:!1,$$slots:{default:[Ls]},$$scope:{ctx:B}}}),ol=new E({props:{title:"Talk with your agent and visualize its thoughts in a cool Gradio interface",local:"talk-with-your-agent-and-visualize-its-thoughts-in-a-cool-gradio-interface",headingTag:"h2"}}),il=new Q({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjAoJTBBJTIwJTIwJTIwJTIwbG9hZF90b29sJTJDJTBBJTIwJTIwJTIwJTIwQ29kZUFnZW50JTJDJTBBJTIwJTIwJTIwJTIwSW5mZXJlbmNlQ2xpZW50TW9kZWwlMkMlMEElMjAlMjAlMjAlMjBHcmFkaW9VSSUwQSklMEElMEElMjMlMjBJbXBvcnQlMjB0b29sJTIwZnJvbSUyMEh1YiUwQWltYWdlX2dlbmVyYXRpb25fdG9vbCUyMCUzRCUyMGxvYWRfdG9vbCglMjJtLXJpYyUyRnRleHQtdG8taW1hZ2UlMjIlMkMlMjB0cnVzdF9yZW1vdGVfY29kZSUzRFRydWUpJTBBJTBBbW9kZWwlMjAlM0QlMjBJbmZlcmVuY2VDbGllbnRNb2RlbChtb2RlbF9pZCUzRG1vZGVsX2lkKSUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjB0aGUlMjBhZ2VudCUyMHdpdGglMjB0aGUlMjBpbWFnZSUyMGdlbmVyYXRpb24lMjB0b29sJTBBYWdlbnQlMjAlM0QlMjBDb2RlQWdlbnQodG9vbHMlM0QlNUJpbWFnZV9nZW5lcmF0aW9uX3Rvb2wlNUQlMkMlMjBtb2RlbCUzRG1vZGVsKSUwQSUwQUdyYWRpb1VJKGFnZW50KS5sYXVuY2goKQ==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> (
    load_tool,
    CodeAgent,
    InferenceClientModel,
    GradioUI
)

<span class="hljs-comment"># Import tool from Hub</span>
image_generation_tool = load_tool(<span class="hljs-string">&quot;m-ric/text-to-image&quot;</span>, trust_remote_code=<span class="hljs-literal">True</span>)

model = InferenceClientModel(model_id=model_id)

<span class="hljs-comment"># Initialize the agent with the image generation tool</span>
agent = CodeAgent(tools=[image_generation_tool], model=model)

GradioUI(agent).launch()`,wrap:!1}}),Ul=new E({props:{title:"Next steps",local:"next-steps",headingTag:"h2"}}),pl=new Q({props:{code:"YWdlbnQucHVzaF90b19odWIoJTIybS1yaWMlMkZteV9hZ2VudCUyMik=",highlighted:'agent.push_to_hub(<span class="hljs-string">&quot;m-ric/my_agent&quot;</span>)',wrap:!1}}),wl=new Q({props:{code:"YWdlbnQuZnJvbV9odWIoJTIybS1yaWMlMkZteV9hZ2VudCUyMiUyQyUyMHRydXN0X3JlbW90ZV9jb2RlJTNEVHJ1ZSk=",highlighted:'agent.from_hub(<span class="hljs-string">&quot;m-ric/my_agent&quot;</span>, trust_remote_code=<span class="hljs-literal">True</span>)',wrap:!1}}),cl=new Bs({props:{source:"https://github.com/huggingface/smolagents/blob/main/docs/source/en/guided_tour.md"}}),{c(){s=T("meta"),d=o(),i=T("p"),p=o(),m(u.$$.fragment),w=o(),m(C.$$.fragment),$=o(),r=T("p"),r.textContent=A,R=o(),m(v.$$.fragment),Z=o(),c=T("p"),c.innerHTML=M,k=o(),j=T("ul"),N=T("li"),F=T("p"),F.innerHTML=G,H=o(),y=T("ul"),W=T("li"),W.textContent=mn,on=o(),fl=T("li"),fl.textContent=gn,an=o(),bl=T("li"),Tn=gs(`Example of tool call:
	`),m(ee.$$.fragment),Jn=o(),Il=T("li"),Il.innerHTML=hn,Mn=o(),Cl=T("li"),Cl.innerHTML=fn,Un=o(),le=T("li"),jl=T("p"),jl.innerHTML=bn,rn=o(),_=T("ul"),kl=T("li"),kl.textContent=In,pn=o(),$l=T("li"),$l.textContent=Cn,dn=o(),vl=T("li"),wn=gs(`Example of tool call:
	`),m(te.$$.fragment),un=o(),Bl=T("li"),Bl.innerHTML=jn,yn=o(),Vl=T("li"),Vl.innerHTML=kn,Nl=o(),ne=T("p"),ne.textContent=$n,Wl=o(),se=T("ul"),se.innerHTML=vn,Ql=o(),m(oe.$$.fragment),Fl=o(),ae=T("p"),ae.innerHTML=Bn,El=o(),ie=T("p"),ie.innerHTML=Vn,Gl=o(),Te=T("p"),Te.innerHTML=An,_l=o(),m(Je.$$.fragment),xl=o(),Me=T("p"),Me.innerHTML=Rn,Sl=o(),m(Y.$$.fragment),Ol=o(),Ue=T("p"),Ue.textContent=Zn,Hl=o(),re=T("p"),re.innerHTML=Nn,Ll=o(),m(D.$$.fragment),zl=o(),m(pe.$$.fragment),Yl=o(),de=T("p"),de.innerHTML=Wn,Dl=o(),we=T("p"),we.innerHTML=Qn,Xl=o(),m(ue.$$.fragment),ql=o(),m(ye.$$.fragment),Pl=o(),ce=T("p"),ce.textContent=Fn,Kl=o(),me=T("ul"),me.innerHTML=En,et=o(),ge=T("p"),ge.innerHTML=Gn,lt=o(),m(X.$$.fragment),tt=o(),m(he.$$.fragment),nt=o(),m(fe.$$.fragment),st=o(),be=T("p"),be.innerHTML=_n,ot=o(),m(Ie.$$.fragment),at=o(),Ce=T("p"),Ce.innerHTML=xn,it=o(),je=T("ul"),je.innerHTML=Sn,Tt=o(),ke=T("p"),ke.innerHTML=On,Jt=o(),$e=T("ul"),$e.innerHTML=Hn,Mt=o(),m(ve.$$.fragment),Ut=o(),Be=T("p"),Be.textContent=Ln,rt=o(),Ve=T("ul"),Ve.innerHTML=zn,pt=o(),m(Ae.$$.fragment),dt=o(),Re=T("p"),Re.textContent=Yn,wt=o(),Ze=T("ul"),Ze.innerHTML=Dn,ut=o(),Ne=T("p"),Ne.innerHTML=Xn,yt=o(),We=T("p"),We.textContent=qn,ct=o(),m(Qe.$$.fragment),mt=o(),Fe=T("p"),Fe.innerHTML=Pn,gt=o(),Ee=T("ul"),Ee.innerHTML=Kn,ht=o(),Ge=T("p"),Ge.textContent=es,ft=o(),m(_e.$$.fragment),bt=o(),m(xe.$$.fragment),It=o(),Se=T("p"),Se.textContent=ls,Ct=o(),Oe=T("p"),Oe.textContent=ts,jt=o(),m(He.$$.fragment),kt=o(),Le=T("p"),Le.innerHTML=ns,$t=o(),ze=T("p"),ze.textContent=ss,vt=o(),m(q.$$.fragment),Bt=o(),Ye=T("p"),Ye.textContent=os,Vt=o(),m(De.$$.fragment),At=o(),Xe=T("p"),Xe.textContent=as,Rt=o(),m(qe.$$.fragment),Zt=o(),m(P.$$.fragment),Nt=o(),m(Pe.$$.fragment),Wt=o(),Ke=T("p"),Ke.innerHTML=is,Qt=o(),el=T("p"),el.textContent=Ts,Ft=o(),ll=T("p"),ll.innerHTML=Js,Et=o(),tl=T("p"),tl.innerHTML=Ms,Gt=o(),nl=T("p"),nl.innerHTML=Us,_t=o(),m(sl.$$.fragment),xt=o(),m(K.$$.fragment),St=o(),m(ol.$$.fragment),Ot=o(),al=T("p"),al.innerHTML=rs,Ht=o(),m(il.$$.fragment),Lt=o(),Tl=T("p"),Tl.innerHTML=ps,zt=o(),Jl=T("p"),Jl.innerHTML=ds,Yt=o(),Ml=T("p"),Ml.innerHTML=ws,Dt=o(),m(Ul.$$.fragment),Xt=o(),rl=T("p"),rl.textContent=us,qt=o(),m(pl.$$.fragment),Pt=o(),dl=T("p"),dl.textContent=ys,Kt=o(),m(wl.$$.fragment),en=o(),ul=T("p"),ul.textContent=cs,ln=o(),yl=T("ul"),yl.innerHTML=ms,tn=o(),m(cl.$$.fragment),nn=o(),Rl=T("p"),this.h()},l(e){const n=$s("svelte-u9bgzb",document.head);s=J(n,"META",{name:!0,content:!0}),n.forEach(l),d=a(e),i=J(e,"P",{}),L(i).forEach(l),p=a(e),g(u.$$.fragment,e),w=a(e),g(C.$$.fragment,e),$=a(e),r=J(e,"P",{"data-svelte-h":!0}),U(r)!=="svelte-c0efqa"&&(r.textContent=A),R=a(e),g(v.$$.fragment,e),Z=a(e),c=J(e,"P",{"data-svelte-h":!0}),U(c)!=="svelte-1o33qv6"&&(c.innerHTML=M),k=a(e),j=J(e,"UL",{});var ml=L(j);N=J(ml,"LI",{});var gl=L(N);F=J(gl,"P",{"data-svelte-h":!0}),U(F)!=="svelte-1htqzzi"&&(F.innerHTML=G),H=a(gl),y=J(gl,"UL",{});var x=L(y);W=J(x,"LI",{"data-svelte-h":!0}),U(W)!=="svelte-162n4d9"&&(W.textContent=mn),on=a(x),fl=J(x,"LI",{"data-svelte-h":!0}),U(fl)!=="svelte-8tmb6j"&&(fl.textContent=gn),an=a(x),bl=J(x,"LI",{});var Al=L(bl);Tn=hs(Al,`Example of tool call:
	`),g(ee.$$.fragment,Al),Al.forEach(l),Jn=a(x),Il=J(x,"LI",{"data-svelte-h":!0}),U(Il)!=="svelte-lcg58m"&&(Il.innerHTML=hn),Mn=a(x),Cl=J(x,"LI",{"data-svelte-h":!0}),U(Cl)!=="svelte-1aoquu3"&&(Cl.innerHTML=fn),x.forEach(l),gl.forEach(l),Un=a(ml),le=J(ml,"LI",{});var hl=L(le);jl=J(hl,"P",{"data-svelte-h":!0}),U(jl)!=="svelte-1qr3hxu"&&(jl.innerHTML=bn),rn=a(hl),_=J(hl,"UL",{});var S=L(_);kl=J(S,"LI",{"data-svelte-h":!0}),U(kl)!=="svelte-zh2lf7"&&(kl.textContent=In),pn=a(S),$l=J(S,"LI",{"data-svelte-h":!0}),U($l)!=="svelte-11jmc23"&&($l.textContent=Cn),dn=a(S),vl=J(S,"LI",{});var cn=L(vl);wn=hs(cn,`Example of tool call:
	`),g(te.$$.fragment,cn),cn.forEach(l),un=a(S),Bl=J(S,"LI",{"data-svelte-h":!0}),U(Bl)!=="svelte-1mp0djq"&&(Bl.innerHTML=jn),yn=a(S),Vl=J(S,"LI",{"data-svelte-h":!0}),U(Vl)!=="svelte-xj73p6"&&(Vl.innerHTML=kn),S.forEach(l),hl.forEach(l),ml.forEach(l),Nl=a(e),ne=J(e,"P",{"data-svelte-h":!0}),U(ne)!=="svelte-hdti8c"&&(ne.textContent=$n),Wl=a(e),se=J(e,"UL",{"data-svelte-h":!0}),U(se)!=="svelte-1npcq4r"&&(se.innerHTML=vn),Ql=a(e),g(oe.$$.fragment,e),Fl=a(e),ae=J(e,"P",{"data-svelte-h":!0}),U(ae)!=="svelte-12qyqd8"&&(ae.innerHTML=Bn),El=a(e),ie=J(e,"P",{"data-svelte-h":!0}),U(ie)!=="svelte-j8myns"&&(ie.innerHTML=Vn),Gl=a(e),Te=J(e,"P",{"data-svelte-h":!0}),U(Te)!=="svelte-rp3rke"&&(Te.innerHTML=An),_l=a(e),g(Je.$$.fragment,e),xl=a(e),Me=J(e,"P",{"data-svelte-h":!0}),U(Me)!=="svelte-1gm9mfe"&&(Me.innerHTML=Rn),Sl=a(e),g(Y.$$.fragment,e),Ol=a(e),Ue=J(e,"P",{"data-svelte-h":!0}),U(Ue)!=="svelte-1iiqbq7"&&(Ue.textContent=Zn),Hl=a(e),re=J(e,"P",{"data-svelte-h":!0}),U(re)!=="svelte-1kjrzws"&&(re.innerHTML=Nn),Ll=a(e),g(D.$$.fragment,e),zl=a(e),g(pe.$$.fragment,e),Yl=a(e),de=J(e,"P",{"data-svelte-h":!0}),U(de)!=="svelte-1cp6hkj"&&(de.innerHTML=Wn),Dl=a(e),we=J(e,"P",{"data-svelte-h":!0}),U(we)!=="svelte-n0btv8"&&(we.innerHTML=Qn),Xl=a(e),g(ue.$$.fragment,e),ql=a(e),g(ye.$$.fragment,e),Pl=a(e),ce=J(e,"P",{"data-svelte-h":!0}),U(ce)!=="svelte-fbbc6g"&&(ce.textContent=Fn),Kl=a(e),me=J(e,"UL",{"data-svelte-h":!0}),U(me)!=="svelte-1gs7c6s"&&(me.innerHTML=En),et=a(e),ge=J(e,"P",{"data-svelte-h":!0}),U(ge)!=="svelte-rh57s1"&&(ge.innerHTML=Gn),lt=a(e),g(X.$$.fragment,e),tt=a(e),g(he.$$.fragment,e),nt=a(e),g(fe.$$.fragment,e),st=a(e),be=J(e,"P",{"data-svelte-h":!0}),U(be)!=="svelte-1e83m24"&&(be.innerHTML=_n),ot=a(e),g(Ie.$$.fragment,e),at=a(e),Ce=J(e,"P",{"data-svelte-h":!0}),U(Ce)!=="svelte-a39tyc"&&(Ce.innerHTML=xn),it=a(e),je=J(e,"UL",{"data-svelte-h":!0}),U(je)!=="svelte-1f3fqeb"&&(je.innerHTML=Sn),Tt=a(e),ke=J(e,"P",{"data-svelte-h":!0}),U(ke)!=="svelte-11i007g"&&(ke.innerHTML=On),Jt=a(e),$e=J(e,"UL",{"data-svelte-h":!0}),U($e)!=="svelte-xlpltp"&&($e.innerHTML=Hn),Mt=a(e),g(ve.$$.fragment,e),Ut=a(e),Be=J(e,"P",{"data-svelte-h":!0}),U(Be)!=="svelte-4h2er2"&&(Be.textContent=Ln),rt=a(e),Ve=J(e,"UL",{"data-svelte-h":!0}),U(Ve)!=="svelte-1bxk7ay"&&(Ve.innerHTML=zn),pt=a(e),g(Ae.$$.fragment,e),dt=a(e),Re=J(e,"P",{"data-svelte-h":!0}),U(Re)!=="svelte-izglpm"&&(Re.textContent=Yn),wt=a(e),Ze=J(e,"UL",{"data-svelte-h":!0}),U(Ze)!=="svelte-eja4z2"&&(Ze.innerHTML=Dn),ut=a(e),Ne=J(e,"P",{"data-svelte-h":!0}),U(Ne)!=="svelte-1er80d2"&&(Ne.innerHTML=Xn),yt=a(e),We=J(e,"P",{"data-svelte-h":!0}),U(We)!=="svelte-u83m8z"&&(We.textContent=qn),ct=a(e),g(Qe.$$.fragment,e),mt=a(e),Fe=J(e,"P",{"data-svelte-h":!0}),U(Fe)!=="svelte-t7zb7o"&&(Fe.innerHTML=Pn),gt=a(e),Ee=J(e,"UL",{"data-svelte-h":!0}),U(Ee)!=="svelte-125t7iy"&&(Ee.innerHTML=Kn),ht=a(e),Ge=J(e,"P",{"data-svelte-h":!0}),U(Ge)!=="svelte-1o4z3y"&&(Ge.textContent=es),ft=a(e),g(_e.$$.fragment,e),bt=a(e),g(xe.$$.fragment,e),It=a(e),Se=J(e,"P",{"data-svelte-h":!0}),U(Se)!=="svelte-8dd7rj"&&(Se.textContent=ls),Ct=a(e),Oe=J(e,"P",{"data-svelte-h":!0}),U(Oe)!=="svelte-jio97"&&(Oe.textContent=ts),jt=a(e),g(He.$$.fragment,e),kt=a(e),Le=J(e,"P",{"data-svelte-h":!0}),U(Le)!=="svelte-ud0w06"&&(Le.innerHTML=ns),$t=a(e),ze=J(e,"P",{"data-svelte-h":!0}),U(ze)!=="svelte-x6h8bb"&&(ze.textContent=ss),vt=a(e),g(q.$$.fragment,e),Bt=a(e),Ye=J(e,"P",{"data-svelte-h":!0}),U(Ye)!=="svelte-1bc8e8e"&&(Ye.textContent=os),Vt=a(e),g(De.$$.fragment,e),At=a(e),Xe=J(e,"P",{"data-svelte-h":!0}),U(Xe)!=="svelte-1rndc0g"&&(Xe.textContent=as),Rt=a(e),g(qe.$$.fragment,e),Zt=a(e),g(P.$$.fragment,e),Nt=a(e),g(Pe.$$.fragment,e),Wt=a(e),Ke=J(e,"P",{"data-svelte-h":!0}),U(Ke)!=="svelte-6s34wk"&&(Ke.innerHTML=is),Qt=a(e),el=J(e,"P",{"data-svelte-h":!0}),U(el)!=="svelte-1x0er27"&&(el.textContent=Ts),Ft=a(e),ll=J(e,"P",{"data-svelte-h":!0}),U(ll)!=="svelte-1n3puco"&&(ll.innerHTML=Js),Et=a(e),tl=J(e,"P",{"data-svelte-h":!0}),U(tl)!=="svelte-1mo0wtw"&&(tl.innerHTML=Ms),Gt=a(e),nl=J(e,"P",{"data-svelte-h":!0}),U(nl)!=="svelte-1s62r4x"&&(nl.innerHTML=Us),_t=a(e),g(sl.$$.fragment,e),xt=a(e),g(K.$$.fragment,e),St=a(e),g(ol.$$.fragment,e),Ot=a(e),al=J(e,"P",{"data-svelte-h":!0}),U(al)!=="svelte-8ye7ad"&&(al.innerHTML=rs),Ht=a(e),g(il.$$.fragment,e),Lt=a(e),Tl=J(e,"P",{"data-svelte-h":!0}),U(Tl)!=="svelte-1k7bqf2"&&(Tl.innerHTML=ps),zt=a(e),Jl=J(e,"P",{"data-svelte-h":!0}),U(Jl)!=="svelte-130f0gy"&&(Jl.innerHTML=ds),Yt=a(e),Ml=J(e,"P",{"data-svelte-h":!0}),U(Ml)!=="svelte-3zhnpr"&&(Ml.innerHTML=ws),Dt=a(e),g(Ul.$$.fragment,e),Xt=a(e),rl=J(e,"P",{"data-svelte-h":!0}),U(rl)!=="svelte-1hjlm82"&&(rl.textContent=us),qt=a(e),g(pl.$$.fragment,e),Pt=a(e),dl=J(e,"P",{"data-svelte-h":!0}),U(dl)!=="svelte-2wlmjx"&&(dl.textContent=ys),Kt=a(e),g(wl.$$.fragment,e),en=a(e),ul=J(e,"P",{"data-svelte-h":!0}),U(ul)!=="svelte-1emppws"&&(ul.textContent=cs),ln=a(e),yl=J(e,"UL",{"data-svelte-h":!0}),U(yl)!=="svelte-1hcect5"&&(yl.innerHTML=ms),tn=a(e),g(cl.$$.fragment,e),nn=a(e),Rl=J(e,"P",{}),L(Rl).forEach(l),this.h()},h(){fs(s,"name","hf:doc:metadata"),fs(s,"content",Ys)},m(e,n){V(document.head,s),t(e,d,n),t(e,i,n),t(e,p,n),h(u,e,n),t(e,w,n),h(C,e,n),t(e,$,n),t(e,r,n),t(e,R,n),h(v,e,n),t(e,Z,n),t(e,c,n),t(e,k,n),t(e,j,n),V(j,N),V(N,F),V(N,H),V(N,y),V(y,W),V(y,on),V(y,fl),V(y,an),V(y,bl),V(bl,Tn),h(ee,bl,null),V(y,Jn),V(y,Il),V(y,Mn),V(y,Cl),V(j,Un),V(j,le),V(le,jl),V(le,rn),V(le,_),V(_,kl),V(_,pn),V(_,$l),V(_,dn),V(_,vl),V(vl,wn),h(te,vl,null),V(_,un),V(_,Bl),V(_,yn),V(_,Vl),t(e,Nl,n),t(e,ne,n),t(e,Wl,n),t(e,se,n),t(e,Ql,n),h(oe,e,n),t(e,Fl,n),t(e,ae,n),t(e,El,n),t(e,ie,n),t(e,Gl,n),t(e,Te,n),t(e,_l,n),h(Je,e,n),t(e,xl,n),t(e,Me,n),t(e,Sl,n),h(Y,e,n),t(e,Ol,n),t(e,Ue,n),t(e,Hl,n),t(e,re,n),t(e,Ll,n),h(D,e,n),t(e,zl,n),h(pe,e,n),t(e,Yl,n),t(e,de,n),t(e,Dl,n),t(e,we,n),t(e,Xl,n),h(ue,e,n),t(e,ql,n),h(ye,e,n),t(e,Pl,n),t(e,ce,n),t(e,Kl,n),t(e,me,n),t(e,et,n),t(e,ge,n),t(e,lt,n),h(X,e,n),t(e,tt,n),h(he,e,n),t(e,nt,n),h(fe,e,n),t(e,st,n),t(e,be,n),t(e,ot,n),h(Ie,e,n),t(e,at,n),t(e,Ce,n),t(e,it,n),t(e,je,n),t(e,Tt,n),t(e,ke,n),t(e,Jt,n),t(e,$e,n),t(e,Mt,n),h(ve,e,n),t(e,Ut,n),t(e,Be,n),t(e,rt,n),t(e,Ve,n),t(e,pt,n),h(Ae,e,n),t(e,dt,n),t(e,Re,n),t(e,wt,n),t(e,Ze,n),t(e,ut,n),t(e,Ne,n),t(e,yt,n),t(e,We,n),t(e,ct,n),h(Qe,e,n),t(e,mt,n),t(e,Fe,n),t(e,gt,n),t(e,Ee,n),t(e,ht,n),t(e,Ge,n),t(e,ft,n),h(_e,e,n),t(e,bt,n),h(xe,e,n),t(e,It,n),t(e,Se,n),t(e,Ct,n),t(e,Oe,n),t(e,jt,n),h(He,e,n),t(e,kt,n),t(e,Le,n),t(e,$t,n),t(e,ze,n),t(e,vt,n),h(q,e,n),t(e,Bt,n),t(e,Ye,n),t(e,Vt,n),h(De,e,n),t(e,At,n),t(e,Xe,n),t(e,Rt,n),h(qe,e,n),t(e,Zt,n),h(P,e,n),t(e,Nt,n),h(Pe,e,n),t(e,Wt,n),t(e,Ke,n),t(e,Qt,n),t(e,el,n),t(e,Ft,n),t(e,ll,n),t(e,Et,n),t(e,tl,n),t(e,Gt,n),t(e,nl,n),t(e,_t,n),h(sl,e,n),t(e,xt,n),h(K,e,n),t(e,St,n),h(ol,e,n),t(e,Ot,n),t(e,al,n),t(e,Ht,n),h(il,e,n),t(e,Lt,n),t(e,Tl,n),t(e,zt,n),t(e,Jl,n),t(e,Yt,n),t(e,Ml,n),t(e,Dt,n),h(Ul,e,n),t(e,Xt,n),t(e,rl,n),t(e,qt,n),h(pl,e,n),t(e,Pt,n),t(e,dl,n),t(e,Kt,n),h(wl,e,n),t(e,en,n),t(e,ul,n),t(e,ln,n),t(e,yl,n),t(e,tn,n),h(cl,e,n),t(e,nn,n),t(e,Rl,n),sn=!0},p(e,[n]){const ml={};n&2&&(ml.$$scope={dirty:n,ctx:e}),Y.$set(ml);const gl={};n&2&&(gl.$$scope={dirty:n,ctx:e}),D.$set(gl);const x={};n&2&&(x.$$scope={dirty:n,ctx:e}),X.$set(x);const Al={};n&2&&(Al.$$scope={dirty:n,ctx:e}),q.$set(Al);const hl={};n&2&&(hl.$$scope={dirty:n,ctx:e}),P.$set(hl);const S={};n&2&&(S.$$scope={dirty:n,ctx:e}),K.$set(S)},i(e){sn||(f(u.$$.fragment,e),f(C.$$.fragment,e),f(v.$$.fragment,e),f(ee.$$.fragment,e),f(te.$$.fragment,e),f(oe.$$.fragment,e),f(Je.$$.fragment,e),f(Y.$$.fragment,e),f(D.$$.fragment,e),f(pe.$$.fragment,e),f(ue.$$.fragment,e),f(ye.$$.fragment,e),f(X.$$.fragment,e),f(he.$$.fragment,e),f(fe.$$.fragment,e),f(Ie.$$.fragment,e),f(ve.$$.fragment,e),f(Ae.$$.fragment,e),f(Qe.$$.fragment,e),f(_e.$$.fragment,e),f(xe.$$.fragment,e),f(He.$$.fragment,e),f(q.$$.fragment,e),f(De.$$.fragment,e),f(qe.$$.fragment,e),f(P.$$.fragment,e),f(Pe.$$.fragment,e),f(sl.$$.fragment,e),f(K.$$.fragment,e),f(ol.$$.fragment,e),f(il.$$.fragment,e),f(Ul.$$.fragment,e),f(pl.$$.fragment,e),f(wl.$$.fragment,e),f(cl.$$.fragment,e),sn=!0)},o(e){b(u.$$.fragment,e),b(C.$$.fragment,e),b(v.$$.fragment,e),b(ee.$$.fragment,e),b(te.$$.fragment,e),b(oe.$$.fragment,e),b(Je.$$.fragment,e),b(Y.$$.fragment,e),b(D.$$.fragment,e),b(pe.$$.fragment,e),b(ue.$$.fragment,e),b(ye.$$.fragment,e),b(X.$$.fragment,e),b(he.$$.fragment,e),b(fe.$$.fragment,e),b(Ie.$$.fragment,e),b(ve.$$.fragment,e),b(Ae.$$.fragment,e),b(Qe.$$.fragment,e),b(_e.$$.fragment,e),b(xe.$$.fragment,e),b(He.$$.fragment,e),b(q.$$.fragment,e),b(De.$$.fragment,e),b(qe.$$.fragment,e),b(P.$$.fragment,e),b(Pe.$$.fragment,e),b(sl.$$.fragment,e),b(K.$$.fragment,e),b(ol.$$.fragment,e),b(il.$$.fragment,e),b(Ul.$$.fragment,e),b(pl.$$.fragment,e),b(wl.$$.fragment,e),b(cl.$$.fragment,e),sn=!1},d(e){e&&(l(d),l(i),l(p),l(w),l($),l(r),l(R),l(Z),l(c),l(k),l(j),l(Nl),l(ne),l(Wl),l(se),l(Ql),l(Fl),l(ae),l(El),l(ie),l(Gl),l(Te),l(_l),l(xl),l(Me),l(Sl),l(Ol),l(Ue),l(Hl),l(re),l(Ll),l(zl),l(Yl),l(de),l(Dl),l(we),l(Xl),l(ql),l(Pl),l(ce),l(Kl),l(me),l(et),l(ge),l(lt),l(tt),l(nt),l(st),l(be),l(ot),l(at),l(Ce),l(it),l(je),l(Tt),l(ke),l(Jt),l($e),l(Mt),l(Ut),l(Be),l(rt),l(Ve),l(pt),l(dt),l(Re),l(wt),l(Ze),l(ut),l(Ne),l(yt),l(We),l(ct),l(mt),l(Fe),l(gt),l(Ee),l(ht),l(Ge),l(ft),l(bt),l(It),l(Se),l(Ct),l(Oe),l(jt),l(kt),l(Le),l($t),l(ze),l(vt),l(Bt),l(Ye),l(Vt),l(At),l(Xe),l(Rt),l(Zt),l(Nt),l(Wt),l(Ke),l(Qt),l(el),l(Ft),l(ll),l(Et),l(tl),l(Gt),l(nl),l(_t),l(xt),l(St),l(Ot),l(al),l(Ht),l(Lt),l(Tl),l(zt),l(Jl),l(Yt),l(Ml),l(Dt),l(Xt),l(rl),l(qt),l(Pt),l(dl),l(Kt),l(en),l(ul),l(ln),l(yl),l(tn),l(nn),l(Rl)),l(s),I(u,e),I(C,e),I(v,e),I(ee),I(te),I(oe,e),I(Je,e),I(Y,e),I(D,e),I(pe,e),I(ue,e),I(ye,e),I(X,e),I(he,e),I(fe,e),I(Ie,e),I(ve,e),I(Ae,e),I(Qe,e),I(_e,e),I(xe,e),I(He,e),I(q,e),I(De,e),I(qe,e),I(P,e),I(Pe,e),I(sl,e),I(K,e),I(ol,e),I(il,e),I(Ul,e),I(pl,e),I(wl,e),I(cl,e)}}}const Ys='{"title":"Agents - Guided tour","local":"agents---guided-tour","sections":[{"title":"Choosing an agent type: CodeAgent or ToolCallingAgent","local":"choosing-an-agent-type-codeagent-or-toolcallingagent","sections":[],"depth":2},{"title":"CodeAgent","local":"codeagent","sections":[{"title":"ToolCallingAgent","local":"toolcallingagent","sections":[],"depth":3}],"depth":2},{"title":"Building your agent","local":"building-your-agent","sections":[],"depth":2},{"title":"Advanced agent configuration","local":"advanced-agent-configuration","sections":[{"title":"Customizing agent termination conditions","local":"customizing-agent-termination-conditions","sections":[],"depth":3}],"depth":2},{"title":"Inspecting an agent run","local":"inspecting-an-agent-run","sections":[],"depth":2},{"title":"Tools","local":"tools","sections":[{"title":"Default toolbox","local":"default-toolbox","sections":[],"depth":3},{"title":"Create a new tool","local":"create-a-new-tool","sections":[],"depth":3}],"depth":2},{"title":"Multi-agents","local":"multi-agents","sections":[],"depth":2},{"title":"Talk with your agent and visualize its thoughts in a cool Gradio interface","local":"talk-with-your-agent-and-visualize-its-thoughts-in-a-cool-gradio-interface","sections":[],"depth":2},{"title":"Next steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function Ds(B){return Cs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class no extends js{constructor(s){super(),ks(this,s,Ds,zs,Is,{})}}export{no as component};
