import{s as Cs,o as xs,n as Lt}from"../chunks/scheduler.f6319a2a.js";import{S as Ns,i as As,g as r,s as o,r as d,A as qs,h as i,f as s,c as l,j as N,u as p,x as f,k as $,y as m,a as n,v as g,d as u,t as M,w as h}from"../chunks/index.85aa684c.js";import{T as Es,D as X,E as ts}from"../chunks/ExampleCodeBlock.7120e9d6.js";import{C as k}from"../chunks/CodeBlock.3400fc53.js";import{H as R,E as Ls}from"../chunks/getInferenceSnippets.0233181f.js";function Zs(x){let c,I="Smolagents 是一个实验性 API，其可能会随时发生更改。由于 API 或底层模型可能会变化，智能体返回的结果可能会有所不同。";return{c(){c=r("p"),c.textContent=I},l(y){c=i(y,"P",{"data-svelte-h":!0}),f(c)!=="svelte-j62iso"&&(c.textContent=I)},m(y,T){n(y,c,T)},p:Lt,d(y){y&&s(c)}}}function Ws(x){let c,I="Example:",y,T,_;return T=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(){c=r("p"),c.textContent=I,y=o(),d(T.$$.fragment)},l(a){c=i(a,"P",{"data-svelte-h":!0}),f(c)!=="svelte-11lpom8"&&(c.textContent=I),y=l(a),p(T.$$.fragment,a)},m(a,w){n(a,c,w),n(a,y,w),g(T,a,w),_=!0},p:Lt,i(a){_||(u(T.$$.fragment,a),_=!0)},o(a){M(T.$$.fragment,a),_=!1},d(a){a&&(s(c),s(y)),h(T,a)}}}function Bs(x){let c,I="Example:",y,T,_;return T=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(){c=r("p"),c.textContent=I,y=o(),d(T.$$.fragment)},l(a){c=i(a,"P",{"data-svelte-h":!0}),f(c)!=="svelte-11lpom8"&&(c.textContent=I),y=l(a),p(T.$$.fragment,a)},m(a,w){n(a,c,w),n(a,y,w),g(T,a,w),_=!0},p:Lt,i(a){_||(u(T.$$.fragment,a),_=!0)},o(a){M(T.$$.fragment,a),_=!1},d(a){a&&(s(c),s(y)),h(T,a)}}}function Qs(x){let c,I="Example:",y,T,_;return T=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(){c=r("p"),c.textContent=I,y=o(),d(T.$$.fragment)},l(a){c=i(a,"P",{"data-svelte-h":!0}),f(c)!=="svelte-11lpom8"&&(c.textContent=I),y=l(a),p(T.$$.fragment,a)},m(a,w){n(a,c,w),n(a,y,w),g(T,a,w),_=!0},p:Lt,i(a){_||(u(T.$$.fragment,a),_=!0)},o(a){M(T.$$.fragment,a),_=!1},d(a){a&&(s(c),s(y)),h(T,a)}}}function Vs(x){let c,I,y,T,_,a,w,He,H,ss='要了解有关智能体和工具的更多信息，请务必阅读<a href="../index">入门指南</a>。此页面包含底层类的 API 文档。',Fe,F,Pe,P,ns="您可以自由创建和使用自己的模型为智能体提供支持。",Oe,O,os="您可以使用任何 <code>model</code> 可调用对象作为智能体的模型，只要满足以下条件：",Ge,G,ls='<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>',De,D,as='要定义您的 LLM，可以创建一个 <code>custom_model</code> 方法，该方法接受一个 <a href="./chat_templating">messages</a> 列表，并返回一个包含 <code>.content</code> 属性的对象，其中包含生成的文本。此可调用对象还需要接受一个 <code>stop_sequences</code> 参数，用于指示何时停止生成。',Ye,Y,Ke,K,rs='此外，<code>custom_model</code> 还可以接受一个 <code>grammar</code> 参数。如果在智能体初始化时指定了 <code>grammar</code>，则此参数将在调用模型时传递，以便进行<a href="https://huggingface.co/docs/text-generation-inference/conceptual/guidance" rel="nofollow">约束生成</a>，从而强制生成格式正确的智能体输出。',et,ee,tt,te,is="为了方便起见，我们添加了一个 <code>TransformersModel</code>，该模型通过为初始化时指定的 <code>model_id</code> 构建一个本地 <code>transformers</code> pipeline 来实现上述功能。",st,se,nt,ne,ot,L,cs="<p>您必须在机器上安装 <code>transformers</code> 和 <code>torch</code>。如果尚未安装，请运行 <code>pip install &#39;smolagents[transformers]&#39;</code>。</p>",lt,J,oe,Zt,qe,ms="A class that uses Hugging Face’s Transformers library for language model interaction.",Wt,Ee,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.",Bt,le,ps="<p>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.</p>",Qt,Z,at,ae,rt,re,gs='<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>。',it,ie,ct,ce,mt,b,me,Vt,Le,us="A class to interact with Hugging Face’s Inference Providers for language model interaction.",zt,Ze,Ms="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.",St,We,hs="Providers include Cerebras, Cohere, Fal, Fireworks, HF-Inference, Hyperbolic, Nebius, Novita, Replicate, SambaNova, Together, and more.",Xt,W,Rt,B,de,Ht,Be,fs="Create the Hugging Face client.",dt,pe,pt,ge,Ts='<code>LiteLLMModel</code> 利用 <a href="https://www.litellm.ai/" rel="nofollow">LiteLLM</a> 支持来自不同提供商的 100+ 个 LLM。您可以在模型初始化时传递 <code>kwargs</code>，这些参数将在每次使用模型时被使用，例如下面的示例中传递了 <code>temperature</code>。',gt,ue,ut,C,Me,Ft,Qe,ys='Model to use <a href="https://docs.litellm.ai/docs/#litellm-python-sdk" rel="nofollow">LiteLLM Python SDK</a> to access hundreds of LLMs.',Pt,Q,he,Ot,Ve,_s="Create the LiteLLM client.",Mt,fe,ht,Te,ws=`此类允许您调用任何 OpenAIServer 兼容模型。
以下是设置方法（您可以自定义 <code>api_base</code> URL 指向其他服务器）：`,ft,ye,Tt,A,_e,Gt,ze,bs="This model connects to an OpenAI-compatible API server.",yt,we,_t,be,Is="<code>AzureOpenAIServerModel</code> 允许您连接到任何 Azure OpenAI 部署。",wt,Ie,Js="下面是设置示例，请注意，如果已经设置了相应的环境变量，您可以省略 <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>。",bt,Je,vs='请注意，<code>OPENAI_API_VERSION</code> 没有 <code>AZURE_</code> 前缀，这是由于底层 <a href="https://github.com/openai/openai-python" rel="nofollow">openai</a> 包的设计所致。',It,ve,Jt,q,$e,Dt,Se,$s="This model connects to an Azure OpenAI deployment.",vt,je,$t,Ue,jt,ke,Ut,V,js="<p>您必须在机器上安装 <code>mlx-lm</code>。如果尚未安装，请运行 <code>pip install &#39;smolagents[mlx-lm]&#39;</code>。</p>",kt,j,Ce,Yt,Xe,Us="A class to interact with models loaded using MLX on Apple silicon.",Kt,xe,ks="<p>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.</p>",es,z,Ct,Ne,xt,Re,Nt;return _=new R({props:{title:"模型",local:"模型",headingTag:"h1"}}),w=new Es({props:{warning:!0,$$slots:{default:[Zs]},$$scope:{ctx:x}}}),F=new R({props:{title:"模型",local:"模型",headingTag:"h2"}}),Y=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}}),ee=new R({props:{title:"TransformersModel",local:"smolagents.TransformersModel",headingTag:"h3"}}),se=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}}),ne=new k({props:{code:"V2hhdCUyMGE=",highlighted:"&gt;&gt;&gt; What a",wrap:!1}}),oe=new X({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>
`}}),Z=new ts({props:{anchor:"smolagents.TransformersModel.example",$$slots:{default:[Ws]},$$scope:{ctx:x}}}),ae=new R({props:{title:"InferenceClientModel",local:"smolagents.InferenceClientModel",headingTag:"h3"}}),ie=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}}),ce=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}}),me=new X({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#L1341",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 ts({props:{anchor:"smolagents.InferenceClientModel.example",$$slots:{default:[Bs]},$$scope:{ctx:x}}}),de=new X({props:{name:"create_client",anchor:"smolagents.InferenceClientModel.create_client",parameters:[],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L1432"}}),pe=new R({props:{title:"LiteLLMModel",local:"smolagents.LiteLLMModel",headingTag:"h3"}}),ue=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}}),Me=new X({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#L1098"}}),he=new X({props:{name:"create_client",anchor:"smolagents.LiteLLMModel.create_client",parameters:[],source:"https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L1148"}}),fe=new R({props:{title:"OpenAIServerModel",local:"smolagents.OpenAIServerModel",headingTag:"h3"}}),ye=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 X({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#L1523"}}),we=new R({props:{title:"AzureOpenAIServerModel",local:"smolagents.AzureOpenAIServerModel",headingTag:"h3"}}),ve=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}}),$e=new X({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#L1668"}}),je=new R({props:{title:"MLXModel",local:"smolagents.MLXModel",headingTag:"h3"}}),Ue=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}}),ke=new k({props:{code:"V2hhdCUyMGE=",highlighted:"&gt;&gt;&gt; What a",wrap:!1}}),Ce=new X({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"}}),z=new ts({props:{anchor:"smolagents.MLXModel.example",$$slots:{default:[Qs]},$$scope:{ctx:x}}}),Ne=new Ls({props:{source:"https://github.com/huggingface/smolagents/blob/main/docs/source/zh/reference/models.md"}}),{c(){c=r("meta"),I=o(),y=r("p"),T=o(),d(_.$$.fragment),a=o(),d(w.$$.fragment),He=o(),H=r("p"),H.innerHTML=ss,Fe=o(),d(F.$$.fragment),Pe=o(),P=r("p"),P.textContent=ns,Oe=o(),O=r("p"),O.innerHTML=os,Ge=o(),G=r("ol"),G.innerHTML=ls,De=o(),D=r("p"),D.innerHTML=as,Ye=o(),d(Y.$$.fragment),Ke=o(),K=r("p"),K.innerHTML=rs,et=o(),d(ee.$$.fragment),tt=o(),te=r("p"),te.innerHTML=is,st=o(),d(se.$$.fragment),nt=o(),d(ne.$$.fragment),ot=o(),L=r("blockquote"),L.innerHTML=cs,lt=o(),J=r("div"),d(oe.$$.fragment),Zt=o(),qe=r("p"),qe.textContent=ms,Wt=o(),Ee=r("p"),Ee.textContent=ds,Bt=o(),le=r("blockquote"),le.innerHTML=ps,Qt=o(),d(Z.$$.fragment),at=o(),d(ae.$$.fragment),rt=o(),re=r("p"),re.innerHTML=gs,it=o(),d(ie.$$.fragment),ct=o(),d(ce.$$.fragment),mt=o(),b=r("div"),d(me.$$.fragment),Vt=o(),Le=r("p"),Le.textContent=us,zt=o(),Ze=r("p"),Ze.textContent=Ms,St=o(),We=r("p"),We.textContent=hs,Xt=o(),d(W.$$.fragment),Rt=o(),B=r("div"),d(de.$$.fragment),Ht=o(),Be=r("p"),Be.textContent=fs,dt=o(),d(pe.$$.fragment),pt=o(),ge=r("p"),ge.innerHTML=Ts,gt=o(),d(ue.$$.fragment),ut=o(),C=r("div"),d(Me.$$.fragment),Ft=o(),Qe=r("p"),Qe.innerHTML=ys,Pt=o(),Q=r("div"),d(he.$$.fragment),Ot=o(),Ve=r("p"),Ve.textContent=_s,Mt=o(),d(fe.$$.fragment),ht=o(),Te=r("p"),Te.innerHTML=ws,ft=o(),d(ye.$$.fragment),Tt=o(),A=r("div"),d(_e.$$.fragment),Gt=o(),ze=r("p"),ze.textContent=bs,yt=o(),d(we.$$.fragment),_t=o(),be=r("p"),be.innerHTML=Is,wt=o(),Ie=r("p"),Ie.innerHTML=Js,bt=o(),Je=r("p"),Je.innerHTML=vs,It=o(),d(ve.$$.fragment),Jt=o(),q=r("div"),d($e.$$.fragment),Dt=o(),Se=r("p"),Se.textContent=$s,vt=o(),d(je.$$.fragment),$t=o(),d(Ue.$$.fragment),jt=o(),d(ke.$$.fragment),Ut=o(),V=r("blockquote"),V.innerHTML=js,kt=o(),j=r("div"),d(Ce.$$.fragment),Yt=o(),Xe=r("p"),Xe.textContent=Us,Kt=o(),xe=r("blockquote"),xe.innerHTML=ks,es=o(),d(z.$$.fragment),Ct=o(),d(Ne.$$.fragment),xt=o(),Re=r("p"),this.h()},l(e){const t=qs("svelte-u9bgzb",document.head);c=i(t,"META",{name:!0,content:!0}),t.forEach(s),I=l(e),y=i(e,"P",{}),N(y).forEach(s),T=l(e),p(_.$$.fragment,e),a=l(e),p(w.$$.fragment,e),He=l(e),H=i(e,"P",{"data-svelte-h":!0}),f(H)!=="svelte-11nub39"&&(H.innerHTML=ss),Fe=l(e),p(F.$$.fragment,e),Pe=l(e),P=i(e,"P",{"data-svelte-h":!0}),f(P)!=="svelte-15ti981"&&(P.textContent=ns),Oe=l(e),O=i(e,"P",{"data-svelte-h":!0}),f(O)!=="svelte-y6kvhr"&&(O.innerHTML=os),Ge=l(e),G=i(e,"OL",{"data-svelte-h":!0}),f(G)!=="svelte-14peu6x"&&(G.innerHTML=ls),De=l(e),D=i(e,"P",{"data-svelte-h":!0}),f(D)!=="svelte-mamej0"&&(D.innerHTML=as),Ye=l(e),p(Y.$$.fragment,e),Ke=l(e),K=i(e,"P",{"data-svelte-h":!0}),f(K)!=="svelte-c0mv9r"&&(K.innerHTML=rs),et=l(e),p(ee.$$.fragment,e),tt=l(e),te=i(e,"P",{"data-svelte-h":!0}),f(te)!=="svelte-tirv5b"&&(te.innerHTML=is),st=l(e),p(se.$$.fragment,e),nt=l(e),p(ne.$$.fragment,e),ot=l(e),L=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(L)!=="svelte-ouuan6"&&(L.innerHTML=cs),lt=l(e),J=i(e,"DIV",{class:!0});var U=N(J);p(oe.$$.fragment,U),Zt=l(U),qe=i(U,"P",{"data-svelte-h":!0}),f(qe)!=="svelte-1ex1ahr"&&(qe.textContent=ms),Wt=l(U),Ee=i(U,"P",{"data-svelte-h":!0}),f(Ee)!=="svelte-1140acn"&&(Ee.textContent=ds),Bt=l(U),le=i(U,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(le)!=="svelte-103z9yw"&&(le.innerHTML=ps),Qt=l(U),p(Z.$$.fragment,U),U.forEach(s),at=l(e),p(ae.$$.fragment,e),rt=l(e),re=i(e,"P",{"data-svelte-h":!0}),f(re)!=="svelte-dz1cyo"&&(re.innerHTML=gs),it=l(e),p(ie.$$.fragment,e),ct=l(e),p(ce.$$.fragment,e),mt=l(e),b=i(e,"DIV",{class:!0});var v=N(b);p(me.$$.fragment,v),Vt=l(v),Le=i(v,"P",{"data-svelte-h":!0}),f(Le)!=="svelte-axkcn3"&&(Le.textContent=us),zt=l(v),Ze=i(v,"P",{"data-svelte-h":!0}),f(Ze)!=="svelte-bducrc"&&(Ze.textContent=Ms),St=l(v),We=i(v,"P",{"data-svelte-h":!0}),f(We)!=="svelte-12eu297"&&(We.textContent=hs),Xt=l(v),p(W.$$.fragment,v),Rt=l(v),B=i(v,"DIV",{class:!0});var Ae=N(B);p(de.$$.fragment,Ae),Ht=l(Ae),Be=i(Ae,"P",{"data-svelte-h":!0}),f(Be)!=="svelte-ym2f5u"&&(Be.textContent=fs),Ae.forEach(s),v.forEach(s),dt=l(e),p(pe.$$.fragment,e),pt=l(e),ge=i(e,"P",{"data-svelte-h":!0}),f(ge)!=="svelte-131mixa"&&(ge.innerHTML=Ts),gt=l(e),p(ue.$$.fragment,e),ut=l(e),C=i(e,"DIV",{class:!0});var E=N(C);p(Me.$$.fragment,E),Ft=l(E),Qe=i(E,"P",{"data-svelte-h":!0}),f(Qe)!=="svelte-5g97zk"&&(Qe.innerHTML=ys),Pt=l(E),Q=i(E,"DIV",{class:!0});var At=N(Q);p(he.$$.fragment,At),Ot=l(At),Ve=i(At,"P",{"data-svelte-h":!0}),f(Ve)!=="svelte-12r14rd"&&(Ve.textContent=_s),At.forEach(s),E.forEach(s),Mt=l(e),p(fe.$$.fragment,e),ht=l(e),Te=i(e,"P",{"data-svelte-h":!0}),f(Te)!=="svelte-k9txw"&&(Te.innerHTML=ws),ft=l(e),p(ye.$$.fragment,e),Tt=l(e),A=i(e,"DIV",{class:!0});var qt=N(A);p(_e.$$.fragment,qt),Gt=l(qt),ze=i(qt,"P",{"data-svelte-h":!0}),f(ze)!=="svelte-1bc1pfc"&&(ze.textContent=bs),qt.forEach(s),yt=l(e),p(we.$$.fragment,e),_t=l(e),be=i(e,"P",{"data-svelte-h":!0}),f(be)!=="svelte-1mey86d"&&(be.innerHTML=Is),wt=l(e),Ie=i(e,"P",{"data-svelte-h":!0}),f(Ie)!=="svelte-yktcaa"&&(Ie.innerHTML=Js),bt=l(e),Je=i(e,"P",{"data-svelte-h":!0}),f(Je)!=="svelte-14bqt2g"&&(Je.innerHTML=vs),It=l(e),p(ve.$$.fragment,e),Jt=l(e),q=i(e,"DIV",{class:!0});var Et=N(q);p($e.$$.fragment,Et),Dt=l(Et),Se=i(Et,"P",{"data-svelte-h":!0}),f(Se)!=="svelte-1fspdqk"&&(Se.textContent=$s),Et.forEach(s),vt=l(e),p(je.$$.fragment,e),$t=l(e),p(Ue.$$.fragment,e),jt=l(e),p(ke.$$.fragment,e),Ut=l(e),V=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(V)!=="svelte-ivd2cr"&&(V.innerHTML=js),kt=l(e),j=i(e,"DIV",{class:!0});var S=N(j);p(Ce.$$.fragment,S),Yt=l(S),Xe=i(S,"P",{"data-svelte-h":!0}),f(Xe)!=="svelte-t9ku5w"&&(Xe.textContent=Us),Kt=l(S),xe=i(S,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(xe)!=="svelte-covr82"&&(xe.innerHTML=ks),es=l(S),p(z.$$.fragment,S),S.forEach(s),Ct=l(e),p(Ne.$$.fragment,e),xt=l(e),Re=i(e,"P",{}),N(Re).forEach(s),this.h()},h(){$(c,"name","hf:doc:metadata"),$(c,"content",zs),$(L,"class","tip"),$(le,"class","tip"),$(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(V,"class","tip"),$(xe,"class","tip"),$(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){m(document.head,c),n(e,I,t),n(e,y,t),n(e,T,t),g(_,e,t),n(e,a,t),g(w,e,t),n(e,He,t),n(e,H,t),n(e,Fe,t),g(F,e,t),n(e,Pe,t),n(e,P,t),n(e,Oe,t),n(e,O,t),n(e,Ge,t),n(e,G,t),n(e,De,t),n(e,D,t),n(e,Ye,t),g(Y,e,t),n(e,Ke,t),n(e,K,t),n(e,et,t),g(ee,e,t),n(e,tt,t),n(e,te,t),n(e,st,t),g(se,e,t),n(e,nt,t),g(ne,e,t),n(e,ot,t),n(e,L,t),n(e,lt,t),n(e,J,t),g(oe,J,null),m(J,Zt),m(J,qe),m(J,Wt),m(J,Ee),m(J,Bt),m(J,le),m(J,Qt),g(Z,J,null),n(e,at,t),g(ae,e,t),n(e,rt,t),n(e,re,t),n(e,it,t),g(ie,e,t),n(e,ct,t),g(ce,e,t),n(e,mt,t),n(e,b,t),g(me,b,null),m(b,Vt),m(b,Le),m(b,zt),m(b,Ze),m(b,St),m(b,We),m(b,Xt),g(W,b,null),m(b,Rt),m(b,B),g(de,B,null),m(B,Ht),m(B,Be),n(e,dt,t),g(pe,e,t),n(e,pt,t),n(e,ge,t),n(e,gt,t),g(ue,e,t),n(e,ut,t),n(e,C,t),g(Me,C,null),m(C,Ft),m(C,Qe),m(C,Pt),m(C,Q),g(he,Q,null),m(Q,Ot),m(Q,Ve),n(e,Mt,t),g(fe,e,t),n(e,ht,t),n(e,Te,t),n(e,ft,t),g(ye,e,t),n(e,Tt,t),n(e,A,t),g(_e,A,null),m(A,Gt),m(A,ze),n(e,yt,t),g(we,e,t),n(e,_t,t),n(e,be,t),n(e,wt,t),n(e,Ie,t),n(e,bt,t),n(e,Je,t),n(e,It,t),g(ve,e,t),n(e,Jt,t),n(e,q,t),g($e,q,null),m(q,Dt),m(q,Se),n(e,vt,t),g(je,e,t),n(e,$t,t),g(Ue,e,t),n(e,jt,t),g(ke,e,t),n(e,Ut,t),n(e,V,t),n(e,kt,t),n(e,j,t),g(Ce,j,null),m(j,Yt),m(j,Xe),m(j,Kt),m(j,xe),m(j,es),g(z,j,null),n(e,Ct,t),g(Ne,e,t),n(e,xt,t),n(e,Re,t),Nt=!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}),Z.$set(v);const Ae={};t&2&&(Ae.$$scope={dirty:t,ctx:e}),W.$set(Ae);const E={};t&2&&(E.$$scope={dirty:t,ctx:e}),z.$set(E)},i(e){Nt||(u(_.$$.fragment,e),u(w.$$.fragment,e),u(F.$$.fragment,e),u(Y.$$.fragment,e),u(ee.$$.fragment,e),u(se.$$.fragment,e),u(ne.$$.fragment,e),u(oe.$$.fragment,e),u(Z.$$.fragment,e),u(ae.$$.fragment,e),u(ie.$$.fragment,e),u(ce.$$.fragment,e),u(me.$$.fragment,e),u(W.$$.fragment,e),u(de.$$.fragment,e),u(pe.$$.fragment,e),u(ue.$$.fragment,e),u(Me.$$.fragment,e),u(he.$$.fragment,e),u(fe.$$.fragment,e),u(ye.$$.fragment,e),u(_e.$$.fragment,e),u(we.$$.fragment,e),u(ve.$$.fragment,e),u($e.$$.fragment,e),u(je.$$.fragment,e),u(Ue.$$.fragment,e),u(ke.$$.fragment,e),u(Ce.$$.fragment,e),u(z.$$.fragment,e),u(Ne.$$.fragment,e),Nt=!0)},o(e){M(_.$$.fragment,e),M(w.$$.fragment,e),M(F.$$.fragment,e),M(Y.$$.fragment,e),M(ee.$$.fragment,e),M(se.$$.fragment,e),M(ne.$$.fragment,e),M(oe.$$.fragment,e),M(Z.$$.fragment,e),M(ae.$$.fragment,e),M(ie.$$.fragment,e),M(ce.$$.fragment,e),M(me.$$.fragment,e),M(W.$$.fragment,e),M(de.$$.fragment,e),M(pe.$$.fragment,e),M(ue.$$.fragment,e),M(Me.$$.fragment,e),M(he.$$.fragment,e),M(fe.$$.fragment,e),M(ye.$$.fragment,e),M(_e.$$.fragment,e),M(we.$$.fragment,e),M(ve.$$.fragment,e),M($e.$$.fragment,e),M(je.$$.fragment,e),M(Ue.$$.fragment,e),M(ke.$$.fragment,e),M(Ce.$$.fragment,e),M(z.$$.fragment,e),M(Ne.$$.fragment,e),Nt=!1},d(e){e&&(s(I),s(y),s(T),s(a),s(He),s(H),s(Fe),s(Pe),s(P),s(Oe),s(O),s(Ge),s(G),s(De),s(D),s(Ye),s(Ke),s(K),s(et),s(tt),s(te),s(st),s(nt),s(ot),s(L),s(lt),s(J),s(at),s(rt),s(re),s(it),s(ct),s(mt),s(b),s(dt),s(pt),s(ge),s(gt),s(ut),s(C),s(Mt),s(ht),s(Te),s(ft),s(Tt),s(A),s(yt),s(_t),s(be),s(wt),s(Ie),s(bt),s(Je),s(It),s(Jt),s(q),s(vt),s($t),s(jt),s(Ut),s(V),s(kt),s(j),s(Ct),s(xt),s(Re)),s(c),h(_,e),h(w,e),h(F,e),h(Y,e),h(ee,e),h(se,e),h(ne,e),h(oe),h(Z),h(ae,e),h(ie,e),h(ce,e),h(me),h(W),h(de),h(pe,e),h(ue,e),h(Me),h(he),h(fe,e),h(ye,e),h(_e),h(we,e),h(ve,e),h($e),h(je,e),h(Ue,e),h(ke,e),h(Ce),h(z),h(Ne,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(x){return xs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Os extends Ns{constructor(c){super(),As(this,c,Ss,Vs,Cs,{})}}export{Os as component};
