import{s as Ns,o as As,n as Wt}from"../chunks/scheduler.00b97157.js";import{S as qs,i as Es,e as r,s as o,c as m,h as Ls,a as i,d as s,b as l,f as N,g as d,j as f,k as $,l as h,m as n,n as p,t as g,o as u,p as M}from"../chunks/index.a7c1a7a1.js";import{T as Zs,D as R,E as ns}from"../chunks/ExampleCodeBlock.3e50e595.js";import{C as Ws,H,E as Bs}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4292aef9.js";import{C as k}from"../chunks/CodeBlock.afb4ac0c.js";function Qs(C){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:Wt,d(y){y&&s(c)}}}function Vs(C){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(),m(T.$$.fragment)},l(a){c=i(a,"P",{"data-svelte-h":!0}),f(c)!=="svelte-11lpom8"&&(c.textContent=I),y=l(a),d(T.$$.fragment,a)},m(a,w){n(a,c,w),n(a,y,w),p(T,a,w),_=!0},p:Wt,i(a){_||(g(T.$$.fragment,a),_=!0)},o(a){u(T.$$.fragment,a),_=!1},d(a){a&&(s(c),s(y)),M(T,a)}}}function zs(C){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(),m(T.$$.fragment)},l(a){c=i(a,"P",{"data-svelte-h":!0}),f(c)!=="svelte-11lpom8"&&(c.textContent=I),y=l(a),d(T.$$.fragment,a)},m(a,w){n(a,c,w),n(a,y,w),p(T,a,w),_=!0},p:Wt,i(a){_||(g(T.$$.fragment,a),_=!0)},o(a){u(T.$$.fragment,a),_=!1},d(a){a&&(s(c),s(y)),M(T,a)}}}function Ss(C){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(),m(T.$$.fragment)},l(a){c=i(a,"P",{"data-svelte-h":!0}),f(c)!=="svelte-11lpom8"&&(c.textContent=I),y=l(a),d(T.$$.fragment,a)},m(a,w){n(a,c,w),n(a,y,w),p(T,a,w),_=!0},p:Wt,i(a){_||(g(T.$$.fragment,a),_=!0)},o(a){u(T.$$.fragment,a),_=!1},d(a){a&&(s(c),s(y)),M(T,a)}}}function Xs(C){let c,I,y,T,_,a,w,Fe,L,Pe,F,os='要了解有关智能体和工具的更多信息，请务必阅读<a href="../index">入门指南</a>。此页面包含底层类的 API 文档。',Oe,P,Ge,O,ls="您可以自由创建和使用自己的模型为智能体提供支持。",De,G,as="您可以使用任何 <code>model</code> 可调用对象作为智能体的模型，只要满足以下条件：",Ye,D,rs='<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>',Ke,Y,is='要定义您的 LLM，可以创建一个 <code>custom_model</code> 方法，该方法接受一个 <a href="./chat_templating">messages</a> 列表，并返回一个包含 <code>.content</code> 属性的对象，其中包含生成的文本。此可调用对象还需要接受一个 <code>stop_sequences</code> 参数，用于指示何时停止生成。',et,K,tt,ee,cs='此外，<code>custom_model</code> 还可以接受一个 <code>grammar</code> 参数。如果在智能体初始化时指定了 <code>grammar</code>，则此参数将在调用模型时传递，以便进行<a href="https://huggingface.co/docs/text-generation-inference/conceptual/guidance" rel="nofollow">约束生成</a>，从而强制生成格式正确的智能体输出。',st,te,nt,se,ms="为了方便起见，我们添加了一个 <code>TransformersModel</code>，该模型通过为初始化时指定的 <code>model_id</code> 构建一个本地 <code>transformers</code> pipeline 来实现上述功能。",ot,ne,lt,oe,at,Z,ds="<p>您必须在机器上安装 <code>transformers</code> 和 <code>torch</code>。如果尚未安装，请运行 <code>pip install &#39;smolagents[transformers]&#39;</code>。</p>",rt,J,le,Bt,Ee,ps="A class that uses Hugging Face’s Transformers library for language model interaction.",Qt,Le,gs="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,ae,us="<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>",zt,W,it,re,ct,ie,Ms='<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>。',mt,ce,dt,me,pt,b,de,St,Ze,hs="A class to interact with Hugging Face’s Inference Providers for language model interaction.",Xt,We,fs="This model allows you to communicate with Hugging Face’s models using Inference Providers. It can be used in both serverless mode, with a dedicated endpoint, or even with a local URL, supporting features like stop sequences and grammar customization.",Rt,Be,Ts="Providers include Cerebras, Cohere, Fal, Fireworks, HF-Inference, Hyperbolic, Nebius, Novita, Replicate, SambaNova, Together, and more.",Ht,B,Ft,Q,pe,Pt,Qe,ys="Create the Hugging Face client.",gt,ge,ut,ue,_s='<code>LiteLLMModel</code> 利用 <a href="https://www.litellm.ai/" rel="nofollow">LiteLLM</a> 支持来自不同提供商的 100+ 个 LLM。您可以在模型初始化时传递 <code>kwargs</code>，这些参数将在每次使用模型时被使用，例如下面的示例中传递了 <code>temperature</code>。',Mt,Me,ht,x,he,Ot,Ve,ws='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,V,fe,Dt,ze,bs="Create the LiteLLM client.",ft,Te,Tt,ye,Is=`此类允许您调用任何 OpenAIServer 兼容模型。
以下是设置方法（您可以自定义 <code>api_base</code> URL 指向其他服务器）：`,yt,_e,_t,A,we,Yt,Se,Js="This model connects to an OpenAI-compatible API server.",wt,be,bt,Ie,vs="<code>AzureOpenAIServerModel</code> 允许您连接到任何 Azure OpenAI 部署。",It,Je,$s="下面是设置示例，请注意，如果已经设置了相应的环境变量，您可以省略 <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,js='请注意，<code>OPENAI_API_VERSION</code> 没有 <code>AZURE_</code> 前缀，这是由于底层 <a href="https://github.com/openai/openai-python" rel="nofollow">openai</a> 包的设计所致。',vt,$e,$t,q,je,Kt,Xe,Us="This model connects to an Azure OpenAI deployment.",jt,Ue,Ut,ke,kt,xe,xt,z,ks="<p>您必须在机器上安装 <code>mlx-lm</code>。如果尚未安装，请运行 <code>pip install &#39;smolagents[mlx-lm]&#39;</code>。</p>",Ct,j,Ce,es,Re,xs="A class to interact with models loaded using MLX on Apple silicon.",ts,Ne,Cs="<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>",ss,S,Nt,Ae,At,He,qt;return _=new Ws({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new H({props:{title:"模型",local:"模型",headingTag:"h1"}}),L=new Zs({props:{warning:!0,$$slots:{default:[Qs]},$$scope:{ctx:C}}}),P=new H({props:{title:"模型",local:"模型",headingTag:"h2"}}),K=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}}),te=new H({props:{title:"TransformersModel",local:"smolagents.TransformersModel",headingTag:"h3"}}),ne=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}}),oe=new k({props:{code:"V2hhdCUyMGE=",highlighted:"&gt;&gt;&gt; What a",wrap:!1}}),le=new R({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/v1.22.0/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 ns({props:{anchor:"smolagents.TransformersModel.example",$$slots:{default:[Vs]},$$scope:{ctx:C}}}),re=new H({props:{title:"InferenceClientModel",local:"smolagents.InferenceClientModel",headingTag:"h3"}}),ce=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}}),me=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}}),de=new R({props:{name:"class smolagents.InferenceClientModel",anchor:"smolagents.InferenceClientModel",parameters:[{name:"model_id",val:": str = 'Qwen/Qwen2.5-Coder-32B-Instruct'"},{name:"provider",val:": str | None = None"},{name:"token",val:": str | None = None"},{name:"timeout",val:": int = 120"},{name:"client_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"custom_role_conversions",val:": dict[str, str] | None = None"},{name:"api_key",val:": str | None = None"},{name:"bill_to",val:": str | None = None"},{name:"base_url",val:": str | None = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"smolagents.InferenceClientModel.model_id",description:`<strong>model_id</strong> (<code>str</code>, <em>optional</em>, default <code>&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</code>) &#x2014;
The Hugging Face model ID to be used for inference.
This can be a model identifier from the Hugging Face model hub or a URL to a deployed Inference Endpoint.
Currently, it defaults to <code>&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</code>, but this may change in the future.`,name:"model_id"},{anchor:"smolagents.InferenceClientModel.provider",description:`<strong>provider</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Name of the provider to use for inference. A list of supported providers can be found in the <a href="https://huggingface.co/docs/inference-providers/index#partners" rel="nofollow">Inference Providers documentation</a>.
Defaults to &#x201C;auto&#x201D; i.e. the first of the providers available for the model, sorted by the user&#x2019;s order <a href="https://hf.co/settings/inference-providers" rel="nofollow">here</a>.
If <code>base_url</code> is passed, then <code>provider</code> is not used.`,name:"provider"},{anchor:"smolagents.InferenceClientModel.token",description:`<strong>token</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Token used by the Hugging Face API for authentication. This token need to be authorized &#x2018;Make calls to the serverless Inference Providers&#x2019;.
If the model is gated (like Llama-3 models), the token also needs &#x2018;Read access to contents of all public gated repos you can access&#x2019;.
If not provided, the class will try to use environment variable &#x2018;HF_TOKEN&#x2019;, else use the token stored in the Hugging Face CLI configuration.`,name:"token"},{anchor:"smolagents.InferenceClientModel.timeout",description:`<strong>timeout</strong> (<code>int</code>, <em>optional</em>, defaults to 120) &#x2014;
Timeout for the API request, in seconds.`,name:"timeout"},{anchor:"smolagents.InferenceClientModel.client_kwargs",description:`<strong>client_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional keyword arguments to pass to the Hugging Face InferenceClient.`,name:"client_kwargs"},{anchor:"smolagents.InferenceClientModel.custom_role_conversions",description:`<strong>custom_role_conversions</strong> (<code>dict[str, str]</code>, <em>optional</em>) &#x2014;
Custom role conversion mapping to convert message roles in others.
Useful for specific models that do not support specific message roles like &#x201C;system&#x201D;.`,name:"custom_role_conversions"},{anchor:"smolagents.InferenceClientModel.api_key",description:`<strong>api_key</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Token to use for authentication. This is a duplicated argument from <code>token</code> to make <a href="/docs/smolagents/v1.22.0/zh/reference/models#smolagents.InferenceClientModel">InferenceClientModel</a>
follow the same pattern as <code>openai.OpenAI</code> client. Cannot be used if <code>token</code> is set. Defaults to None.`,name:"api_key"},{anchor:"smolagents.InferenceClientModel.bill_to",description:`<strong>bill_to</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The billing account to use for the requests. By default the requests are billed on the user&#x2019;s account. Requests can only be billed to
an organization the user is a member of, and which has subscribed to Enterprise Hub.`,name:"bill_to"},{anchor:"smolagents.InferenceClientModel.base_url",description:`<strong>base_url</strong> (<code>str</code>, <code>optional</code>) &#x2014;
Base URL to run inference. This is a duplicated argument from <code>model</code> to make <a href="/docs/smolagents/v1.22.0/zh/reference/models#smolagents.InferenceClientModel">InferenceClientModel</a>
follow the same pattern as <code>openai.OpenAI</code> client. Cannot be used if <code>model</code> is set. Defaults to None.`,name:"base_url"},{anchor:"smolagents.InferenceClientModel.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments to forward to the underlying Hugging Face InferenceClient completion call.`,name:"*kwargs"}],source:"https://github.com/huggingface/smolagents/blob/v1.22.0/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>
`}}),B=new ns({props:{anchor:"smolagents.InferenceClientModel.example",$$slots:{default:[zs]},$$scope:{ctx:C}}}),pe=new R({props:{name:"create_client",anchor:"smolagents.InferenceClientModel.create_client",parameters:[],source:"https://github.com/huggingface/smolagents/blob/v1.22.0/src/smolagents/models.py#L1432"}}),ge=new H({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 R({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/v1.22.0/src/smolagents/models.py#L1098"}}),fe=new R({props:{name:"create_client",anchor:"smolagents.LiteLLMModel.create_client",parameters:[],source:"https://github.com/huggingface/smolagents/blob/v1.22.0/src/smolagents/models.py#L1148"}}),Te=new H({props:{title:"OpenAIServerModel",local:"smolagents.OpenAIServerModel",headingTag:"h3"}}),_e=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}}),we=new R({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/v1.22.0/src/smolagents/models.py#L1523"}}),be=new H({props:{title:"AzureOpenAIServerModel",local:"smolagents.AzureOpenAIServerModel",headingTag:"h3"}}),$e=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}}),je=new R({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/v1.22.0/src/smolagents/models.py#L1668"}}),Ue=new H({props:{title:"MLXModel",local:"smolagents.MLXModel",headingTag:"h3"}}),ke=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}}),Ce=new R({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/v1.22.0/src/smolagents/models.py#L675"}}),S=new ns({props:{anchor:"smolagents.MLXModel.example",$$slots:{default:[Ss]},$$scope:{ctx:C}}}),Ae=new Bs({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(),m(_.$$.fragment),a=o(),m(w.$$.fragment),Fe=o(),m(L.$$.fragment),Pe=o(),F=r("p"),F.innerHTML=os,Oe=o(),m(P.$$.fragment),Ge=o(),O=r("p"),O.textContent=ls,De=o(),G=r("p"),G.innerHTML=as,Ye=o(),D=r("ol"),D.innerHTML=rs,Ke=o(),Y=r("p"),Y.innerHTML=is,et=o(),m(K.$$.fragment),tt=o(),ee=r("p"),ee.innerHTML=cs,st=o(),m(te.$$.fragment),nt=o(),se=r("p"),se.innerHTML=ms,ot=o(),m(ne.$$.fragment),lt=o(),m(oe.$$.fragment),at=o(),Z=r("blockquote"),Z.innerHTML=ds,rt=o(),J=r("div"),m(le.$$.fragment),Bt=o(),Ee=r("p"),Ee.textContent=ps,Qt=o(),Le=r("p"),Le.textContent=gs,Vt=o(),ae=r("blockquote"),ae.innerHTML=us,zt=o(),m(W.$$.fragment),it=o(),m(re.$$.fragment),ct=o(),ie=r("p"),ie.innerHTML=Ms,mt=o(),m(ce.$$.fragment),dt=o(),m(me.$$.fragment),pt=o(),b=r("div"),m(de.$$.fragment),St=o(),Ze=r("p"),Ze.textContent=hs,Xt=o(),We=r("p"),We.textContent=fs,Rt=o(),Be=r("p"),Be.textContent=Ts,Ht=o(),m(B.$$.fragment),Ft=o(),Q=r("div"),m(pe.$$.fragment),Pt=o(),Qe=r("p"),Qe.textContent=ys,gt=o(),m(ge.$$.fragment),ut=o(),ue=r("p"),ue.innerHTML=_s,Mt=o(),m(Me.$$.fragment),ht=o(),x=r("div"),m(he.$$.fragment),Ot=o(),Ve=r("p"),Ve.innerHTML=ws,Gt=o(),V=r("div"),m(fe.$$.fragment),Dt=o(),ze=r("p"),ze.textContent=bs,ft=o(),m(Te.$$.fragment),Tt=o(),ye=r("p"),ye.innerHTML=Is,yt=o(),m(_e.$$.fragment),_t=o(),A=r("div"),m(we.$$.fragment),Yt=o(),Se=r("p"),Se.textContent=Js,wt=o(),m(be.$$.fragment),bt=o(),Ie=r("p"),Ie.innerHTML=vs,It=o(),Je=r("p"),Je.innerHTML=$s,Jt=o(),ve=r("p"),ve.innerHTML=js,vt=o(),m($e.$$.fragment),$t=o(),q=r("div"),m(je.$$.fragment),Kt=o(),Xe=r("p"),Xe.textContent=Us,jt=o(),m(Ue.$$.fragment),Ut=o(),m(ke.$$.fragment),kt=o(),m(xe.$$.fragment),xt=o(),z=r("blockquote"),z.innerHTML=ks,Ct=o(),j=r("div"),m(Ce.$$.fragment),es=o(),Re=r("p"),Re.textContent=xs,ts=o(),Ne=r("blockquote"),Ne.innerHTML=Cs,ss=o(),m(S.$$.fragment),Nt=o(),m(Ae.$$.fragment),At=o(),He=r("p"),this.h()},l(e){const t=Ls("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),d(_.$$.fragment,e),a=l(e),d(w.$$.fragment,e),Fe=l(e),d(L.$$.fragment,e),Pe=l(e),F=i(e,"P",{"data-svelte-h":!0}),f(F)!=="svelte-11nub39"&&(F.innerHTML=os),Oe=l(e),d(P.$$.fragment,e),Ge=l(e),O=i(e,"P",{"data-svelte-h":!0}),f(O)!=="svelte-15ti981"&&(O.textContent=ls),De=l(e),G=i(e,"P",{"data-svelte-h":!0}),f(G)!=="svelte-y6kvhr"&&(G.innerHTML=as),Ye=l(e),D=i(e,"OL",{"data-svelte-h":!0}),f(D)!=="svelte-14peu6x"&&(D.innerHTML=rs),Ke=l(e),Y=i(e,"P",{"data-svelte-h":!0}),f(Y)!=="svelte-mamej0"&&(Y.innerHTML=is),et=l(e),d(K.$$.fragment,e),tt=l(e),ee=i(e,"P",{"data-svelte-h":!0}),f(ee)!=="svelte-c0mv9r"&&(ee.innerHTML=cs),st=l(e),d(te.$$.fragment,e),nt=l(e),se=i(e,"P",{"data-svelte-h":!0}),f(se)!=="svelte-tirv5b"&&(se.innerHTML=ms),ot=l(e),d(ne.$$.fragment,e),lt=l(e),d(oe.$$.fragment,e),at=l(e),Z=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(Z)!=="svelte-ouuan6"&&(Z.innerHTML=ds),rt=l(e),J=i(e,"DIV",{class:!0});var U=N(J);d(le.$$.fragment,U),Bt=l(U),Ee=i(U,"P",{"data-svelte-h":!0}),f(Ee)!=="svelte-1ex1ahr"&&(Ee.textContent=ps),Qt=l(U),Le=i(U,"P",{"data-svelte-h":!0}),f(Le)!=="svelte-1140acn"&&(Le.textContent=gs),Vt=l(U),ae=i(U,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(ae)!=="svelte-103z9yw"&&(ae.innerHTML=us),zt=l(U),d(W.$$.fragment,U),U.forEach(s),it=l(e),d(re.$$.fragment,e),ct=l(e),ie=i(e,"P",{"data-svelte-h":!0}),f(ie)!=="svelte-dz1cyo"&&(ie.innerHTML=Ms),mt=l(e),d(ce.$$.fragment,e),dt=l(e),d(me.$$.fragment,e),pt=l(e),b=i(e,"DIV",{class:!0});var v=N(b);d(de.$$.fragment,v),St=l(v),Ze=i(v,"P",{"data-svelte-h":!0}),f(Ze)!=="svelte-axkcn3"&&(Ze.textContent=hs),Xt=l(v),We=i(v,"P",{"data-svelte-h":!0}),f(We)!=="svelte-bducrc"&&(We.textContent=fs),Rt=l(v),Be=i(v,"P",{"data-svelte-h":!0}),f(Be)!=="svelte-12eu297"&&(Be.textContent=Ts),Ht=l(v),d(B.$$.fragment,v),Ft=l(v),Q=i(v,"DIV",{class:!0});var qe=N(Q);d(pe.$$.fragment,qe),Pt=l(qe),Qe=i(qe,"P",{"data-svelte-h":!0}),f(Qe)!=="svelte-ym2f5u"&&(Qe.textContent=ys),qe.forEach(s),v.forEach(s),gt=l(e),d(ge.$$.fragment,e),ut=l(e),ue=i(e,"P",{"data-svelte-h":!0}),f(ue)!=="svelte-131mixa"&&(ue.innerHTML=_s),Mt=l(e),d(Me.$$.fragment,e),ht=l(e),x=i(e,"DIV",{class:!0});var E=N(x);d(he.$$.fragment,E),Ot=l(E),Ve=i(E,"P",{"data-svelte-h":!0}),f(Ve)!=="svelte-5g97zk"&&(Ve.innerHTML=ws),Gt=l(E),V=i(E,"DIV",{class:!0});var Et=N(V);d(fe.$$.fragment,Et),Dt=l(Et),ze=i(Et,"P",{"data-svelte-h":!0}),f(ze)!=="svelte-12r14rd"&&(ze.textContent=bs),Et.forEach(s),E.forEach(s),ft=l(e),d(Te.$$.fragment,e),Tt=l(e),ye=i(e,"P",{"data-svelte-h":!0}),f(ye)!=="svelte-k9txw"&&(ye.innerHTML=Is),yt=l(e),d(_e.$$.fragment,e),_t=l(e),A=i(e,"DIV",{class:!0});var Lt=N(A);d(we.$$.fragment,Lt),Yt=l(Lt),Se=i(Lt,"P",{"data-svelte-h":!0}),f(Se)!=="svelte-1bc1pfc"&&(Se.textContent=Js),Lt.forEach(s),wt=l(e),d(be.$$.fragment,e),bt=l(e),Ie=i(e,"P",{"data-svelte-h":!0}),f(Ie)!=="svelte-1mey86d"&&(Ie.innerHTML=vs),It=l(e),Je=i(e,"P",{"data-svelte-h":!0}),f(Je)!=="svelte-yktcaa"&&(Je.innerHTML=$s),Jt=l(e),ve=i(e,"P",{"data-svelte-h":!0}),f(ve)!=="svelte-14bqt2g"&&(ve.innerHTML=js),vt=l(e),d($e.$$.fragment,e),$t=l(e),q=i(e,"DIV",{class:!0});var Zt=N(q);d(je.$$.fragment,Zt),Kt=l(Zt),Xe=i(Zt,"P",{"data-svelte-h":!0}),f(Xe)!=="svelte-1fspdqk"&&(Xe.textContent=Us),Zt.forEach(s),jt=l(e),d(Ue.$$.fragment,e),Ut=l(e),d(ke.$$.fragment,e),kt=l(e),d(xe.$$.fragment,e),xt=l(e),z=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(z)!=="svelte-ivd2cr"&&(z.innerHTML=ks),Ct=l(e),j=i(e,"DIV",{class:!0});var X=N(j);d(Ce.$$.fragment,X),es=l(X),Re=i(X,"P",{"data-svelte-h":!0}),f(Re)!=="svelte-t9ku5w"&&(Re.textContent=xs),ts=l(X),Ne=i(X,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(Ne)!=="svelte-covr82"&&(Ne.innerHTML=Cs),ss=l(X),d(S.$$.fragment,X),X.forEach(s),Nt=l(e),d(Ae.$$.fragment,e),At=l(e),He=i(e,"P",{}),N(He).forEach(s),this.h()},h(){$(c,"name","hf:doc:metadata"),$(c,"content",Rs),$(Z,"class","tip"),$(ae,"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"),$(Q,"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"),$(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(x,"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"),$(z,"class","tip"),$(Ne,"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){h(document.head,c),n(e,I,t),n(e,y,t),n(e,T,t),p(_,e,t),n(e,a,t),p(w,e,t),n(e,Fe,t),p(L,e,t),n(e,Pe,t),n(e,F,t),n(e,Oe,t),p(P,e,t),n(e,Ge,t),n(e,O,t),n(e,De,t),n(e,G,t),n(e,Ye,t),n(e,D,t),n(e,Ke,t),n(e,Y,t),n(e,et,t),p(K,e,t),n(e,tt,t),n(e,ee,t),n(e,st,t),p(te,e,t),n(e,nt,t),n(e,se,t),n(e,ot,t),p(ne,e,t),n(e,lt,t),p(oe,e,t),n(e,at,t),n(e,Z,t),n(e,rt,t),n(e,J,t),p(le,J,null),h(J,Bt),h(J,Ee),h(J,Qt),h(J,Le),h(J,Vt),h(J,ae),h(J,zt),p(W,J,null),n(e,it,t),p(re,e,t),n(e,ct,t),n(e,ie,t),n(e,mt,t),p(ce,e,t),n(e,dt,t),p(me,e,t),n(e,pt,t),n(e,b,t),p(de,b,null),h(b,St),h(b,Ze),h(b,Xt),h(b,We),h(b,Rt),h(b,Be),h(b,Ht),p(B,b,null),h(b,Ft),h(b,Q),p(pe,Q,null),h(Q,Pt),h(Q,Qe),n(e,gt,t),p(ge,e,t),n(e,ut,t),n(e,ue,t),n(e,Mt,t),p(Me,e,t),n(e,ht,t),n(e,x,t),p(he,x,null),h(x,Ot),h(x,Ve),h(x,Gt),h(x,V),p(fe,V,null),h(V,Dt),h(V,ze),n(e,ft,t),p(Te,e,t),n(e,Tt,t),n(e,ye,t),n(e,yt,t),p(_e,e,t),n(e,_t,t),n(e,A,t),p(we,A,null),h(A,Yt),h(A,Se),n(e,wt,t),p(be,e,t),n(e,bt,t),n(e,Ie,t),n(e,It,t),n(e,Je,t),n(e,Jt,t),n(e,ve,t),n(e,vt,t),p($e,e,t),n(e,$t,t),n(e,q,t),p(je,q,null),h(q,Kt),h(q,Xe),n(e,jt,t),p(Ue,e,t),n(e,Ut,t),p(ke,e,t),n(e,kt,t),p(xe,e,t),n(e,xt,t),n(e,z,t),n(e,Ct,t),n(e,j,t),p(Ce,j,null),h(j,es),h(j,Re),h(j,ts),h(j,Ne),h(j,ss),p(S,j,null),n(e,Nt,t),p(Ae,e,t),n(e,At,t),n(e,He,t),qt=!0},p(e,[t]){const U={};t&2&&(U.$$scope={dirty:t,ctx:e}),L.$set(U);const v={};t&2&&(v.$$scope={dirty:t,ctx:e}),W.$set(v);const qe={};t&2&&(qe.$$scope={dirty:t,ctx:e}),B.$set(qe);const E={};t&2&&(E.$$scope={dirty:t,ctx:e}),S.$set(E)},i(e){qt||(g(_.$$.fragment,e),g(w.$$.fragment,e),g(L.$$.fragment,e),g(P.$$.fragment,e),g(K.$$.fragment,e),g(te.$$.fragment,e),g(ne.$$.fragment,e),g(oe.$$.fragment,e),g(le.$$.fragment,e),g(W.$$.fragment,e),g(re.$$.fragment,e),g(ce.$$.fragment,e),g(me.$$.fragment,e),g(de.$$.fragment,e),g(B.$$.fragment,e),g(pe.$$.fragment,e),g(ge.$$.fragment,e),g(Me.$$.fragment,e),g(he.$$.fragment,e),g(fe.$$.fragment,e),g(Te.$$.fragment,e),g(_e.$$.fragment,e),g(we.$$.fragment,e),g(be.$$.fragment,e),g($e.$$.fragment,e),g(je.$$.fragment,e),g(Ue.$$.fragment,e),g(ke.$$.fragment,e),g(xe.$$.fragment,e),g(Ce.$$.fragment,e),g(S.$$.fragment,e),g(Ae.$$.fragment,e),qt=!0)},o(e){u(_.$$.fragment,e),u(w.$$.fragment,e),u(L.$$.fragment,e),u(P.$$.fragment,e),u(K.$$.fragment,e),u(te.$$.fragment,e),u(ne.$$.fragment,e),u(oe.$$.fragment,e),u(le.$$.fragment,e),u(W.$$.fragment,e),u(re.$$.fragment,e),u(ce.$$.fragment,e),u(me.$$.fragment,e),u(de.$$.fragment,e),u(B.$$.fragment,e),u(pe.$$.fragment,e),u(ge.$$.fragment,e),u(Me.$$.fragment,e),u(he.$$.fragment,e),u(fe.$$.fragment,e),u(Te.$$.fragment,e),u(_e.$$.fragment,e),u(we.$$.fragment,e),u(be.$$.fragment,e),u($e.$$.fragment,e),u(je.$$.fragment,e),u(Ue.$$.fragment,e),u(ke.$$.fragment,e),u(xe.$$.fragment,e),u(Ce.$$.fragment,e),u(S.$$.fragment,e),u(Ae.$$.fragment,e),qt=!1},d(e){e&&(s(I),s(y),s(T),s(a),s(Fe),s(Pe),s(F),s(Oe),s(Ge),s(O),s(De),s(G),s(Ye),s(D),s(Ke),s(Y),s(et),s(tt),s(ee),s(st),s(nt),s(se),s(ot),s(lt),s(at),s(Z),s(rt),s(J),s(it),s(ct),s(ie),s(mt),s(dt),s(pt),s(b),s(gt),s(ut),s(ue),s(Mt),s(ht),s(x),s(ft),s(Tt),s(ye),s(yt),s(_t),s(A),s(wt),s(bt),s(Ie),s(It),s(Je),s(Jt),s(ve),s(vt),s($t),s(q),s(jt),s(Ut),s(kt),s(xt),s(z),s(Ct),s(j),s(Nt),s(At),s(He)),s(c),M(_,e),M(w,e),M(L,e),M(P,e),M(K,e),M(te,e),M(ne,e),M(oe,e),M(le),M(W),M(re,e),M(ce,e),M(me,e),M(de),M(B),M(pe),M(ge,e),M(Me,e),M(he),M(fe),M(Te,e),M(_e,e),M(we),M(be,e),M($e,e),M(je),M(Ue,e),M(ke,e),M(xe,e),M(Ce),M(S),M(Ae,e)}}}const Rs='{"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 Hs(C){return As(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ys extends qs{constructor(c){super(),Es(this,c,Hs,Xs,Ns,{})}}export{Ys as component};
