import{s as js,o as Us,n as F}from"../chunks/scheduler.f6319a2a.js";import{S as ks,i as Cs,g as c,s as l,r as p,A as xs,h as m,f as s,c as a,j as N,u as g,x as _,k as A,y as T,a as n,v as u,d as f,t as M,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.3d8cc3b7.js";import{C as k}from"../chunks/CodeBlock.3400fc53.js";import{H as P,E as Ns}from"../chunks/getInferenceSnippets.55a93fbe.js";function As(b){let o,y="Smolagents 是一个实验性 API，其可能会随时发生更改。由于 API 或底层模型可能会变化，智能体返回的结果可能会有所不同。";return{c(){o=c("p"),o.textContent=y},l(r){o=m(r,"P",{"data-svelte-h":!0}),_(o)!=="svelte-j62iso"&&(o.textContent=y)},m(r,d){n(r,o,d)},p:F,d(r){r&&s(o)}}}function Es(b){let o,y="您必须在机器上安装 <code>transformers</code> 和 <code>torch</code>。如果尚未安装，请运行 <code>pip install &#39;smolagents[transformers]&#39;</code>。";return{c(){o=c("p"),o.innerHTML=y},l(r){o=m(r,"P",{"data-svelte-h":!0}),_(o)!=="svelte-8yqd9p"&&(o.innerHTML=y)},m(r,d){n(r,o,d)},p:F,d(r){r&&s(o)}}}function qs(b){let o,y="You must have <code>transformers</code> and <code>torch</code> installed on your machine. Please run <code>pip install &#39;smolagents[transformers]&#39;</code> if it’s not the case.";return{c(){o=c("p"),o.innerHTML=y},l(r){o=m(r,"P",{"data-svelte-h":!0}),_(o)!=="svelte-2avciv"&&(o.innerHTML=y)},m(r,d){n(r,o,d)},p:F,d(r){r&&s(o)}}}function Ls(b){let o,y="Example:",r,d,w;return d=new k({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=y,r=l(),p(d.$$.fragment)},l(i){o=m(i,"P",{"data-svelte-h":!0}),_(o)!=="svelte-11lpom8"&&(o.textContent=y),r=a(i),g(d.$$.fragment,i)},m(i,$){n(i,o,$),n(i,r,$),u(d,i,$),w=!0},p:F,i(i){w||(f(d.$$.fragment,i),w=!0)},o(i){M(d.$$.fragment,i),w=!1},d(i){i&&(s(o),s(r)),h(d,i)}}}function Zs(b){let o,y="Example:",r,d,w;return d=new k({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=y,r=l(),p(d.$$.fragment)},l(i){o=m(i,"P",{"data-svelte-h":!0}),_(o)!=="svelte-11lpom8"&&(o.textContent=y),r=a(i),g(d.$$.fragment,i)},m(i,$){n(i,o,$),n(i,r,$),u(d,i,$),w=!0},p:F,i(i){w||(f(d.$$.fragment,i),w=!0)},o(i){M(d.$$.fragment,i),w=!1},d(i){i&&(s(o),s(r)),h(d,i)}}}function Ws(b){let o,y="您必须在机器上安装 <code>mlx-lm</code>。如果尚未安装，请运行 <code>pip install &#39;smolagents[mlx-lm]&#39;</code>。";return{c(){o=c("p"),o.innerHTML=y},l(r){o=m(r,"P",{"data-svelte-h":!0}),_(o)!=="svelte-zfi3tc"&&(o.innerHTML=y)},m(r,d){n(r,o,d)},p:F,d(r){r&&s(o)}}}function Bs(b){let o,y="You must have <code>mlx-lm</code> installed on your machine. Please run <code>pip install &#39;smolagents[mlx-lm]&#39;</code> if it’s not the case.";return{c(){o=c("p"),o.innerHTML=y},l(r){o=m(r,"P",{"data-svelte-h":!0}),_(o)!=="svelte-1u8nbd9"&&(o.innerHTML=y)},m(r,d){n(r,o,d)},p:F,d(r){r&&s(o)}}}function Vs(b){let o,y="Example:",r,d,w;return d=new k({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=y,r=l(),p(d.$$.fragment)},l(i){o=m(i,"P",{"data-svelte-h":!0}),_(o)!=="svelte-11lpom8"&&(o.textContent=y),r=a(i),g(d.$$.fragment,i)},m(i,$){n(i,o,$),n(i,r,$),u(d,i,$),w=!0},p:F,i(i){w||(f(d.$$.fragment,i),w=!0)},o(i){M(d.$$.fragment,i),w=!1},d(i){i&&(s(o),s(r)),h(d,i)}}}function Qs(b){let o,y,r,d,w,i,$,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,Z,mt,J,re,Wt,We,ms="A class that uses Hugging Face’s Transformers library for language model interaction.",Bt,Be,ds="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,dt,ie,pt,ce,ps='<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,de,ft,I,pe,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.",Xt,ze,fs="Providers include Cerebras, Cohere, Fal, Fireworks, HF-Inference, Hyperbolic, Nebius, Novita, Replicate, SambaNova, Together, and more.",Rt,V,Ht,Q,ge,Pt,Se,Ms="Create the Hugging Face client.",Mt,ue,ht,fe,hs='<code>LiteLLMModel</code> 利用 <a href="https://www.litellm.ai/" rel="nofollow">LiteLLM</a> 支持来自不同提供商的 100+ 个 LLM。您可以在模型初始化时传递 <code>kwargs</code>，这些参数将在每次使用模型时被使用，例如下面的示例中传递了 <code>temperature</code>。',Tt,Me,_t,C,he,Ft,Xe,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,Re,_s="Create the LiteLLM client.",yt,_e,wt,ye,ys=`此类允许您调用任何 OpenAIServer 兼容模型。
以下是设置方法（您可以自定义 <code>api_base</code> URL 指向其他服务器）：`,$t,we,bt,E,$e,Dt,He,ws="This model connects to an OpenAI-compatible API server.",It,be,Jt,Ie,$s="<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,kt,q,Ue,Yt,Pe,Js="This model connects to an Azure OpenAI deployment.",Ct,ke,xt,Ce,Nt,xe,At,S,Et,j,Ne,Kt,Fe,vs="A class to interact with models loaded using MLX on Apple silicon.",es,X,ts,R,qt,Ae,Lt,Ge,Zt;return w=new P({props:{title:"模型",local:"模型",headingTag:"h1"}}),$=new Oe({props:{warning:!0,$$slots:{default:[As]},$$scope:{ctx:b}}}),O=new P({props:{title:"模型",local:"模型",headingTag:"h2"}}),te=new k({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 k({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 k({props:{code:"V2hhdCUyMGE=",highlighted:"&gt;&gt;&gt; What a",wrap:!1}}),Z=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:"max_new_tokens",val:": int = 4096"},{name:"max_tokens",val:": int | 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.max_new_tokens",description:`<strong>max_new_tokens</strong> (<code>int</code>, default <code>4096</code>) &#x2014;
Maximum number of new tokens to generate, ignoring the number of tokens in the prompt.`,name:"max_new_tokens"},{anchor:"smolagents.TransformersModel.max_tokens",description:`<strong>max_tokens</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Alias for <code>max_new_tokens</code>. If provided, this value takes precedence.`,name:"max_tokens"},{anchor:"smolagents.TransformersModel.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments to forward to the underlying Transformers model generate call, such as <code>device</code>.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L782",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:[Ls]},$$scope:{ctx:b}}}),ie=new P({props:{title:"InferenceClientModel",local:"smolagents.InferenceClientModel",headingTag:"h3"}}),me=new k({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}}),de=new k({props:{code:"T2YlMjBjb3Vyc2UhJTIwSWYlMjB5b3UlMjBjaGFuZ2UlMjB5b3VyJTIwbWluZCUyQyUyMGZlZWwlMjBmcmVlJTIwdG8lMjByZWFjaCUyMG91dC4lMjBUYWtlJTIwY2FyZSE=",highlighted:"&gt;&gt;&gt; Of course! If you change your mind, feel free to reach out. Take care!",wrap:!1}}),pe=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/main/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/main/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 forward to the underlying Hugging Face InferenceClient completion call.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L1339",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:[Zs]},$$scope:{ctx:b}}}),ge=new H({props:{name:"create_client",anchor:"smolagents.InferenceClientModel.create_client",parameters:[],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L1430"}}),ue=new P({props:{title:"LiteLLMModel",local:"smolagents.LiteLLMModel",headingTag:"h3"}}),Me=new k({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 forward to the underlying LiteLLM completion call.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L1096"}}),Te=new H({props:{name:"create_client",anchor:"smolagents.LiteLLMModel.create_client",parameters:[],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L1146"}}),_e=new P({props:{title:"OpenAIServerModel",local:"smolagents.OpenAIServerModel",headingTag:"h3"}}),we=new k({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}}),$e=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 forward to the underlying OpenAI API completion call, for instance <code>temperature</code>.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L1521"}}),be=new P({props:{title:"AzureOpenAIServerModel",local:"smolagents.AzureOpenAIServerModel",headingTag:"h3"}}),je=new k({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 forward to the underlying Azure OpenAI API completion call.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L1666"}}),ke=new P({props:{title:"MLXModel",local:"smolagents.MLXModel",headingTag:"h3"}}),Ce=new k({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 k({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> &#x2014;
Additional keyword arguments to forward to the underlying MLX model stream_generate call, for instance <code>max_tokens</code>.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L675"}}),X=new Oe({props:{warning:!1,$$slots:{default:[Bs]},$$scope:{ctx:b}}}),R=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"),y=l(),r=c("p"),d=l(),p(w.$$.fragment),i=l(),p($.$$.fragment),De=l(),G=c("p"),G.innerHTML=ns,Ye=l(),p(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(),p(te.$$.fragment),ot=l(),se=c("p"),se.innerHTML=is,lt=l(),p(ne.$$.fragment),at=l(),oe=c("p"),oe.innerHTML=cs,rt=l(),p(le.$$.fragment),it=l(),p(ae.$$.fragment),ct=l(),p(Z.$$.fragment),mt=l(),J=c("div"),p(re.$$.fragment),Wt=l(),We=c("p"),We.textContent=ms,Bt=l(),Be=c("p"),Be.textContent=ds,Vt=l(),p(W.$$.fragment),Qt=l(),p(B.$$.fragment),dt=l(),p(ie.$$.fragment),pt=l(),ce=c("p"),ce.innerHTML=ps,gt=l(),p(me.$$.fragment),ut=l(),p(de.$$.fragment),ft=l(),I=c("div"),p(pe.$$.fragment),zt=l(),Ve=c("p"),Ve.textContent=gs,St=l(),Qe=c("p"),Qe.textContent=us,Xt=l(),ze=c("p"),ze.textContent=fs,Rt=l(),p(V.$$.fragment),Ht=l(),Q=c("div"),p(ge.$$.fragment),Pt=l(),Se=c("p"),Se.textContent=Ms,Mt=l(),p(ue.$$.fragment),ht=l(),fe=c("p"),fe.innerHTML=hs,Tt=l(),p(Me.$$.fragment),_t=l(),C=c("div"),p(he.$$.fragment),Ft=l(),Xe=c("p"),Xe.innerHTML=Ts,Gt=l(),z=c("div"),p(Te.$$.fragment),Ot=l(),Re=c("p"),Re.textContent=_s,yt=l(),p(_e.$$.fragment),wt=l(),ye=c("p"),ye.innerHTML=ys,$t=l(),p(we.$$.fragment),bt=l(),E=c("div"),p($e.$$.fragment),Dt=l(),He=c("p"),He.textContent=ws,It=l(),p(be.$$.fragment),Jt=l(),Ie=c("p"),Ie.innerHTML=$s,vt=l(),Je=c("p"),Je.innerHTML=bs,jt=l(),ve=c("p"),ve.innerHTML=Is,Ut=l(),p(je.$$.fragment),kt=l(),q=c("div"),p(Ue.$$.fragment),Yt=l(),Pe=c("p"),Pe.textContent=Js,Ct=l(),p(ke.$$.fragment),xt=l(),p(Ce.$$.fragment),Nt=l(),p(xe.$$.fragment),At=l(),p(S.$$.fragment),Et=l(),j=c("div"),p(Ne.$$.fragment),Kt=l(),Fe=c("p"),Fe.textContent=vs,es=l(),p(X.$$.fragment),ts=l(),p(R.$$.fragment),qt=l(),p(Ae.$$.fragment),Lt=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),y=a(e),r=m(e,"P",{}),N(r).forEach(s),d=a(e),g(w.$$.fragment,e),i=a(e),g($.$$.fragment,e),De=a(e),G=m(e,"P",{"data-svelte-h":!0}),_(G)!=="svelte-11nub39"&&(G.innerHTML=ns),Ye=a(e),g(O.$$.fragment,e),Ke=a(e),D=m(e,"P",{"data-svelte-h":!0}),_(D)!=="svelte-15ti981"&&(D.textContent=os),et=a(e),Y=m(e,"P",{"data-svelte-h":!0}),_(Y)!=="svelte-y6kvhr"&&(Y.innerHTML=ls),tt=a(e),K=m(e,"OL",{"data-svelte-h":!0}),_(K)!=="svelte-14peu6x"&&(K.innerHTML=as),st=a(e),ee=m(e,"P",{"data-svelte-h":!0}),_(ee)!=="svelte-mamej0"&&(ee.innerHTML=rs),nt=a(e),g(te.$$.fragment,e),ot=a(e),se=m(e,"P",{"data-svelte-h":!0}),_(se)!=="svelte-c0mv9r"&&(se.innerHTML=is),lt=a(e),g(ne.$$.fragment,e),at=a(e),oe=m(e,"P",{"data-svelte-h":!0}),_(oe)!=="svelte-tirv5b"&&(oe.innerHTML=cs),rt=a(e),g(le.$$.fragment,e),it=a(e),g(ae.$$.fragment,e),ct=a(e),g(Z.$$.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}),_(We)!=="svelte-1ex1ahr"&&(We.textContent=ms),Bt=a(U),Be=m(U,"P",{"data-svelte-h":!0}),_(Be)!=="svelte-1140acn"&&(Be.textContent=ds),Vt=a(U),g(W.$$.fragment,U),Qt=a(U),g(B.$$.fragment,U),U.forEach(s),dt=a(e),g(ie.$$.fragment,e),pt=a(e),ce=m(e,"P",{"data-svelte-h":!0}),_(ce)!=="svelte-dz1cyo"&&(ce.innerHTML=ps),gt=a(e),g(me.$$.fragment,e),ut=a(e),g(de.$$.fragment,e),ft=a(e),I=m(e,"DIV",{class:!0});var v=N(I);g(pe.$$.fragment,v),zt=a(v),Ve=m(v,"P",{"data-svelte-h":!0}),_(Ve)!=="svelte-axkcn3"&&(Ve.textContent=gs),St=a(v),Qe=m(v,"P",{"data-svelte-h":!0}),_(Qe)!=="svelte-bducrc"&&(Qe.textContent=us),Xt=a(v),ze=m(v,"P",{"data-svelte-h":!0}),_(ze)!=="svelte-12eu297"&&(ze.textContent=fs),Rt=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}),_(Se)!=="svelte-ym2f5u"&&(Se.textContent=Ms),Ee.forEach(s),v.forEach(s),Mt=a(e),g(ue.$$.fragment,e),ht=a(e),fe=m(e,"P",{"data-svelte-h":!0}),_(fe)!=="svelte-131mixa"&&(fe.innerHTML=hs),Tt=a(e),g(Me.$$.fragment,e),_t=a(e),C=m(e,"DIV",{class:!0});var L=N(C);g(he.$$.fragment,L),Ft=a(L),Xe=m(L,"P",{"data-svelte-h":!0}),_(Xe)!=="svelte-5g97zk"&&(Xe.innerHTML=Ts),Gt=a(L),z=m(L,"DIV",{class:!0});var qe=N(z);g(Te.$$.fragment,qe),Ot=a(qe),Re=m(qe,"P",{"data-svelte-h":!0}),_(Re)!=="svelte-12r14rd"&&(Re.textContent=_s),qe.forEach(s),L.forEach(s),yt=a(e),g(_e.$$.fragment,e),wt=a(e),ye=m(e,"P",{"data-svelte-h":!0}),_(ye)!=="svelte-k9txw"&&(ye.innerHTML=ys),$t=a(e),g(we.$$.fragment,e),bt=a(e),E=m(e,"DIV",{class:!0});var Le=N(E);g($e.$$.fragment,Le),Dt=a(Le),He=m(Le,"P",{"data-svelte-h":!0}),_(He)!=="svelte-1bc1pfc"&&(He.textContent=ws),Le.forEach(s),It=a(e),g(be.$$.fragment,e),Jt=a(e),Ie=m(e,"P",{"data-svelte-h":!0}),_(Ie)!=="svelte-1mey86d"&&(Ie.innerHTML=$s),vt=a(e),Je=m(e,"P",{"data-svelte-h":!0}),_(Je)!=="svelte-yktcaa"&&(Je.innerHTML=bs),jt=a(e),ve=m(e,"P",{"data-svelte-h":!0}),_(ve)!=="svelte-14bqt2g"&&(ve.innerHTML=Is),Ut=a(e),g(je.$$.fragment,e),kt=a(e),q=m(e,"DIV",{class:!0});var Ze=N(q);g(Ue.$$.fragment,Ze),Yt=a(Ze),Pe=m(Ze,"P",{"data-svelte-h":!0}),_(Pe)!=="svelte-1fspdqk"&&(Pe.textContent=Js),Ze.forEach(s),Ct=a(e),g(ke.$$.fragment,e),xt=a(e),g(Ce.$$.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}),_(Fe)!=="svelte-t9ku5w"&&(Fe.textContent=vs),es=a(x),g(X.$$.fragment,x),ts=a(x),g(R.$$.fragment,x),x.forEach(s),qt=a(e),g(Ae.$$.fragment,e),Lt=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(C,"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,y,t),n(e,r,t),n(e,d,t),u(w,e,t),n(e,i,t),u($,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(Z,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,dt,t),u(ie,e,t),n(e,pt,t),n(e,ce,t),n(e,gt,t),u(me,e,t),n(e,ut,t),u(de,e,t),n(e,ft,t),n(e,I,t),u(pe,I,null),T(I,zt),T(I,Ve),T(I,St),T(I,Qe),T(I,Xt),T(I,ze),T(I,Rt),u(V,I,null),T(I,Ht),T(I,Q),u(ge,Q,null),T(Q,Pt),T(Q,Se),n(e,Mt,t),u(ue,e,t),n(e,ht,t),n(e,fe,t),n(e,Tt,t),u(Me,e,t),n(e,_t,t),n(e,C,t),u(he,C,null),T(C,Ft),T(C,Xe),T(C,Gt),T(C,z),u(Te,z,null),T(z,Ot),T(z,Re),n(e,yt,t),u(_e,e,t),n(e,wt,t),n(e,ye,t),n(e,$t,t),u(we,e,t),n(e,bt,t),n(e,E,t),u($e,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,kt,t),n(e,q,t),u(Ue,q,null),T(q,Yt),T(q,Pe),n(e,Ct,t),u(ke,e,t),n(e,xt,t),u(Ce,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(X,j,null),T(j,ts),u(R,j,null),n(e,qt,t),u(Ae,e,t),n(e,Lt,t),n(e,Ge,t),Zt=!0},p(e,[t]){const U={};t&2&&(U.$$scope={dirty:t,ctx:e}),$.$set(U);const v={};t&2&&(v.$$scope={dirty:t,ctx:e}),Z.$set(v);const Ee={};t&2&&(Ee.$$scope={dirty:t,ctx:e}),W.$set(Ee);const L={};t&2&&(L.$$scope={dirty:t,ctx:e}),B.$set(L);const qe={};t&2&&(qe.$$scope={dirty:t,ctx:e}),V.$set(qe);const Le={};t&2&&(Le.$$scope={dirty:t,ctx:e}),S.$set(Le);const Ze={};t&2&&(Ze.$$scope={dirty:t,ctx:e}),X.$set(Ze);const x={};t&2&&(x.$$scope={dirty:t,ctx:e}),R.$set(x)},i(e){Zt||(f(w.$$.fragment,e),f($.$$.fragment,e),f(O.$$.fragment,e),f(te.$$.fragment,e),f(ne.$$.fragment,e),f(le.$$.fragment,e),f(ae.$$.fragment,e),f(Z.$$.fragment,e),f(re.$$.fragment,e),f(W.$$.fragment,e),f(B.$$.fragment,e),f(ie.$$.fragment,e),f(me.$$.fragment,e),f(de.$$.fragment,e),f(pe.$$.fragment,e),f(V.$$.fragment,e),f(ge.$$.fragment,e),f(ue.$$.fragment,e),f(Me.$$.fragment,e),f(he.$$.fragment,e),f(Te.$$.fragment,e),f(_e.$$.fragment,e),f(we.$$.fragment,e),f($e.$$.fragment,e),f(be.$$.fragment,e),f(je.$$.fragment,e),f(Ue.$$.fragment,e),f(ke.$$.fragment,e),f(Ce.$$.fragment,e),f(xe.$$.fragment,e),f(S.$$.fragment,e),f(Ne.$$.fragment,e),f(X.$$.fragment,e),f(R.$$.fragment,e),f(Ae.$$.fragment,e),Zt=!0)},o(e){M(w.$$.fragment,e),M($.$$.fragment,e),M(O.$$.fragment,e),M(te.$$.fragment,e),M(ne.$$.fragment,e),M(le.$$.fragment,e),M(ae.$$.fragment,e),M(Z.$$.fragment,e),M(re.$$.fragment,e),M(W.$$.fragment,e),M(B.$$.fragment,e),M(ie.$$.fragment,e),M(me.$$.fragment,e),M(de.$$.fragment,e),M(pe.$$.fragment,e),M(V.$$.fragment,e),M(ge.$$.fragment,e),M(ue.$$.fragment,e),M(Me.$$.fragment,e),M(he.$$.fragment,e),M(Te.$$.fragment,e),M(_e.$$.fragment,e),M(we.$$.fragment,e),M($e.$$.fragment,e),M(be.$$.fragment,e),M(je.$$.fragment,e),M(Ue.$$.fragment,e),M(ke.$$.fragment,e),M(Ce.$$.fragment,e),M(xe.$$.fragment,e),M(S.$$.fragment,e),M(Ne.$$.fragment,e),M(X.$$.fragment,e),M(R.$$.fragment,e),M(Ae.$$.fragment,e),Zt=!1},d(e){e&&(s(y),s(r),s(d),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(dt),s(pt),s(ce),s(gt),s(ut),s(ft),s(I),s(Mt),s(ht),s(fe),s(Tt),s(_t),s(C),s(yt),s(wt),s(ye),s($t),s(bt),s(E),s(It),s(Jt),s(Ie),s(vt),s(Je),s(jt),s(ve),s(Ut),s(kt),s(q),s(Ct),s(xt),s(Nt),s(At),s(Et),s(j),s(qt),s(Lt),s(Ge)),s(o),h(w,e),h($,e),h(O,e),h(te,e),h(ne,e),h(le,e),h(ae,e),h(Z,e),h(re),h(W),h(B),h(ie,e),h(me,e),h(de,e),h(pe),h(V),h(ge),h(ue,e),h(Me,e),h(he),h(Te),h(_e,e),h(we,e),h($e),h(be,e),h(je,e),h(Ue),h(ke,e),h(Ce,e),h(xe,e),h(S,e),h(Ne),h(X),h(R),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 ks{constructor(o){super(),Cs(this,o,Ss,Qs,js,{})}}export{Os as component};
