import{s as js,o as Us,n as F}from"../chunks/scheduler.f6319a2a.js";import{S as Cs,i as ks,g as c,s as l,r as d,A as xs,h as m,f as s,c as a,j as N,u as g,x as y,k as A,y as T,a as n,v as u,d as M,t as f,w as h}from"../chunks/index.85aa684c.js";import{T as Oe}from"../chunks/Tip.3d397a88.js";import{D as H,E as ss}from"../chunks/ExampleCodeBlock.ac5a24b2.js";import{C}from"../chunks/CodeBlock.3400fc53.js";import{H as P,E as Ns}from"../chunks/getInferenceSnippets.743412b2.js";function As(b){let o,_="Smolagents 是一个实验性 API，其可能会随时发生更改。由于 API 或底层模型可能会变化，智能体返回的结果可能会有所不同。";return{c(){o=c("p"),o.textContent=_},l(r){o=m(r,"P",{"data-svelte-h":!0}),y(o)!=="svelte-j62iso"&&(o.textContent=_)},m(r,p){n(r,o,p)},p:F,d(r){r&&s(o)}}}function Es(b){let o,_="您必须在机器上安装 <code>transformers</code> 和 <code>torch</code>。如果尚未安装，请运行 <code>pip install smolagents[transformers]</code>。";return{c(){o=c("p"),o.innerHTML=_},l(r){o=m(r,"P",{"data-svelte-h":!0}),y(o)!=="svelte-7pjjll"&&(o.innerHTML=_)},m(r,p){n(r,o,p)},p:F,d(r){r&&s(o)}}}function qs(b){let o,_="You must have <code>transformers</code> and <code>torch</code> installed on your machine. Please run <code>pip install smolagents[transformers]</code> if it’s not the case.";return{c(){o=c("p"),o.innerHTML=_},l(r){o=m(r,"P",{"data-svelte-h":!0}),y(o)!=="svelte-1tclttn"&&(o.innerHTML=_)},m(r,p){n(r,o,p)},p:F,d(r){r&&s(o)}}}function Zs(b){let o,_="Example:",r,p,$;return p=new C({props:{code:"ZW5naW5lJTIwJTNEJTIwVHJhbnNmb3JtZXJzTW9kZWwoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlM0QlMjJRd2VuJTJGUXdlbjIuNS1Db2Rlci0zMkItSW5zdHJ1Y3QlMjIlMkMlMEElMjAlMjAlMjAlMjBkZXZpY2UlM0QlMjJjdWRhJTIyJTJDJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0Q1MDAwJTJDJTBBKSUwQW1lc3NhZ2VzJTIwJTNEJTIwJTVCJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyRXhwbGFpbiUyMHF1YW50dW0lMjBtZWNoYW5pY3MlMjBpbiUyMHNpbXBsZSUyMHRlcm1zLiUyMiU3RCU1RCUwQXJlc3BvbnNlJTIwJTNEJTIwZW5naW5lKG1lc3NhZ2VzJTJDJTIwc3RvcF9zZXF1ZW5jZXMlM0QlNUIlMjJFTkQlMjIlNUQpJTBBcHJpbnQocmVzcG9uc2Up",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>engine = TransformersModel(
<span class="hljs-meta">... </span>    model_id=<span class="hljs-string">&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</span>,
<span class="hljs-meta">... </span>    device=<span class="hljs-string">&quot;cuda&quot;</span>,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">5000</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>messages = [{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Explain quantum mechanics in simple terms.&quot;</span>}]
<span class="hljs-meta">&gt;&gt;&gt; </span>response = engine(messages, stop_sequences=[<span class="hljs-string">&quot;END&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(response)
<span class="hljs-string">&quot;Quantum mechanics is the branch of physics that studies...&quot;</span>`,wrap:!1}}),{c(){o=c("p"),o.textContent=_,r=l(),d(p.$$.fragment)},l(i){o=m(i,"P",{"data-svelte-h":!0}),y(o)!=="svelte-11lpom8"&&(o.textContent=_),r=a(i),g(p.$$.fragment,i)},m(i,w){n(i,o,w),n(i,r,w),u(p,i,w),$=!0},p:F,i(i){$||(M(p.$$.fragment,i),$=!0)},o(i){f(p.$$.fragment,i),$=!1},d(i){i&&(s(o),s(r)),h(p,i)}}}function Ls(b){let o,_="Example:",r,p,$;return p=new C({props:{code:"ZW5naW5lJTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50TW9kZWwoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlM0QlMjJRd2VuJTJGUXdlbjIuNS1Db2Rlci0zMkItSW5zdHJ1Y3QlMjIlMkMlMEElMjAlMjAlMjAlMjBwcm92aWRlciUzRCUyMm5lYml1cyUyMiUyQyUwQSUyMCUyMCUyMCUyMHRva2VuJTNEJTIyeW91cl9oZl90b2tlbl9oZXJlJTIyJTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDUwMDAlMkMlMEEpJTBBbWVzc2FnZXMlMjAlM0QlMjAlNUIlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJFeHBsYWluJTIwcXVhbnR1bSUyMG1lY2hhbmljcyUyMGluJTIwc2ltcGxlJTIwdGVybXMuJTIyJTdEJTVEJTBBcmVzcG9uc2UlMjAlM0QlMjBlbmdpbmUobWVzc2FnZXMlMkMlMjBzdG9wX3NlcXVlbmNlcyUzRCU1QiUyMkVORCUyMiU1RCklMEFwcmludChyZXNwb25zZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>engine = InferenceClientModel(
<span class="hljs-meta">... </span>    model_id=<span class="hljs-string">&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</span>,
<span class="hljs-meta">... </span>    provider=<span class="hljs-string">&quot;nebius&quot;</span>,
<span class="hljs-meta">... </span>    token=<span class="hljs-string">&quot;your_hf_token_here&quot;</span>,
<span class="hljs-meta">... </span>    max_tokens=<span class="hljs-number">5000</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>messages = [{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Explain quantum mechanics in simple terms.&quot;</span>}]
<span class="hljs-meta">&gt;&gt;&gt; </span>response = engine(messages, stop_sequences=[<span class="hljs-string">&quot;END&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(response)
<span class="hljs-string">&quot;Quantum mechanics is the branch of physics that studies...&quot;</span>`,wrap:!1}}),{c(){o=c("p"),o.textContent=_,r=l(),d(p.$$.fragment)},l(i){o=m(i,"P",{"data-svelte-h":!0}),y(o)!=="svelte-11lpom8"&&(o.textContent=_),r=a(i),g(p.$$.fragment,i)},m(i,w){n(i,o,w),n(i,r,w),u(p,i,w),$=!0},p:F,i(i){$||(M(p.$$.fragment,i),$=!0)},o(i){f(p.$$.fragment,i),$=!1},d(i){i&&(s(o),s(r)),h(p,i)}}}function Ws(b){let o,_="您必须在机器上安装 <code>mlx-lm</code>。如果尚未安装，请运行 <code>pip install smolagents[mlx-lm]</code>。";return{c(){o=c("p"),o.innerHTML=_},l(r){o=m(r,"P",{"data-svelte-h":!0}),y(o)!=="svelte-199hg0m"&&(o.innerHTML=_)},m(r,p){n(r,o,p)},p:F,d(r){r&&s(o)}}}function Bs(b){let o,_="You must have <code>mlx-lm</code> installed on your machine. Please run <code>pip install smolagents[mlx-lm]</code> if it’s not the case.";return{c(){o=c("p"),o.innerHTML=_},l(r){o=m(r,"P",{"data-svelte-h":!0}),y(o)!=="svelte-g382or"&&(o.innerHTML=_)},m(r,p){n(r,o,p)},p:F,d(r){r&&s(o)}}}function Vs(b){let o,_="Example:",r,p,$;return p=new C({props:{code:"ZW5naW5lJTIwJTNEJTIwTUxYTW9kZWwoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlM0QlMjJtbHgtY29tbXVuaXR5JTJGUXdlbjIuNS1Db2Rlci0zMkItSW5zdHJ1Y3QtNGJpdCUyMiUyQyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QxMDAwMCUyQyUwQSklMEFtZXNzYWdlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkV4cGxhaW4lMjBxdWFudHVtJTIwbWVjaGFuaWNzJTIwaW4lMjBzaW1wbGUlMjB0ZXJtcy4lMjIlMEElMjAlMjAlMjAlMjAlN0QlMEElNUQlMEFyZXNwb25zZSUyMCUzRCUyMGVuZ2luZShtZXNzYWdlcyUyQyUyMHN0b3Bfc2VxdWVuY2VzJTNEJTVCJTIyRU5EJTIyJTVEKSUwQXByaW50KHJlc3BvbnNlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>engine = MLXModel(
<span class="hljs-meta">... </span>    model_id=<span class="hljs-string">&quot;mlx-community/Qwen2.5-Coder-32B-Instruct-4bit&quot;</span>,
<span class="hljs-meta">... </span>    max_tokens=<span class="hljs-number">10000</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>messages = [
<span class="hljs-meta">... </span>    {
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Explain quantum mechanics in simple terms.&quot;</span>
<span class="hljs-meta">... </span>    }
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>response = engine(messages, stop_sequences=[<span class="hljs-string">&quot;END&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(response)
<span class="hljs-string">&quot;Quantum mechanics is the branch of physics that studies...&quot;</span>`,wrap:!1}}),{c(){o=c("p"),o.textContent=_,r=l(),d(p.$$.fragment)},l(i){o=m(i,"P",{"data-svelte-h":!0}),y(o)!=="svelte-11lpom8"&&(o.textContent=_),r=a(i),g(p.$$.fragment,i)},m(i,w){n(i,o,w),n(i,r,w),u(p,i,w),$=!0},p:F,i(i){$||(M(p.$$.fragment,i),$=!0)},o(i){f(p.$$.fragment,i),$=!1},d(i){i&&(s(o),s(r)),h(p,i)}}}function Qs(b){let o,_,r,p,$,i,w,De,G,ns='要了解有关智能体和工具的更多信息，请务必阅读<a href="../index">入门指南</a>。此页面包含底层类的 API 文档。',Ye,O,Ke,D,os="您可以自由创建和使用自己的模型为智能体提供支持。",et,Y,ls="您可以使用任何 <code>model</code> 可调用对象作为智能体的模型，只要满足以下条件：",tt,K,as='<li>它遵循<a href="./chat_templating">消息格式</a>（<code>List[Dict[str, str]]</code>），将其作为输入 <code>messages</code>，并返回一个 <code>str</code>。</li> <li>它在生成的序列到达 <code>stop_sequences</code> 参数中指定的内容之前停止生成输出。</li>',st,ee,rs='要定义您的 LLM，可以创建一个 <code>custom_model</code> 方法，该方法接受一个 <a href="./chat_templating">messages</a> 列表，并返回一个包含 <code>.content</code> 属性的对象，其中包含生成的文本。此可调用对象还需要接受一个 <code>stop_sequences</code> 参数，用于指示何时停止生成。',nt,te,ot,se,is='此外，<code>custom_model</code> 还可以接受一个 <code>grammar</code> 参数。如果在智能体初始化时指定了 <code>grammar</code>，则此参数将在调用模型时传递，以便进行<a href="https://huggingface.co/docs/text-generation-inference/conceptual/guidance" rel="nofollow">约束生成</a>，从而强制生成格式正确的智能体输出。',lt,ne,at,oe,cs="为了方便起见，我们添加了一个 <code>TransformersModel</code>，该模型通过为初始化时指定的 <code>model_id</code> 构建一个本地 <code>transformers</code> pipeline 来实现上述功能。",rt,le,it,ae,ct,L,mt,J,re,Wt,We,ms="A class that uses Hugging Face’s Transformers library for language model interaction.",Bt,Be,ps="This model allows you to load and use Hugging Face’s models locally using the Transformers library. It supports features like stop sequences and grammar customization.",Vt,W,Qt,B,pt,ie,dt,ce,ds='<code>InferenceClientModel</code> 封装了 huggingface_hub 的 <a href="https://huggingface.co/docs/huggingface_hub/main/en/guides/inference" rel="nofollow">InferenceClient</a>，用于执行 LLM。它支持 HF 的 <a href="https://huggingface.co/docs/api-inference/index" rel="nofollow">Inference API</a> 以及 Hub 上所有可用的<a href="https://huggingface.co/blog/inference-providers" rel="nofollow">Inference Providers</a>。',gt,me,ut,pe,Mt,I,de,zt,Ve,gs="A class to interact with Hugging Face’s Inference Providers for language model interaction.",St,Qe,us="This model allows you to communicate with Hugging Face’s models using Inference Providers. It can be used in both serverless mode, with a dedicated endpoint, or even with a local URL, supporting features like stop sequences and grammar customization.",Rt,ze,Ms="Providers include Cerebras, Cohere, Fal, Fireworks, HF-Inference, Hyperbolic, Nebius, Novita, Replicate, SambaNova, Together, and more.",Xt,V,Ht,Q,ge,Pt,Se,fs="Create the Hugging Face client.",ft,ue,ht,Me,hs='<code>LiteLLMModel</code> 利用 <a href="https://www.litellm.ai/" rel="nofollow">LiteLLM</a> 支持来自不同提供商的 100+ 个 LLM。您可以在模型初始化时传递 <code>kwargs</code>，这些参数将在每次使用模型时被使用，例如下面的示例中传递了 <code>temperature</code>。',Tt,fe,yt,k,he,Ft,Re,Ts='Model to use <a href="https://docs.litellm.ai/docs/#litellm-python-sdk" rel="nofollow">LiteLLM Python SDK</a> to access hundreds of LLMs.',Gt,z,Te,Ot,Xe,ys="Create the LiteLLM client.",_t,ye,$t,_e,_s=`此类允许您调用任何 OpenAIServer 兼容模型。
以下是设置方法（您可以自定义 <code>api_base</code> URL 指向其他服务器）：`,wt,$e,bt,E,we,Dt,He,$s="This model connects to an OpenAI-compatible API server.",It,be,Jt,Ie,ws="<code>AzureOpenAIServerModel</code> 允许您连接到任何 Azure OpenAI 部署。",vt,Je,bs="下面是设置示例，请注意，如果已经设置了相应的环境变量，您可以省略 <code>azure_endpoint</code>、<code>api_key</code> 和 <code>api_version</code> 参数——环境变量包括 <code>AZURE_OPENAI_ENDPOINT</code>、<code>AZURE_OPENAI_API_KEY</code> 和 <code>OPENAI_API_VERSION</code>。",jt,ve,Is='请注意，<code>OPENAI_API_VERSION</code> 没有 <code>AZURE_</code> 前缀，这是由于底层 <a href="https://github.com/openai/openai-python" rel="nofollow">openai</a> 包的设计所致。',Ut,je,Ct,q,Ue,Yt,Pe,Js="This model connects to an Azure OpenAI deployment.",kt,Ce,xt,ke,Nt,xe,At,S,Et,j,Ne,Kt,Fe,vs="A class to interact with models loaded using MLX on Apple silicon.",es,R,ts,X,qt,Ae,Zt,Ge,Lt;return $=new P({props:{title:"模型",local:"模型",headingTag:"h1"}}),w=new Oe({props:{warning:!0,$$slots:{default:[As]},$$scope:{ctx:b}}}),O=new P({props:{title:"模型",local:"模型",headingTag:"h2"}}),te=new C({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGxvZ2luJTJDJTIwSW5mZXJlbmNlQ2xpZW50JTBBJTBBbG9naW4oJTIyJTNDWU9VUl9IVUdHSU5HRkFDRUhVQl9BUElfVE9LRU4lM0UlMjIpJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJtZXRhLWxsYW1hJTJGTGxhbWEtMy4zLTcwQi1JbnN0cnVjdCUyMiUwQSUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudChtb2RlbCUzRG1vZGVsX2lkKSUwQSUwQWRlZiUyMGN1c3RvbV9tb2RlbChtZXNzYWdlcyUyQyUyMHN0b3Bfc2VxdWVuY2VzJTNEJTVCJTIyVGFzayUyMiU1RCklM0ElMEElMjAlMjAlMjAlMjByZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0X2NvbXBsZXRpb24obWVzc2FnZXMlMkMlMjBzdG9wJTNEc3RvcF9zZXF1ZW5jZXMlMkMlMjBtYXhfdG9rZW5zJTNEMTAwMCklMEElMjAlMjAlMjAlMjBhbnN3ZXIlMjAlM0QlMjByZXNwb25zZS5jaG9pY2VzJTVCMCU1RC5tZXNzYWdlJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwYW5zd2Vy",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> login, InferenceClient

login(<span class="hljs-string">&quot;&lt;YOUR_HUGGINGFACEHUB_API_TOKEN&gt;&quot;</span>)

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

client = InferenceClient(model=model_id)

<span class="hljs-keyword">def</span> <span class="hljs-title function_">custom_model</span>(<span class="hljs-params">messages, stop_sequences=[<span class="hljs-string">&quot;Task&quot;</span>]</span>):
    response = client.chat_completion(messages, stop=stop_sequences, max_tokens=<span class="hljs-number">1000</span>)
    answer = response.choices[<span class="hljs-number">0</span>].message
    <span class="hljs-keyword">return</span> answer`,wrap:!1}}),ne=new P({props:{title:"TransformersModel",local:"smolagents.TransformersModel",headingTag:"h3"}}),le=new C({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBUcmFuc2Zvcm1lcnNNb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwVHJhbnNmb3JtZXJzTW9kZWwobW9kZWxfaWQlM0QlMjJIdWdnaW5nRmFjZVRCJTJGU21vbExNLTEzNU0tSW5zdHJ1Y3QlMjIpJTBBJTBBcHJpbnQobW9kZWwoJTVCJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTVCJTdCJTIydHlwZSUyMiUzQSUyMCUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyT2shJTIyJTdEJTVEJTdEJTVEJTJDJTIwc3RvcF9zZXF1ZW5jZXMlM0QlNUIlMjJncmVhdCUyMiU1RCkp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> TransformersModel

model = TransformersModel(model_id=<span class="hljs-string">&quot;HuggingFaceTB/SmolLM-135M-Instruct&quot;</span>)

<span class="hljs-built_in">print</span>(model([{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;Ok!&quot;</span>}]}], stop_sequences=[<span class="hljs-string">&quot;great&quot;</span>]))`,wrap:!1}}),ae=new C({props:{code:"V2hhdCUyMGE=",highlighted:"&gt;&gt;&gt; What a",wrap:!1}}),L=new Oe({props:{warning:!1,$$slots:{default:[Es]},$$scope:{ctx:b}}}),re=new H({props:{name:"class smolagents.TransformersModel",anchor:"smolagents.TransformersModel",parameters:[{name:"model_id",val:": str | None = None"},{name:"device_map",val:": str | None = None"},{name:"torch_dtype",val:": str | None = None"},{name:"trust_remote_code",val:": bool = False"},{name:"model_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"smolagents.TransformersModel.model_id",description:`<strong>model_id</strong> (<code>str</code>) &#x2014;
The Hugging Face model ID to be used for inference. This can be a path or model identifier from the Hugging Face model hub.
For example, <code>&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</code>.`,name:"model_id"},{anchor:"smolagents.TransformersModel.device_map",description:`<strong>device_map</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The device_map to initialize your model with.`,name:"device_map"},{anchor:"smolagents.TransformersModel.torch_dtype",description:`<strong>torch_dtype</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The torch_dtype to initialize your model with.`,name:"torch_dtype"},{anchor:"smolagents.TransformersModel.trust_remote_code",description:`<strong>trust_remote_code</strong> (bool, default <code>False</code>) &#x2014;
Some models on the Hub require running remote code: for this model, you would have to set this flag to True.`,name:"trust_remote_code"},{anchor:"smolagents.TransformersModel.model_kwargs",description:`<strong>model_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional keyword arguments to pass to <code>AutoModel.from_pretrained</code> (like revision, model_args, config, etc.).`,name:"model_kwargs"},{anchor:"smolagents.TransformersModel.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments to pass to <code>model.generate()</code>, for instance <code>max_new_tokens</code> or <code>device</code>.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/v1.21.0/src/smolagents/models.py#L738",raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<ul>
<li><code>ValueError</code> —
If the model name is not provided.</li>
</ul>
`,raiseType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>ValueError</code></p>
`}}),W=new Oe({props:{warning:!1,$$slots:{default:[qs]},$$scope:{ctx:b}}}),B=new ss({props:{anchor:"smolagents.TransformersModel.example",$$slots:{default:[Zs]},$$scope:{ctx:b}}}),ie=new P({props:{title:"InferenceClientModel",local:"smolagents.InferenceClientModel",headingTag:"h3"}}),me=new C({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUwQSUwQW1lc3NhZ2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTVCJTdCJTIydHlwZSUyMiUzQSUyMCUyMnRleHQlMjIlMkMlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIySGVsbG8lMkMlMjBob3clMjBhcmUlMjB5b3UlM0YlMjIlN0QlNUQlN0QlMEElNUQlMEElMEFtb2RlbCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudE1vZGVsKCklMEFwcmludChtb2RlbChtZXNzYWdlcykp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> InferenceClientModel

messages = [
  {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;Hello, how are you?&quot;</span>}]}
]

model = InferenceClientModel()
<span class="hljs-built_in">print</span>(model(messages))`,wrap:!1}}),pe=new C({props:{code:"T2YlMjBjb3Vyc2UhJTIwSWYlMjB5b3UlMjBjaGFuZ2UlMjB5b3VyJTIwbWluZCUyQyUyMGZlZWwlMjBmcmVlJTIwdG8lMjByZWFjaCUyMG91dC4lMjBUYWtlJTIwY2FyZSE=",highlighted:"&gt;&gt;&gt; Of course! If you change your mind, feel free to reach out. Take care!",wrap:!1}}),de=new H({props:{name:"class smolagents.InferenceClientModel",anchor:"smolagents.InferenceClientModel",parameters:[{name:"model_id",val:": str = 'Qwen/Qwen2.5-Coder-32B-Instruct'"},{name:"provider",val:": str | None = None"},{name:"token",val:": str | None = None"},{name:"timeout",val:": int = 120"},{name:"client_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"custom_role_conversions",val:": dict[str, str] | None = None"},{name:"api_key",val:": str | None = None"},{name:"bill_to",val:": str | None = None"},{name:"base_url",val:": str | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"smolagents.InferenceClientModel.model_id",description:`<strong>model_id</strong> (<code>str</code>, <em>optional</em>, default <code>&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</code>) &#x2014;
The Hugging Face model ID to be used for inference.
This can be a model identifier from the Hugging Face model hub or a URL to a deployed Inference Endpoint.
Currently, it defaults to <code>&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</code>, but this may change in the future.`,name:"model_id"},{anchor:"smolagents.InferenceClientModel.provider",description:`<strong>provider</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Name of the provider to use for inference. A list of supported providers can be found in the <a href="https://huggingface.co/docs/inference-providers/index#partners" rel="nofollow">Inference Providers documentation</a>.
Defaults to &#x201C;auto&#x201D; i.e. the first of the providers available for the model, sorted by the user&#x2019;s order <a href="https://hf.co/settings/inference-providers" rel="nofollow">here</a>.
If <code>base_url</code> is passed, then <code>provider</code> is not used.`,name:"provider"},{anchor:"smolagents.InferenceClientModel.token",description:`<strong>token</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Token used by the Hugging Face API for authentication. This token need to be authorized &#x2018;Make calls to the serverless Inference Providers&#x2019;.
If the model is gated (like Llama-3 models), the token also needs &#x2018;Read access to contents of all public gated repos you can access&#x2019;.
If not provided, the class will try to use environment variable &#x2018;HF_TOKEN&#x2019;, else use the token stored in the Hugging Face CLI configuration.`,name:"token"},{anchor:"smolagents.InferenceClientModel.timeout",description:`<strong>timeout</strong> (<code>int</code>, <em>optional</em>, defaults to 120) &#x2014;
Timeout for the API request, in seconds.`,name:"timeout"},{anchor:"smolagents.InferenceClientModel.client_kwargs",description:`<strong>client_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional keyword arguments to pass to the Hugging Face InferenceClient.`,name:"client_kwargs"},{anchor:"smolagents.InferenceClientModel.custom_role_conversions",description:`<strong>custom_role_conversions</strong> (<code>dict[str, str]</code>, <em>optional</em>) &#x2014;
Custom role conversion mapping to convert message roles in others.
Useful for specific models that do not support specific message roles like &#x201C;system&#x201D;.`,name:"custom_role_conversions"},{anchor:"smolagents.InferenceClientModel.api_key",description:`<strong>api_key</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Token to use for authentication. This is a duplicated argument from <code>token</code> to make <a href="/docs/smolagents/v1.21.0/zh/reference/models#smolagents.InferenceClientModel">InferenceClientModel</a>
follow the same pattern as <code>openai.OpenAI</code> client. Cannot be used if <code>token</code> is set. Defaults to None.`,name:"api_key"},{anchor:"smolagents.InferenceClientModel.bill_to",description:`<strong>bill_to</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The billing account to use for the requests. By default the requests are billed on the user&#x2019;s account. Requests can only be billed to
an organization the user is a member of, and which has subscribed to Enterprise Hub.`,name:"bill_to"},{anchor:"smolagents.InferenceClientModel.base_url",description:`<strong>base_url</strong> (<code>str</code>, <code>optional</code>) &#x2014;
Base URL to run inference. This is a duplicated argument from <code>model</code> to make <a href="/docs/smolagents/v1.21.0/zh/reference/models#smolagents.InferenceClientModel">InferenceClientModel</a>
follow the same pattern as <code>openai.OpenAI</code> client. Cannot be used if <code>model</code> is set. Defaults to None.`,name:"base_url"},{anchor:"smolagents.InferenceClientModel.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments to pass to the Hugging Face InferenceClient.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/v1.21.0/src/smolagents/models.py#L1286",raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<ul>
<li><code>ValueError</code> —
If the model name is not provided.</li>
</ul>
`,raiseType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>ValueError</code></p>
`}}),V=new ss({props:{anchor:"smolagents.InferenceClientModel.example",$$slots:{default:[Ls]},$$scope:{ctx:b}}}),ge=new H({props:{name:"create_client",anchor:"smolagents.InferenceClientModel.create_client",parameters:[],source:"https://github.com/huggingface/smolagents/blob/v1.21.0/src/smolagents/models.py#L1377"}}),ue=new P({props:{title:"LiteLLMModel",local:"smolagents.LiteLLMModel",headingTag:"h3"}}),fe=new C({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBMaXRlTExNTW9kZWwlMEElMEFtZXNzYWdlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCU1QiU3QiUyMnR5cGUlMjIlM0ElMjAlMjJ0ZXh0JTIyJTJDJTIwJTIydGV4dCUyMiUzQSUyMCUyMkhlbGxvJTJDJTIwaG93JTIwYXJlJTIweW91JTNGJTIyJTdEJTVEJTdEJTBBJTVEJTBBJTBBbW9kZWwlMjAlM0QlMjBMaXRlTExNTW9kZWwobW9kZWxfaWQlM0QlMjJhbnRocm9waWMlMkZjbGF1ZGUtMy01LXNvbm5ldC1sYXRlc3QlMjIlMkMlMjB0ZW1wZXJhdHVyZSUzRDAuMiUyQyUyMG1heF90b2tlbnMlM0QxMCklMEFwcmludChtb2RlbChtZXNzYWdlcykp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> LiteLLMModel

messages = [
  {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;Hello, how are you?&quot;</span>}]}
]

model = LiteLLMModel(model_id=<span class="hljs-string">&quot;anthropic/claude-3-5-sonnet-latest&quot;</span>, temperature=<span class="hljs-number">0.2</span>, max_tokens=<span class="hljs-number">10</span>)
<span class="hljs-built_in">print</span>(model(messages))`,wrap:!1}}),he=new H({props:{name:"class smolagents.LiteLLMModel",anchor:"smolagents.LiteLLMModel",parameters:[{name:"model_id",val:": str | None = None"},{name:"api_base",val:": str | None = None"},{name:"api_key",val:": str | None = None"},{name:"custom_role_conversions",val:": dict[str, str] | None = None"},{name:"flatten_messages_as_text",val:": bool | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"smolagents.LiteLLMModel.model_id",description:`<strong>model_id</strong> (<code>str</code>) &#x2014;
The model identifier to use on the server (e.g. &#x201C;gpt-3.5-turbo&#x201D;).`,name:"model_id"},{anchor:"smolagents.LiteLLMModel.api_base",description:`<strong>api_base</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The base URL of the provider API to call the model.`,name:"api_base"},{anchor:"smolagents.LiteLLMModel.api_key",description:`<strong>api_key</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The API key to use for authentication.`,name:"api_key"},{anchor:"smolagents.LiteLLMModel.custom_role_conversions",description:`<strong>custom_role_conversions</strong> (<code>dict[str, str]</code>, <em>optional</em>) &#x2014;
Custom role conversion mapping to convert message roles in others.
Useful for specific models that do not support specific message roles like &#x201C;system&#x201D;.`,name:"custom_role_conversions"},{anchor:"smolagents.LiteLLMModel.flatten_messages_as_text",description:`<strong>flatten_messages_as_text</strong> (<code>bool</code>, <em>optional</em>) &#x2014; Whether to flatten messages as text.
Defaults to <code>True</code> for models that start with &#x201C;ollama&#x201D;, &#x201C;groq&#x201D;, &#x201C;cerebras&#x201D;.`,name:"flatten_messages_as_text"},{anchor:"smolagents.LiteLLMModel.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments to pass to the OpenAI API.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/v1.21.0/src/smolagents/models.py#L1049"}}),Te=new H({props:{name:"create_client",anchor:"smolagents.LiteLLMModel.create_client",parameters:[],source:"https://github.com/huggingface/smolagents/blob/v1.21.0/src/smolagents/models.py#L1099"}}),ye=new P({props:{title:"OpenAIServerModel",local:"smolagents.OpenAIServerModel",headingTag:"h3"}}),$e=new C({props:{code:"aW1wb3J0JTIwb3MlMEFmcm9tJTIwc21vbGFnZW50cyUyMGltcG9ydCUyME9wZW5BSVNlcnZlck1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBPcGVuQUlTZXJ2ZXJNb2RlbCglMEElMjAlMjAlMjAlMjBtb2RlbF9pZCUzRCUyMmdwdC00byUyMiUyQyUwQSUyMCUyMCUyMCUyMGFwaV9iYXNlJTNEJTIyaHR0cHMlM0ElMkYlMkZhcGkub3BlbmFpLmNvbSUyRnYxJTIyJTJDJTBBJTIwJTIwJTIwJTIwYXBpX2tleSUzRG9zLmVudmlyb24lNUIlMjJPUEVOQUlfQVBJX0tFWSUyMiU1RCUyQyUwQSk=",highlighted:`<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> OpenAIServerModel

model = OpenAIServerModel(
    model_id=<span class="hljs-string">&quot;gpt-4o&quot;</span>,
    api_base=<span class="hljs-string">&quot;https://api.openai.com/v1&quot;</span>,
    api_key=os.environ[<span class="hljs-string">&quot;OPENAI_API_KEY&quot;</span>],
)`,wrap:!1}}),we=new H({props:{name:"class smolagents.OpenAIServerModel",anchor:"smolagents.OpenAIServerModel",parameters:[{name:"model_id",val:": str"},{name:"api_base",val:": str | None = None"},{name:"api_key",val:": str | None = None"},{name:"organization",val:": str | None = None"},{name:"project",val:": str | None = None"},{name:"client_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"custom_role_conversions",val:": dict[str, str] | None = None"},{name:"flatten_messages_as_text",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"smolagents.OpenAIServerModel.model_id",description:`<strong>model_id</strong> (<code>str</code>) &#x2014;
The model identifier to use on the server (e.g. &#x201C;gpt-3.5-turbo&#x201D;).`,name:"model_id"},{anchor:"smolagents.OpenAIServerModel.api_base",description:`<strong>api_base</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The base URL of the OpenAI-compatible API server.`,name:"api_base"},{anchor:"smolagents.OpenAIServerModel.api_key",description:`<strong>api_key</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The API key to use for authentication.`,name:"api_key"},{anchor:"smolagents.OpenAIServerModel.organization",description:`<strong>organization</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The organization to use for the API request.`,name:"organization"},{anchor:"smolagents.OpenAIServerModel.project",description:`<strong>project</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The project to use for the API request.`,name:"project"},{anchor:"smolagents.OpenAIServerModel.client_kwargs",description:`<strong>client_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional keyword arguments to pass to the OpenAI client (like organization, project, max_retries etc.).`,name:"client_kwargs"},{anchor:"smolagents.OpenAIServerModel.custom_role_conversions",description:`<strong>custom_role_conversions</strong> (<code>dict[str, str]</code>, <em>optional</em>) &#x2014;
Custom role conversion mapping to convert message roles in others.
Useful for specific models that do not support specific message roles like &#x201C;system&#x201D;.`,name:"custom_role_conversions"},{anchor:"smolagents.OpenAIServerModel.flatten_messages_as_text",description:`<strong>flatten_messages_as_text</strong> (<code>bool</code>, default <code>False</code>) &#x2014;
Whether to flatten messages as text.`,name:"flatten_messages_as_text"},{anchor:"smolagents.OpenAIServerModel.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments to pass to the OpenAI API.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/v1.21.0/src/smolagents/models.py#L1468"}}),be=new P({props:{title:"AzureOpenAIServerModel",local:"smolagents.AzureOpenAIServerModel",headingTag:"h3"}}),je=new C({props:{code:"aW1wb3J0JTIwb3MlMEElMEFmcm9tJTIwc21vbGFnZW50cyUyMGltcG9ydCUyMEF6dXJlT3BlbkFJU2VydmVyTW9kZWwlMEElMEFtb2RlbCUyMCUzRCUyMEF6dXJlT3BlbkFJU2VydmVyTW9kZWwoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlMjAlM0QlMjBvcy5lbnZpcm9uLmdldCglMjJBWlVSRV9PUEVOQUlfTU9ERUwlMjIpJTJDJTBBJTIwJTIwJTIwJTIwYXp1cmVfZW5kcG9pbnQlM0Rvcy5lbnZpcm9uLmdldCglMjJBWlVSRV9PUEVOQUlfRU5EUE9JTlQlMjIpJTJDJTBBJTIwJTIwJTIwJTIwYXBpX2tleSUzRG9zLmVudmlyb24uZ2V0KCUyMkFaVVJFX09QRU5BSV9BUElfS0VZJTIyKSUyQyUwQSUyMCUyMCUyMCUyMGFwaV92ZXJzaW9uJTNEb3MuZW52aXJvbi5nZXQoJTIyT1BFTkFJX0FQSV9WRVJTSU9OJTIyKSUyMCUyMCUyMCUyMCUwQSk=",highlighted:`<span class="hljs-keyword">import</span> os

<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> AzureOpenAIServerModel

model = AzureOpenAIServerModel(
    model_id = os.environ.get(<span class="hljs-string">&quot;AZURE_OPENAI_MODEL&quot;</span>),
    azure_endpoint=os.environ.get(<span class="hljs-string">&quot;AZURE_OPENAI_ENDPOINT&quot;</span>),
    api_key=os.environ.get(<span class="hljs-string">&quot;AZURE_OPENAI_API_KEY&quot;</span>),
    api_version=os.environ.get(<span class="hljs-string">&quot;OPENAI_API_VERSION&quot;</span>)    
)`,wrap:!1}}),Ue=new H({props:{name:"class smolagents.AzureOpenAIServerModel",anchor:"smolagents.AzureOpenAIServerModel",parameters:[{name:"model_id",val:": str"},{name:"azure_endpoint",val:": str | None = None"},{name:"api_key",val:": str | None = None"},{name:"api_version",val:": str | None = None"},{name:"client_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"custom_role_conversions",val:": dict[str, str] | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"smolagents.AzureOpenAIServerModel.model_id",description:`<strong>model_id</strong> (<code>str</code>) &#x2014;
The model deployment name to use when connecting (e.g. &#x201C;gpt-4o-mini&#x201D;).`,name:"model_id"},{anchor:"smolagents.AzureOpenAIServerModel.azure_endpoint",description:`<strong>azure_endpoint</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The Azure endpoint, including the resource, e.g. <code>https://example-resource.azure.openai.com/</code>. If not provided, it will be inferred from the <code>AZURE_OPENAI_ENDPOINT</code> environment variable.`,name:"azure_endpoint"},{anchor:"smolagents.AzureOpenAIServerModel.api_key",description:`<strong>api_key</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The API key to use for authentication. If not provided, it will be inferred from the <code>AZURE_OPENAI_API_KEY</code> environment variable.`,name:"api_key"},{anchor:"smolagents.AzureOpenAIServerModel.api_version",description:`<strong>api_version</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The API version to use. If not provided, it will be inferred from the <code>OPENAI_API_VERSION</code> environment variable.`,name:"api_version"},{anchor:"smolagents.AzureOpenAIServerModel.client_kwargs",description:`<strong>client_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional keyword arguments to pass to the AzureOpenAI client (like organization, project, max_retries etc.).`,name:"client_kwargs"},{anchor:"smolagents.AzureOpenAIServerModel.custom_role_conversions",description:`<strong>custom_role_conversions</strong> (<code>dict[str, str]</code>, <em>optional</em>) &#x2014;
Custom role conversion mapping to convert message roles in others.
Useful for specific models that do not support specific message roles like &#x201C;system&#x201D;.`,name:"custom_role_conversions"},{anchor:"smolagents.AzureOpenAIServerModel.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments to pass to the Azure OpenAI API.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/v1.21.0/src/smolagents/models.py#L1613"}}),Ce=new P({props:{title:"MLXModel",local:"smolagents.MLXModel",headingTag:"h3"}}),ke=new C({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBNTFhNb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwTUxYTW9kZWwobW9kZWxfaWQlM0QlMjJIdWdnaW5nRmFjZVRCJTJGU21vbExNLTEzNU0tSW5zdHJ1Y3QlMjIpJTBBJTBBcHJpbnQobW9kZWwoJTVCJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyT2shJTIyJTdEJTVEJTJDJTIwc3RvcF9zZXF1ZW5jZXMlM0QlNUIlMjJncmVhdCUyMiU1RCkp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> MLXModel

model = MLXModel(model_id=<span class="hljs-string">&quot;HuggingFaceTB/SmolLM-135M-Instruct&quot;</span>)

<span class="hljs-built_in">print</span>(model([{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Ok!&quot;</span>}], stop_sequences=[<span class="hljs-string">&quot;great&quot;</span>]))`,wrap:!1}}),xe=new C({props:{code:"V2hhdCUyMGE=",highlighted:"&gt;&gt;&gt; What a",wrap:!1}}),S=new Oe({props:{warning:!1,$$slots:{default:[Ws]},$$scope:{ctx:b}}}),Ne=new H({props:{name:"class smolagents.MLXModel",anchor:"smolagents.MLXModel",parameters:[{name:"model_id",val:": str"},{name:"trust_remote_code",val:": bool = False"},{name:"load_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"apply_chat_template_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"smolagents.MLXModel.model_id",description:`<strong>model_id</strong> (str) &#x2014;
The Hugging Face model ID to be used for inference. This can be a path or model identifier from the Hugging Face model hub.`,name:"model_id"},{anchor:"smolagents.MLXModel.tool_name_key",description:`<strong>tool_name_key</strong> (str) &#x2014;
The key, which can usually be found in the model&#x2019;s chat template, for retrieving a tool name.`,name:"tool_name_key"},{anchor:"smolagents.MLXModel.tool_arguments_key",description:`<strong>tool_arguments_key</strong> (str) &#x2014;
The key, which can usually be found in the model&#x2019;s chat template, for retrieving tool arguments.`,name:"tool_arguments_key"},{anchor:"smolagents.MLXModel.trust_remote_code",description:`<strong>trust_remote_code</strong> (bool, default <code>False</code>) &#x2014;
Some models on the Hub require running remote code: for this model, you would have to set this flag to True.`,name:"trust_remote_code"},{anchor:"smolagents.MLXModel.load_kwargs",description:`<strong>load_kwargs</strong> (dict[str, Any], <em>optional</em>) &#x2014;
Additional keyword arguments to pass to the <code>mlx.lm.load</code> method when loading the model and tokenizer.`,name:"load_kwargs"},{anchor:"smolagents.MLXModel.apply_chat_template_kwargs",description:`<strong>apply_chat_template_kwargs</strong> (dict, <em>optional</em>) &#x2014;
Additional keyword arguments to pass to the <code>apply_chat_template</code> method of the tokenizer.`,name:"apply_chat_template_kwargs"},{anchor:"smolagents.MLXModel.kwargs",description:`<strong>kwargs</strong> (dict, <em>optional</em>) &#x2014;
Any additional keyword arguments that you want to use in model.generate(), for instance <code>max_tokens</code>.`,name:"kwargs"}],source:"https://github.com/huggingface/smolagents/blob/v1.21.0/src/smolagents/models.py#L631"}}),R=new Oe({props:{warning:!1,$$slots:{default:[Bs]},$$scope:{ctx:b}}}),X=new ss({props:{anchor:"smolagents.MLXModel.example",$$slots:{default:[Vs]},$$scope:{ctx:b}}}),Ae=new Ns({props:{source:"https://github.com/huggingface/smolagents/blob/main/docs/source/zh/reference/models.md"}}),{c(){o=c("meta"),_=l(),r=c("p"),p=l(),d($.$$.fragment),i=l(),d(w.$$.fragment),De=l(),G=c("p"),G.innerHTML=ns,Ye=l(),d(O.$$.fragment),Ke=l(),D=c("p"),D.textContent=os,et=l(),Y=c("p"),Y.innerHTML=ls,tt=l(),K=c("ol"),K.innerHTML=as,st=l(),ee=c("p"),ee.innerHTML=rs,nt=l(),d(te.$$.fragment),ot=l(),se=c("p"),se.innerHTML=is,lt=l(),d(ne.$$.fragment),at=l(),oe=c("p"),oe.innerHTML=cs,rt=l(),d(le.$$.fragment),it=l(),d(ae.$$.fragment),ct=l(),d(L.$$.fragment),mt=l(),J=c("div"),d(re.$$.fragment),Wt=l(),We=c("p"),We.textContent=ms,Bt=l(),Be=c("p"),Be.textContent=ps,Vt=l(),d(W.$$.fragment),Qt=l(),d(B.$$.fragment),pt=l(),d(ie.$$.fragment),dt=l(),ce=c("p"),ce.innerHTML=ds,gt=l(),d(me.$$.fragment),ut=l(),d(pe.$$.fragment),Mt=l(),I=c("div"),d(de.$$.fragment),zt=l(),Ve=c("p"),Ve.textContent=gs,St=l(),Qe=c("p"),Qe.textContent=us,Rt=l(),ze=c("p"),ze.textContent=Ms,Xt=l(),d(V.$$.fragment),Ht=l(),Q=c("div"),d(ge.$$.fragment),Pt=l(),Se=c("p"),Se.textContent=fs,ft=l(),d(ue.$$.fragment),ht=l(),Me=c("p"),Me.innerHTML=hs,Tt=l(),d(fe.$$.fragment),yt=l(),k=c("div"),d(he.$$.fragment),Ft=l(),Re=c("p"),Re.innerHTML=Ts,Gt=l(),z=c("div"),d(Te.$$.fragment),Ot=l(),Xe=c("p"),Xe.textContent=ys,_t=l(),d(ye.$$.fragment),$t=l(),_e=c("p"),_e.innerHTML=_s,wt=l(),d($e.$$.fragment),bt=l(),E=c("div"),d(we.$$.fragment),Dt=l(),He=c("p"),He.textContent=$s,It=l(),d(be.$$.fragment),Jt=l(),Ie=c("p"),Ie.innerHTML=ws,vt=l(),Je=c("p"),Je.innerHTML=bs,jt=l(),ve=c("p"),ve.innerHTML=Is,Ut=l(),d(je.$$.fragment),Ct=l(),q=c("div"),d(Ue.$$.fragment),Yt=l(),Pe=c("p"),Pe.textContent=Js,kt=l(),d(Ce.$$.fragment),xt=l(),d(ke.$$.fragment),Nt=l(),d(xe.$$.fragment),At=l(),d(S.$$.fragment),Et=l(),j=c("div"),d(Ne.$$.fragment),Kt=l(),Fe=c("p"),Fe.textContent=vs,es=l(),d(R.$$.fragment),ts=l(),d(X.$$.fragment),qt=l(),d(Ae.$$.fragment),Zt=l(),Ge=c("p"),this.h()},l(e){const t=xs("svelte-u9bgzb",document.head);o=m(t,"META",{name:!0,content:!0}),t.forEach(s),_=a(e),r=m(e,"P",{}),N(r).forEach(s),p=a(e),g($.$$.fragment,e),i=a(e),g(w.$$.fragment,e),De=a(e),G=m(e,"P",{"data-svelte-h":!0}),y(G)!=="svelte-11nub39"&&(G.innerHTML=ns),Ye=a(e),g(O.$$.fragment,e),Ke=a(e),D=m(e,"P",{"data-svelte-h":!0}),y(D)!=="svelte-15ti981"&&(D.textContent=os),et=a(e),Y=m(e,"P",{"data-svelte-h":!0}),y(Y)!=="svelte-y6kvhr"&&(Y.innerHTML=ls),tt=a(e),K=m(e,"OL",{"data-svelte-h":!0}),y(K)!=="svelte-14peu6x"&&(K.innerHTML=as),st=a(e),ee=m(e,"P",{"data-svelte-h":!0}),y(ee)!=="svelte-mamej0"&&(ee.innerHTML=rs),nt=a(e),g(te.$$.fragment,e),ot=a(e),se=m(e,"P",{"data-svelte-h":!0}),y(se)!=="svelte-c0mv9r"&&(se.innerHTML=is),lt=a(e),g(ne.$$.fragment,e),at=a(e),oe=m(e,"P",{"data-svelte-h":!0}),y(oe)!=="svelte-tirv5b"&&(oe.innerHTML=cs),rt=a(e),g(le.$$.fragment,e),it=a(e),g(ae.$$.fragment,e),ct=a(e),g(L.$$.fragment,e),mt=a(e),J=m(e,"DIV",{class:!0});var U=N(J);g(re.$$.fragment,U),Wt=a(U),We=m(U,"P",{"data-svelte-h":!0}),y(We)!=="svelte-1ex1ahr"&&(We.textContent=ms),Bt=a(U),Be=m(U,"P",{"data-svelte-h":!0}),y(Be)!=="svelte-1140acn"&&(Be.textContent=ps),Vt=a(U),g(W.$$.fragment,U),Qt=a(U),g(B.$$.fragment,U),U.forEach(s),pt=a(e),g(ie.$$.fragment,e),dt=a(e),ce=m(e,"P",{"data-svelte-h":!0}),y(ce)!=="svelte-dz1cyo"&&(ce.innerHTML=ds),gt=a(e),g(me.$$.fragment,e),ut=a(e),g(pe.$$.fragment,e),Mt=a(e),I=m(e,"DIV",{class:!0});var v=N(I);g(de.$$.fragment,v),zt=a(v),Ve=m(v,"P",{"data-svelte-h":!0}),y(Ve)!=="svelte-axkcn3"&&(Ve.textContent=gs),St=a(v),Qe=m(v,"P",{"data-svelte-h":!0}),y(Qe)!=="svelte-bducrc"&&(Qe.textContent=us),Rt=a(v),ze=m(v,"P",{"data-svelte-h":!0}),y(ze)!=="svelte-12eu297"&&(ze.textContent=Ms),Xt=a(v),g(V.$$.fragment,v),Ht=a(v),Q=m(v,"DIV",{class:!0});var Ee=N(Q);g(ge.$$.fragment,Ee),Pt=a(Ee),Se=m(Ee,"P",{"data-svelte-h":!0}),y(Se)!=="svelte-ym2f5u"&&(Se.textContent=fs),Ee.forEach(s),v.forEach(s),ft=a(e),g(ue.$$.fragment,e),ht=a(e),Me=m(e,"P",{"data-svelte-h":!0}),y(Me)!=="svelte-131mixa"&&(Me.innerHTML=hs),Tt=a(e),g(fe.$$.fragment,e),yt=a(e),k=m(e,"DIV",{class:!0});var Z=N(k);g(he.$$.fragment,Z),Ft=a(Z),Re=m(Z,"P",{"data-svelte-h":!0}),y(Re)!=="svelte-5g97zk"&&(Re.innerHTML=Ts),Gt=a(Z),z=m(Z,"DIV",{class:!0});var qe=N(z);g(Te.$$.fragment,qe),Ot=a(qe),Xe=m(qe,"P",{"data-svelte-h":!0}),y(Xe)!=="svelte-12r14rd"&&(Xe.textContent=ys),qe.forEach(s),Z.forEach(s),_t=a(e),g(ye.$$.fragment,e),$t=a(e),_e=m(e,"P",{"data-svelte-h":!0}),y(_e)!=="svelte-k9txw"&&(_e.innerHTML=_s),wt=a(e),g($e.$$.fragment,e),bt=a(e),E=m(e,"DIV",{class:!0});var Ze=N(E);g(we.$$.fragment,Ze),Dt=a(Ze),He=m(Ze,"P",{"data-svelte-h":!0}),y(He)!=="svelte-1bc1pfc"&&(He.textContent=$s),Ze.forEach(s),It=a(e),g(be.$$.fragment,e),Jt=a(e),Ie=m(e,"P",{"data-svelte-h":!0}),y(Ie)!=="svelte-1mey86d"&&(Ie.innerHTML=ws),vt=a(e),Je=m(e,"P",{"data-svelte-h":!0}),y(Je)!=="svelte-yktcaa"&&(Je.innerHTML=bs),jt=a(e),ve=m(e,"P",{"data-svelte-h":!0}),y(ve)!=="svelte-14bqt2g"&&(ve.innerHTML=Is),Ut=a(e),g(je.$$.fragment,e),Ct=a(e),q=m(e,"DIV",{class:!0});var Le=N(q);g(Ue.$$.fragment,Le),Yt=a(Le),Pe=m(Le,"P",{"data-svelte-h":!0}),y(Pe)!=="svelte-1fspdqk"&&(Pe.textContent=Js),Le.forEach(s),kt=a(e),g(Ce.$$.fragment,e),xt=a(e),g(ke.$$.fragment,e),Nt=a(e),g(xe.$$.fragment,e),At=a(e),g(S.$$.fragment,e),Et=a(e),j=m(e,"DIV",{class:!0});var x=N(j);g(Ne.$$.fragment,x),Kt=a(x),Fe=m(x,"P",{"data-svelte-h":!0}),y(Fe)!=="svelte-t9ku5w"&&(Fe.textContent=vs),es=a(x),g(R.$$.fragment,x),ts=a(x),g(X.$$.fragment,x),x.forEach(s),qt=a(e),g(Ae.$$.fragment,e),Zt=a(e),Ge=m(e,"P",{}),N(Ge).forEach(s),this.h()},h(){A(o,"name","hf:doc:metadata"),A(o,"content",zs),A(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){T(document.head,o),n(e,_,t),n(e,r,t),n(e,p,t),u($,e,t),n(e,i,t),u(w,e,t),n(e,De,t),n(e,G,t),n(e,Ye,t),u(O,e,t),n(e,Ke,t),n(e,D,t),n(e,et,t),n(e,Y,t),n(e,tt,t),n(e,K,t),n(e,st,t),n(e,ee,t),n(e,nt,t),u(te,e,t),n(e,ot,t),n(e,se,t),n(e,lt,t),u(ne,e,t),n(e,at,t),n(e,oe,t),n(e,rt,t),u(le,e,t),n(e,it,t),u(ae,e,t),n(e,ct,t),u(L,e,t),n(e,mt,t),n(e,J,t),u(re,J,null),T(J,Wt),T(J,We),T(J,Bt),T(J,Be),T(J,Vt),u(W,J,null),T(J,Qt),u(B,J,null),n(e,pt,t),u(ie,e,t),n(e,dt,t),n(e,ce,t),n(e,gt,t),u(me,e,t),n(e,ut,t),u(pe,e,t),n(e,Mt,t),n(e,I,t),u(de,I,null),T(I,zt),T(I,Ve),T(I,St),T(I,Qe),T(I,Rt),T(I,ze),T(I,Xt),u(V,I,null),T(I,Ht),T(I,Q),u(ge,Q,null),T(Q,Pt),T(Q,Se),n(e,ft,t),u(ue,e,t),n(e,ht,t),n(e,Me,t),n(e,Tt,t),u(fe,e,t),n(e,yt,t),n(e,k,t),u(he,k,null),T(k,Ft),T(k,Re),T(k,Gt),T(k,z),u(Te,z,null),T(z,Ot),T(z,Xe),n(e,_t,t),u(ye,e,t),n(e,$t,t),n(e,_e,t),n(e,wt,t),u($e,e,t),n(e,bt,t),n(e,E,t),u(we,E,null),T(E,Dt),T(E,He),n(e,It,t),u(be,e,t),n(e,Jt,t),n(e,Ie,t),n(e,vt,t),n(e,Je,t),n(e,jt,t),n(e,ve,t),n(e,Ut,t),u(je,e,t),n(e,Ct,t),n(e,q,t),u(Ue,q,null),T(q,Yt),T(q,Pe),n(e,kt,t),u(Ce,e,t),n(e,xt,t),u(ke,e,t),n(e,Nt,t),u(xe,e,t),n(e,At,t),u(S,e,t),n(e,Et,t),n(e,j,t),u(Ne,j,null),T(j,Kt),T(j,Fe),T(j,es),u(R,j,null),T(j,ts),u(X,j,null),n(e,qt,t),u(Ae,e,t),n(e,Zt,t),n(e,Ge,t),Lt=!0},p(e,[t]){const U={};t&2&&(U.$$scope={dirty:t,ctx:e}),w.$set(U);const v={};t&2&&(v.$$scope={dirty:t,ctx:e}),L.$set(v);const Ee={};t&2&&(Ee.$$scope={dirty:t,ctx:e}),W.$set(Ee);const Z={};t&2&&(Z.$$scope={dirty:t,ctx:e}),B.$set(Z);const qe={};t&2&&(qe.$$scope={dirty:t,ctx:e}),V.$set(qe);const Ze={};t&2&&(Ze.$$scope={dirty:t,ctx:e}),S.$set(Ze);const Le={};t&2&&(Le.$$scope={dirty:t,ctx:e}),R.$set(Le);const x={};t&2&&(x.$$scope={dirty:t,ctx:e}),X.$set(x)},i(e){Lt||(M($.$$.fragment,e),M(w.$$.fragment,e),M(O.$$.fragment,e),M(te.$$.fragment,e),M(ne.$$.fragment,e),M(le.$$.fragment,e),M(ae.$$.fragment,e),M(L.$$.fragment,e),M(re.$$.fragment,e),M(W.$$.fragment,e),M(B.$$.fragment,e),M(ie.$$.fragment,e),M(me.$$.fragment,e),M(pe.$$.fragment,e),M(de.$$.fragment,e),M(V.$$.fragment,e),M(ge.$$.fragment,e),M(ue.$$.fragment,e),M(fe.$$.fragment,e),M(he.$$.fragment,e),M(Te.$$.fragment,e),M(ye.$$.fragment,e),M($e.$$.fragment,e),M(we.$$.fragment,e),M(be.$$.fragment,e),M(je.$$.fragment,e),M(Ue.$$.fragment,e),M(Ce.$$.fragment,e),M(ke.$$.fragment,e),M(xe.$$.fragment,e),M(S.$$.fragment,e),M(Ne.$$.fragment,e),M(R.$$.fragment,e),M(X.$$.fragment,e),M(Ae.$$.fragment,e),Lt=!0)},o(e){f($.$$.fragment,e),f(w.$$.fragment,e),f(O.$$.fragment,e),f(te.$$.fragment,e),f(ne.$$.fragment,e),f(le.$$.fragment,e),f(ae.$$.fragment,e),f(L.$$.fragment,e),f(re.$$.fragment,e),f(W.$$.fragment,e),f(B.$$.fragment,e),f(ie.$$.fragment,e),f(me.$$.fragment,e),f(pe.$$.fragment,e),f(de.$$.fragment,e),f(V.$$.fragment,e),f(ge.$$.fragment,e),f(ue.$$.fragment,e),f(fe.$$.fragment,e),f(he.$$.fragment,e),f(Te.$$.fragment,e),f(ye.$$.fragment,e),f($e.$$.fragment,e),f(we.$$.fragment,e),f(be.$$.fragment,e),f(je.$$.fragment,e),f(Ue.$$.fragment,e),f(Ce.$$.fragment,e),f(ke.$$.fragment,e),f(xe.$$.fragment,e),f(S.$$.fragment,e),f(Ne.$$.fragment,e),f(R.$$.fragment,e),f(X.$$.fragment,e),f(Ae.$$.fragment,e),Lt=!1},d(e){e&&(s(_),s(r),s(p),s(i),s(De),s(G),s(Ye),s(Ke),s(D),s(et),s(Y),s(tt),s(K),s(st),s(ee),s(nt),s(ot),s(se),s(lt),s(at),s(oe),s(rt),s(it),s(ct),s(mt),s(J),s(pt),s(dt),s(ce),s(gt),s(ut),s(Mt),s(I),s(ft),s(ht),s(Me),s(Tt),s(yt),s(k),s(_t),s($t),s(_e),s(wt),s(bt),s(E),s(It),s(Jt),s(Ie),s(vt),s(Je),s(jt),s(ve),s(Ut),s(Ct),s(q),s(kt),s(xt),s(Nt),s(At),s(Et),s(j),s(qt),s(Zt),s(Ge)),s(o),h($,e),h(w,e),h(O,e),h(te,e),h(ne,e),h(le,e),h(ae,e),h(L,e),h(re),h(W),h(B),h(ie,e),h(me,e),h(pe,e),h(de),h(V),h(ge),h(ue,e),h(fe,e),h(he),h(Te),h(ye,e),h($e,e),h(we),h(be,e),h(je,e),h(Ue),h(Ce,e),h(ke,e),h(xe,e),h(S,e),h(Ne),h(R),h(X),h(Ae,e)}}}const zs='{"title":"模型","local":"模型","sections":[{"title":"模型","local":"模型","sections":[{"title":"TransformersModel","local":"smolagents.TransformersModel","sections":[],"depth":3},{"title":"InferenceClientModel","local":"smolagents.InferenceClientModel","sections":[],"depth":3},{"title":"LiteLLMModel","local":"smolagents.LiteLLMModel","sections":[],"depth":3},{"title":"OpenAIServerModel","local":"smolagents.OpenAIServerModel","sections":[],"depth":3},{"title":"AzureOpenAIServerModel","local":"smolagents.AzureOpenAIServerModel","sections":[],"depth":3},{"title":"MLXModel","local":"smolagents.MLXModel","sections":[],"depth":3}],"depth":2}],"depth":1}';function Ss(b){return Us(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Os extends Cs{constructor(o){super(),ks(this,o,Ss,Qs,js,{})}}export{Os as component};
