import{s as rs,o as hs,n as Gl}from"../chunks/scheduler.ddeee2a5.js";import{S as ms,i as Cs,e as y,s as o,c as u,h as ds,a as c,d as s,b as i,f as Is,g as I,j as p,k as B,l as fs,m as e,n as r,t as h,o as m,p as C}from"../chunks/index.10b70568.js";import{C as bs}from"../chunks/CopyLLMTxtMenu.48a5d8e9.js";import{C as b}from"../chunks/CodeBlock.7ca4c11d.js";import{H as g,E as As}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.c3713d0b.js";import{H as Qt,a as $l}from"../chunks/HfOption.1e773499.js";function gs(f){let n,j="In the OpenAI client, we’ll use the <code>base_url</code> parameter to specify the provider we want to use for the request.",J,T,a;return T=new b({props:{code:"aW1wb3J0JTIwanNvbiUwQWltcG9ydCUyMG9zJTBBJTBBZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjBjbGllbnQlMEFjbGllbnQlMjAlM0QlMjBPcGVuQUkoJTBBJTIwJTIwJTIwJTIwYmFzZV91cmwlM0QlMjJodHRwcyUzQSUyRiUyRnJvdXRlci5odWdnaW5nZmFjZS5jbyUyRnYxJTIyJTJDJTBBJTIwJTIwJTIwJTIwYXBpX2tleSUzRG9zLmVudmlyb24lNUIlMjJIRl9UT0tFTiUyMiU1RCUyQyUwQSk=",highlighted:`<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> os

<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

<span class="hljs-comment"># Initialize client</span>
client = OpenAI(
    base_url=<span class="hljs-string">&quot;https://router.huggingface.co/v1&quot;</span>,
    api_key=os.environ[<span class="hljs-string">&quot;HF_TOKEN&quot;</span>],
)`,wrap:!1}}),{c(){n=y("p"),n.innerHTML=j,J=o(),u(T.$$.fragment)},l(M){n=c(M,"P",{"data-svelte-h":!0}),p(n)!=="svelte-1kzamp0"&&(n.innerHTML=j),J=i(M),I(T.$$.fragment,M)},m(M,d){e(M,n,d),e(M,J,d),r(T,M,d),a=!0},p:Gl,i(M){a||(h(T.$$.fragment,M),a=!0)},o(M){m(T.$$.fragment,M),a=!1},d(M){M&&(s(n),s(J)),C(T,M)}}}function Bs(f){let n,j="In the Hugging Face Hub client, we’ll use the <code>provider</code> parameter to specify the provider we want to use for the request. By default, it is <code>&quot;auto&quot;</code>.",J,T,a;return T=new b({props:{code:"aW1wb3J0JTIwanNvbiUwQWltcG9ydCUyMG9zJTBBJTBBZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjBjbGllbnQlMEFjbGllbnQlMjAlM0QlMjBJbmZlcmVuY2VDbGllbnQodG9rZW4lM0Rvcy5lbnZpcm9uJTVCJTIySEZfVE9LRU4lMjIlNUQlMkMlMjBwcm92aWRlciUzRCUyMm5lYml1cyUyMik=",highlighted:`<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> os

<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

<span class="hljs-comment"># Initialize client</span>
client = InferenceClient(token=os.environ[<span class="hljs-string">&quot;HF_TOKEN&quot;</span>], provider=<span class="hljs-string">&quot;nebius&quot;</span>)`,wrap:!1}}),{c(){n=y("p"),n.innerHTML=j,J=o(),u(T.$$.fragment)},l(M){n=c(M,"P",{"data-svelte-h":!0}),p(n)!=="svelte-fearg4"&&(n.innerHTML=j),J=i(M),I(T.$$.fragment,M)},m(M,d){e(M,n,d),e(M,J,d),r(T,M,d),a=!0},p:Gl,i(M){a||(h(T.$$.fragment,M),a=!0)},o(M){m(T.$$.fragment,M),a=!1},d(M){M&&(s(n),s(J)),C(T,M)}}}function qs(f){let n,j,J,T;return n=new $l({props:{id:"define-functions",option:"openai",$$slots:{default:[gs]},$$scope:{ctx:f}}}),J=new $l({props:{id:"define-functions",option:"huggingface_hub",$$slots:{default:[Bs]},$$scope:{ctx:f}}}),{c(){u(n.$$.fragment),j=o(),u(J.$$.fragment)},l(a){I(n.$$.fragment,a),j=i(a),I(J.$$.fragment,a)},m(a,M){r(n,a,M),e(a,j,M),r(J,a,M),T=!0},p(a,M){const d={};M&2&&(d.$$scope={dirty:M,ctx:a}),n.$set(d);const w={};M&2&&(w.$$scope={dirty:M,ctx:a}),J.$set(w)},i(a){T||(h(n.$$.fragment,a),h(J.$$.fragment,a),T=!0)},o(a){m(n.$$.fragment,a),m(J.$$.fragment,a),T=!1},d(a){a&&s(j),C(n,a),C(J,a)}}}function Zs(f){let n,j;return n=new b({props:{code:"JTIzJTIwVGhlJTIwT3BlbkFJJTIwY2xpZW50JTIwYXV0b21hdGljYWxseSUyMHJvdXRlcyUyMHRocm91Z2glMjBJbmZlcmVuY2UlMjBQcm92aWRlcnMlMEElMjMlMjBZb3UlMjBjYW4lMjBzcGVjaWZ5JTIwcHJvdmlkZXIlMjBwcmVmZXJlbmNlcyUyMGluJTIweW91ciUyMEhGJTIwc2V0dGluZ3MlMEFjbGllbnQlMjAlM0QlMjBPcGVuQUkoJTBBJTIwJTIwJTIwJTIwYmFzZV91cmwlM0QlMjJodHRwcyUzQSUyRiUyRnJvdXRlci5odWdnaW5nZmFjZS5jbyUyRnYxJTIyJTJDJTBBJTIwJTIwJTIwJTIwYXBpX2tleSUzRG9zLmVudmlyb24lNUIlMjJIRl9UT0tFTiUyMiU1RCUyQyUwQSklMEElMEFjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBLSUyMCUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyZGVlcHNlZWstYWklMkZEZWVwU2Vlay1SMS0wNTI4JTIyJTJDJTIwJTIzJTIwYXV0b21hdGljYWxseSUyMHNlbGVjdCUyMHByb3ZpZGVyJTIwYmFzZWQlMjBvbiUyMGhmLmNvJTJGc2V0dGluZ3MlMkZpbmZlcmVuY2UtcHJvdmlkZXJzJTBBJTJCJTIwJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJkZWVwc2Vlay1haSUyRkRlZXBTZWVrLVIxLTA1MjglM0FuZWJpdXMlMjIlMkMlMjAlMjMlMjBtYW51YWxseSUyMHNlbGVjdCUyME5lYml1cyUyMEFJJTBBJTJCJTIwJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJkZWVwc2Vlay1haSUyRkRlZXBTZWVrLVIxLTA1MjglM0FoeXBlcmJvbGljJTIyJTJDJTIwJTIzJTIwbWFudWFsbHklMjBzZWxlY3QlMjBIeXBlcmJvbGljJTBBJTIwJTIwJTIwJTIwJTIwJTIwLi4uJTBBKQ==",highlighted:`# The OpenAI client automatically routes through Inference Providers
# You can specify provider preferences in your HF settings
client = OpenAI(
    base_url=&quot;https://router.huggingface.co/v1&quot;,
    api_key=os.environ[&quot;HF_TOKEN&quot;],
)

client.chat.completions.create(
<span class="hljs-deletion">-     model=&quot;deepseek-ai/DeepSeek-R1-0528&quot;, # automatically select provider based on hf.co/settings/inference-providers</span>
<span class="hljs-addition">+     model=&quot;deepseek-ai/DeepSeek-R1-0528:nebius&quot;, # manually select Nebius AI</span>
<span class="hljs-addition">+     model=&quot;deepseek-ai/DeepSeek-R1-0528:hyperbolic&quot;, # manually select Hyperbolic</span>
      ...
)`,wrap:!1}}),{c(){u(n.$$.fragment)},l(J){I(n.$$.fragment,J)},m(J,T){r(n,J,T),j=!0},p:Gl,i(J){j||(h(n.$$.fragment,J),j=!0)},o(J){m(n.$$.fragment,J),j=!1},d(J){C(n,J)}}}function $s(f){let n,j="In the Hugging Face Hub client, you can specify the provider you want to use for the request by setting the <code>provider</code> parameter.",J,T,a;return T=new b({props:{code:"JTIzJTIwU3BlY2lmeSUyMGElMjBwcm92aWRlciUyMGRpcmVjdGx5JTBBY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KCUwQSUyMCUyMCUyMCUyMHRva2VuJTNEb3MuZW52aXJvbiU1QiUyMkhGX1RPS0VOJTIyJTVEJTBBJTJCJTIwJTIwJTIwJTIwcHJvdmlkZXIlM0QlMjJhdXRvJTIyJTIwJTIwJTIzJTIwYXV0b21hdGljYWxseSUyMHNlbGVjdCUyMHByb3ZpZGVyJTIwYmFzZWQlMjBvbiUyMGhmLmNvJTJGc2V0dGluZ3MlMkZpbmZlcmVuY2UtcHJvdmlkZXJzJTBBLSUyMCUyMCUyMCUyMHByb3ZpZGVyJTNEJTIydG9nZXRoZXIlMjIlMjAlMjAlMjMlMjBtYW51YWxseSUyMHNlbGVjdCUyMFRvZ2V0aGVyJTIwQUklMEEtJTIwJTIwJTIwJTIwcHJvdmlkZXIlM0QlMjJuZWJpdXMlMjIlMjAlMjAlMjMlMjBtYW51YWxseSUyMHNlbGVjdCUyME5lYml1cyUwQSklMEE=",highlighted:`# Specify a provider directly
client = InferenceClient(
    token=os.environ[&quot;HF_TOKEN&quot;]
<span class="hljs-addition">+    provider=&quot;auto&quot;  # automatically select provider based on hf.co/settings/inference-providers</span>
<span class="hljs-deletion">-    provider=&quot;together&quot;  # manually select Together AI</span>
<span class="hljs-deletion">-    provider=&quot;nebius&quot;  # manually select Nebius</span>
)
`,wrap:!1}}),{c(){n=y("p"),n.innerHTML=j,J=o(),u(T.$$.fragment)},l(M){n=c(M,"P",{"data-svelte-h":!0}),p(n)!=="svelte-1ih4t0z"&&(n.innerHTML=j),J=i(M),I(T.$$.fragment,M)},m(M,d){e(M,n,d),e(M,J,d),r(T,M,d),a=!0},p:Gl,i(M){a||(h(T.$$.fragment,M),a=!0)},o(M){m(T.$$.fragment,M),a=!1},d(M){M&&(s(n),s(J)),C(T,M)}}}function Gs(f){let n,j="In the OpenAI client, you can specify the provider you want to use for the request by appending the provider ID to the model parameter as such:",J,T,a,M,d;return T=new $l({props:{id:"provider-config",option:"openai",$$slots:{default:[Zs]},$$scope:{ctx:f}}}),M=new $l({props:{id:"provider-config",option:"huggingface_hub",$$slots:{default:[$s]},$$scope:{ctx:f}}}),{c(){n=y("p"),n.textContent=j,J=o(),u(T.$$.fragment),a=o(),u(M.$$.fragment)},l(w){n=c(w,"P",{"data-svelte-h":!0}),p(n)!=="svelte-18ali5k"&&(n.textContent=j),J=i(w),I(T.$$.fragment,w),a=i(w),I(M.$$.fragment,w)},m(w,U){e(w,n,U),e(w,J,U),r(T,w,U),e(w,a,U),r(M,w,U),d=!0},p(w,U){const A={};U&2&&(A.$$scope={dirty:U,ctx:w}),T.$set(A);const E={};U&2&&(E.$$scope={dirty:U,ctx:w}),M.$set(E)},i(w){d||(h(T.$$.fragment,w),h(M.$$.fragment,w),d=!0)},o(w){m(T.$$.fragment,w),m(M.$$.fragment,w),d=!1},d(w){w&&(s(n),s(J),s(a)),C(T,w),C(M,w)}}}function vs(f){let n,j="For example, let’s say your assistant’s only job is to give the weather for a given location. You may want to force the model to call the <code>get_current_weather</code> function, and not call any other functions.",J,T,a,M,d="Here, we’re forcing the model to call the <code>get_current_weather</code> function, and not call any other functions.",w;return T=new b({props:{code:"JTIzJTIwRm9yY2UlMjBhJTIwc3BlY2lmaWMlMjBmdW5jdGlvbiUyMGNhbGwlMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0LmNvbXBsZXRpb25zLmNyZWF0ZSglMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMmRlZXBzZWVrLWFpJTJGRGVlcFNlZWstUjEtMDUyOCUyMiUyQyUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTNEbWVzc2FnZXMlMkMlMEElMjAlMjAlMjAlMjB0b29scyUzRHRvb2xzJTJDJTBBJTIwJTIwJTIwJTIwdG9vbF9jaG9pY2UlM0QlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ0eXBlJTIyJTNBJTIwJTIyZnVuY3Rpb24lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJmdW5jdGlvbiUyMiUzQSUyMCU3QiUyMm5hbWUlMjIlM0ElMjAlMjJnZXRfY3VycmVudF93ZWF0aGVyJTIyJTdEJTBBJTIwJTIwJTIwJTIwJTdEJTBBKQ==",highlighted:`<span class="hljs-comment"># Force a specific function call</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;deepseek-ai/DeepSeek-R1-0528&quot;</span>,
    messages=messages,
    tools=tools,
    tool_choice={
        <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;function&quot;</span>,
        <span class="hljs-string">&quot;function&quot;</span>: {<span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;get_current_weather&quot;</span>}
    }
)`,wrap:!1}}),{c(){n=y("p"),n.innerHTML=j,J=o(),u(T.$$.fragment),a=o(),M=y("p"),M.innerHTML=d},l(U){n=c(U,"P",{"data-svelte-h":!0}),p(n)!=="svelte-yciv33"&&(n.innerHTML=j),J=i(U),I(T.$$.fragment,U),a=i(U),M=c(U,"P",{"data-svelte-h":!0}),p(M)!=="svelte-8e7l01"&&(M.innerHTML=d)},m(U,A){e(U,n,A),e(U,J,A),r(T,U,A),e(U,a,A),e(U,M,A),w=!0},p:Gl,i(U){w||(h(T.$$.fragment,U),w=!0)},o(U){m(T.$$.fragment,U),w=!1},d(U){U&&(s(n),s(J),s(a),s(M)),C(T,U)}}}function Ws(f){let n,j="<p>Currently, <code>huggingface_hub.InferenceClient</code> does not support the <code>tool_choice</code> parameters that specify which function to call.</p>";return{c(){n=y("blockquote"),n.innerHTML=j,this.h()},l(J){n=c(J,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p(n)!=="svelte-o14awq"&&(n.innerHTML=j),this.h()},h(){B(n,"class","warning")},m(J,T){e(J,n,T)},p:Gl,d(J){J&&s(n)}}}function Vs(f){let n,j,J,T;return n=new $l({props:{id:"tool-choice-options",option:"openai",$$slots:{default:[vs]},$$scope:{ctx:f}}}),J=new $l({props:{id:"tool-choice-options",option:"huggingface_hub",$$slots:{default:[Ws]},$$scope:{ctx:f}}}),{c(){u(n.$$.fragment),j=o(),u(J.$$.fragment)},l(a){I(n.$$.fragment,a),j=i(a),I(J.$$.fragment,a)},m(a,M){r(n,a,M),e(a,j,M),r(J,a,M),T=!0},p(a,M){const d={};M&2&&(d.$$scope={dirty:M,ctx:a}),n.$set(d);const w={};M&2&&(w.$$scope={dirty:M,ctx:a}),J.$set(w)},i(a){T||(h(n.$$.fragment,a),h(J.$$.fragment,a),T=!0)},o(a){m(n.$$.fragment,a),m(J.$$.fragment,a),T=!1},d(a){a&&s(j),C(n,a),C(J,a)}}}function Qs(f){let n,j,J,T,a,M,d,w,U,A="Function calling enables language models to interact with external tools and APIs by generating structured function calls based on user input. This capability allows you to build AI agents that can perform actions like retrieving real-time data, making calculations, or interacting with external services.",E,N,Rt="When you provide a language model that has been fine-tuned to use tools with function descriptions, it can decide when to call these functions based on user requests, execute them, and incorporate the results into natural language responses. For example, you can build an assistant that fetches real-time weather data to provide accurate responses.",Wl,q,Et='<p>This guide assumes you have a Hugging Face account and access token. You can create a free account at <a href="https://huggingface.co" rel="nofollow">huggingface.co</a> and get your token from your <a href="https://huggingface.co/settings/tokens" rel="nofollow">settings page</a>.</p>',Vl,k,Ql,S,Nt="The first step is implementing the functions you want the model to call. We’ll use a simple weather function example that returns the current weather for a given location.",Rl,Y,kt="As always, we’ll start by initializing the client for our inference client.",El,Z,Nl,X,St="We can define the function as a Python function that performs a simple task. In this case, the function will return the current weather as a dictionary of location, temperature, and condition.",kl,z,Sl,_,Yt="Now we need to define the function schema that describes our weather function to the language model. This schema tells the model what parameters the function expects and what it does:",Yl,x,Xl,F,Xt="The schema is a JSON Schema format that describes what the function does, its parameters, and which parameters are required. The description helps the model understand when to call the function and how to call it.",zl,H,_l,L,zt="Functions work within typical chat completion conversations. The model will decide when to call them based on user input.",xl,D,Fl,$,_t="<p>The <code>tool_choice</code> parameter is used to control when the model calls functions. In this case, we’re using <code>auto</code>, which means the model will decide when to call functions (0 or more times). Below we’ll expand on <code>tool_choice</code> and other parameters.</p>",Hl,P,xt="Next, we need to check in the model response where the model decided to call any functions. If it did, we need to execute the function and add the result to the conversation, before we send the final response to the user.",Ll,O,Dl,K,Ft="The workflow is straightforward: make an initial API call with your tools, check if the model wants to call functions, execute them if needed, add the results to the conversation, and get the final response for the user.",Pl,G,Ht="<p>We have handled the case where the model wants to call a function and that the function actually exists. However, models might try to call functions that don’t exist, so we need to account for that as well. We can also deal with this using <code>strict</code> mode, which we’ll cover later.</p>",Ol,ll,Kl,tl,Lt="You can define multiple functions for more complex assistants:",lt,sl,tt,el,Dt="We have defined multiple functions and added them to the tools list. The model will decide when to call them based on user input. We can also use the <code>tool_choice</code> parameter to force the model to call a specific function.",st,nl,Pt="We can handle the tool executions in a similar way to the single function example. This time using an <code>elif</code> statement to handle the different functions.",et,Ml,nt,al,Ot="🎉 You’ve built a functional assistant that can call multiple functions to get weather data!",Mt,ol,at,il,Kt="Let’s look at some additional configuration options for function calling with Inference Providers, to make the most of the capabilities.",ot,Jl,it,Tl,ls="You can specify which inference provider to use for more control over performance and cost. This will pay off with function calling by reducing variance in the model’s response.",Jt,v,Tt,yl,ts="By switching provider, you can see the model’s response change because each provider uses a different configuration of the model.",yt,W,ss='<p>Each inference provider has different capabilities and performance characteristics. You can find more information about each provider in the <a href="/inference-providers/index#partners">Inference Providers</a> section.</p>',ct,cl,wt,wl,es="You can control when and which functions are called using the <code>tool_choice</code> parameter.",pt,pl,ns="The <code>tool_choice</code> parameter is used to control when the model calls functions. In most cases, we’re using <code>auto</code>, which means the model will decide when to call functions (0 or more times).",jt,jl,Ut,Ul,Ms="However, in some use cases, you may want to force the model to call a function so that it never replies based on its own knowledge, but only based on the function call results.",ut,ul,It,Il,as="This works well if you have simple functions, but if you have more complex functions, you may want to use the <code>tool_choice</code> parameter to force the model to call a specific function at least once.",rt,V,ht,rl,mt,hl,os="Use strict mode to ensure function calls follow your schema exactly. This is useful to prevent the model from calling functions with unexpected arguments, or calling functions that don’t exist.",Ct,ml,dt,Cl,is="Strict mode ensures that function arguments match your schema exactly: no additional properties are allowed, all required parameters must be provided, and data types are strictly enforced.",ft,Q,Js="<p>Strict mode is not supported by all providers. You can check the provider’s documentation to see if it supports strict mode.</p>",bt,dl,At,fl,Ts="Enable streaming for real-time responses with function calls. This is useful to show the model’s progress to the user, or to handle long-running function calls more efficiently.",gt,bl,Bt,Al,ys="Streaming allows you to process responses as they arrive, show real-time progress to users, and handle long-running function calls more efficiently.",qt,R,cs='<p>Streaming is not supported by all providers. You can check the provider’s documentation to see if it supports streaming, or you can refer to this <a href="https://huggingface.co/inference-providers/models" rel="nofollow">dynamic model compatibility table</a>.</p>',Zt,gl,$t,Bl,ws="Now that you’ve seen how to use function calling with Inference Providers, you can start building your own agents and assistants! Why not try out some of these ideas:",Gt,ql,ps="<li>Try smaller models for faster responses and lower costs</li> <li>Build an agent that can fetch real-time data</li> <li>Use a reasoning model to build an agent that can reason with external tools</li>",vt,Zl,Wt,vl,Vt;return a=new bs({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),d=new g({props:{title:"Function Calling with Inference Providers",local:"function-calling-with-inference-providers",headingTag:"h1"}}),k=new g({props:{title:"Defining Functions",local:"defining-functions",headingTag:"h2"}}),Z=new Qt({props:{id:"define-functions",options:["openai","huggingface_hub"],$$slots:{default:[qs]},$$scope:{ctx:f}}}),z=new b({props:{code:"JTIzJTIwRGVmaW5lJTIwdGhlJTIwZnVuY3Rpb24lMEFkZWYlMjBnZXRfY3VycmVudF93ZWF0aGVyKGxvY2F0aW9uJTNBJTIwc3RyKSUyMC0lM0UlMjBkaWN0JTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyR2V0JTIwd2VhdGhlciUyMGluZm9ybWF0aW9uJTIwZm9yJTIwYSUyMGxvY2F0aW9uLiUyMiUyMiUyMiUwQSUyMCUyMCUyMCUyMCUyMyUyMEluJTIwcHJvZHVjdGlvbiUyQyUyMHRoaXMlMjB3b3VsZCUyMGNhbGwlMjBhJTIwcmVhbCUyMHdlYXRoZXIlMjBBUEklMEElMjAlMjAlMjAlMjB3ZWF0aGVyX2RhdGElMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJTYW4lMjBGcmFuY2lzY28lMjIlM0ElMjAlN0IlMjJ0ZW1wZXJhdHVyZSUyMiUzQSUyMCUyMjIyJUMyJUIwQyUyMiUyQyUyMCUyMmNvbmRpdGlvbiUyMiUzQSUyMCUyMlN1bm55JTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyTmV3JTIwWW9yayUyMiUzQSUyMCU3QiUyMnRlbXBlcmF0dXJlJTIyJTNBJTIwJTIyMTglQzIlQjBDJTIyJTJDJTIwJTIyY29uZGl0aW9uJTIyJTNBJTIwJTIyQ2xvdWR5JTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyTG9uZG9uJTIyJTNBJTIwJTdCJTIydGVtcGVyYXR1cmUlMjIlM0ElMjAlMjIxNSVDMiVCMEMlMjIlMkMlMjAlMjJjb25kaXRpb24lMjIlM0ElMjAlMjJSYWlueSUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMCUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHdlYXRoZXJfZGF0YS5nZXQobG9jYXRpb24lMkMlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJsb2NhdGlvbiUyMiUzQSUyMGxvY2F0aW9uJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZXJyb3IlMjIlM0ElMjAlMjJXZWF0aGVyJTIwZGF0YSUyMG5vdCUyMGF2YWlsYWJsZSUyMiUwQSUyMCUyMCUyMCUyMCU3RCk=",highlighted:`<span class="hljs-comment"># Define the function</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_current_weather</span>(<span class="hljs-params">location: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">dict</span>:
    <span class="hljs-string">&quot;&quot;&quot;Get weather information for a location.&quot;&quot;&quot;</span>
    <span class="hljs-comment"># In production, this would call a real weather API</span>
    weather_data = {
        <span class="hljs-string">&quot;San Francisco&quot;</span>: {<span class="hljs-string">&quot;temperature&quot;</span>: <span class="hljs-string">&quot;22°C&quot;</span>, <span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Sunny&quot;</span>},
        <span class="hljs-string">&quot;New York&quot;</span>: {<span class="hljs-string">&quot;temperature&quot;</span>: <span class="hljs-string">&quot;18°C&quot;</span>, <span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Cloudy&quot;</span>},
        <span class="hljs-string">&quot;London&quot;</span>: {<span class="hljs-string">&quot;temperature&quot;</span>: <span class="hljs-string">&quot;15°C&quot;</span>, <span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Rainy&quot;</span>},
    }
    
    <span class="hljs-keyword">return</span> weather_data.get(location, {
        <span class="hljs-string">&quot;location&quot;</span>: location,
        <span class="hljs-string">&quot;error&quot;</span>: <span class="hljs-string">&quot;Weather data not available&quot;</span>
    })`,wrap:!1}}),x=new b({props:{code:"JTBBJTIzJTIwRGVmaW5lJTIwdGhlJTIwZnVuY3Rpb24lMjBzY2hlbWElMEF0b29scyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnR5cGUlMjIlM0ElMjAlMjJmdW5jdGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmZ1bmN0aW9uJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybmFtZSUyMiUzQSUyMCUyMmdldF9jdXJyZW50X3dlYXRoZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJkZXNjcmlwdGlvbiUyMiUzQSUyMCUyMkdldCUyMGN1c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VCJTIybG9jYXRpb24lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMkMlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElNUQ=",highlighted:`
<span class="hljs-comment"># Define the function schema</span>
tools = [
    {
        <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;function&quot;</span>,
        <span class="hljs-string">&quot;function&quot;</span>: {
            <span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;get_current_weather&quot;</span>,
            <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;Get current weather for a location&quot;</span>,
            <span class="hljs-string">&quot;parameters&quot;</span>: {
                <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;object&quot;</span>,
                <span class="hljs-string">&quot;properties&quot;</span>: {
                    <span class="hljs-string">&quot;location&quot;</span>: {
                        <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>, 
                        <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;City name&quot;</span>
                    },
                },
                <span class="hljs-string">&quot;required&quot;</span>: [<span class="hljs-string">&quot;location&quot;</span>],
            },
        },
    },
]`,wrap:!1}}),H=new g({props:{title:"Handling Functions in Chats",local:"handling-functions-in-chats",headingTag:"h2"}}),D=new b({props:{code:"dXNlcl9tZXNzYWdlJTIwJTNEJTIwJTIyV2hhdCdzJTIwdGhlJTIwd2VhdGhlciUyMGxpa2UlMjBpbiUyMFNhbiUyMEZyYW5jaXNjbyUzRiUyMiUwQSUwQW1lc3NhZ2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycm9sZSUyMiUzQSUyMCUyMnN5c3RlbSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJZb3UlMjBhcmUlMjBhJTIwaGVscGZ1bCUyMGFzc2lzdGFudCUyMHdpdGglMjBhY2Nlc3MlMjB0byUyMHdlYXRoZXIlMjBkYXRhLiUyMiUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMHVzZXJfbWVzc2FnZSU3RCUwQSU1RCUwQSUwQSUyMyUyMEluaXRpYWwlMjBBUEklMjBjYWxsJTIwd2l0aCUyMHRvb2xzJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJkZWVwc2Vlay1haSUyRkRlZXBTZWVrLVIxLTA1MjglMjIlMkMlMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUzRG1lc3NhZ2VzJTJDJTBBJTIwJTIwJTIwJTIwdG9vbHMlM0R0b29scyUyQyUwQSUyMCUyMCUyMCUyMHRvb2xfY2hvaWNlJTNEJTIyYXV0byUyMiUyMCUyMyUyMExldCUyMHRoZSUyMG1vZGVsJTIwZGVjaWRlJTIwd2hlbiUyMHRvJTIwY2FsbCUyMGZ1bmN0aW9ucyUwQSklMEElMEFyZXNwb25zZV9tZXNzYWdlJTIwJTNEJTIwcmVzcG9uc2UuY2hvaWNlcyU1QjAlNUQubWVzc2FnZQ==",highlighted:`user_message = <span class="hljs-string">&quot;What&#x27;s the weather like in San Francisco?&quot;</span>

messages = [
    {
        <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>,
        <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant with access to weather data.&quot;</span>
    },
    {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: user_message}
]

<span class="hljs-comment"># Initial API call with tools</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;deepseek-ai/DeepSeek-R1-0528&quot;</span>,
    messages=messages,
    tools=tools,
    tool_choice=<span class="hljs-string">&quot;auto&quot;</span> <span class="hljs-comment"># Let the model decide when to call functions</span>
)

response_message = response.choices[<span class="hljs-number">0</span>].message`,wrap:!1}}),O=new b({props:{code:"JTBBJTIzJTIwQ2hlY2slMjBpZiUyMG1vZGVsJTIwd2FudHMlMjB0byUyMGNhbGwlMjBmdW5jdGlvbnMlMEFpZiUyMHJlc3BvbnNlX21lc3NhZ2UudG9vbF9jYWxscyUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMEFkZCUyMGFzc2lzdGFudCdzJTIwcmVzcG9uc2UlMjB0byUyMG1lc3NhZ2VzJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMuYXBwZW5kKHJlc3BvbnNlX21lc3NhZ2UpJTBBJTBBJTIwJTIwJTIwJTIwJTIzJTIwUHJvY2VzcyUyMGVhY2glMjB0b29sJTIwY2FsbCUwQSUyMCUyMCUyMCUyMGZvciUyMHRvb2xfY2FsbCUyMGluJTIwcmVzcG9uc2VfbWVzc2FnZS50b29sX2NhbGxzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZnVuY3Rpb25fbmFtZSUyMCUzRCUyMHRvb2xfY2FsbC5mdW5jdGlvbi5uYW1lJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZnVuY3Rpb25fYXJncyUyMCUzRCUyMGpzb24ubG9hZHModG9vbF9jYWxsLmZ1bmN0aW9uLmFyZ3VtZW50cyklMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBFeGVjdXRlJTIwdGhlJTIwZnVuY3Rpb24lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZiUyMGZ1bmN0aW9uX25hbWUlMjAlM0QlM0Ql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bHRzJTBBJTIwJTIwJTIwJTIwZmluYWxfcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJkZWVwc2Vlay1haSUyRkRlZXBTZWVrLVIxLTA1MjglMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtZXNzYWdlcyUzRG1lc3NhZ2VzJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGZpbmFsX3Jlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCUwQWVsc2UlM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjByZXNwb25zZV9tZXNzYWdlLmNvbnRlbnQlMEE=",highlighted:`
<span class="hljs-comment"># Check if model wants to call functions</span>
<span class="hljs-keyword">if</span> response_message.tool_calls:
    <span class="hljs-comment"># Add assistant&#x27;s response to messages</span>
    messages.append(response_message)

    <span class="hljs-comment"># Process each tool call</span>
    <span class="hljs-keyword">for</span> tool_call <span class="hljs-keyword">in</span> response_message.tool_calls:
        function_name = tool_call.function.name
        function_args = json.loads(tool_call.function.arguments)

        <span class="hljs-comment"># Execute the function</span>
        <span class="hljs-keyword">if</span> function_name == <span class="hljs-string">&quot;get_current_weather&quot;</span>:
            result = get_current_weather(function_args[<span class="hljs-string">&quot;location&quot;</span>])
            
            <span class="hljs-comment"># Add function result to messages</span>
            messages.append({
                <span class="hljs-string">&quot;tool_call_id&quot;</span>: tool_call.<span class="hljs-built_in">id</span>,
                <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;tool&quot;</span>,
                <span class="hljs-string">&quot;name&quot;</span>: function_name,
                <span class="hljs-string">&quot;content&quot;</span>: json.dumps(result),
            })

    <span class="hljs-comment"># Get final response with function results</span>
    final_response = client.chat.completions.create(
        model=<span class="hljs-string">&quot;deepseek-ai/DeepSeek-R1-0528&quot;</span>,
        messages=messages,
    )

    <span class="hljs-keyword">return</span> final_response.choices[<span class="hljs-number">0</span>].message.content
<span class="hljs-keyword">else</span>:
    <span class="hljs-keyword">return</span> response_message.content
`,wrap:!1}}),ll=new g({props:{title:"Multiple Functions",local:"multiple-functions",headingTag:"h2"}}),sl=new b({props:{code:" ",highlighted:`<span class="hljs-comment"># Define multiple functions</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_current_weather</span>(<span class="hljs-params">location: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">dict</span>:
    <span class="hljs-string">&quot;&quot;&quot;Get current weather for a location.&quot;&quot;&quot;</span>
    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;location&quot;</span>: location, <span class="hljs-string">&quot;temperature&quot;</span>: <span class="hljs-string">&quot;22°C&quot;</span>, <span class="hljs-string">&quot;condition&quot;</span>: <span class="hljs-string">&quot;Sunny&quot;</span>}

<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_weather_forecast</span>(<span class="hljs-params">location: <span class="hljs-built_in">str</span>, date: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">dict</span>:
    <span class="hljs-string">&quot;&quot;&quot;Get weather forecast for a location.&quot;&quot;&quot;</span>
    <span class="hljs-keyword">return</span> {
        <span class="hljs-string">&quot;location&quot;</span>: location,
        <span class="hljs-string">&quot;date&quot;</span>: date,
        <span class="hljs-string">&quot;forecast&quot;</span>: <span class="hljs-string">&quot;Sunny with chance of rain&quot;</span>,
        <span class="hljs-string">&quot;temperature&quot;</span>: <span class="hljs-string">&quot;20°C&quot;</span>
    }

<span class="hljs-comment"># Function registry</span>
AVAILABLE_FUNCTIONS = {
    <span class="hljs-string">&quot;get_current_weather&quot;</span>: get_current_weather,
    <span class="hljs-string">&quot;get_weather_forecast&quot;</span>: get_weather_forecast,
}

<span class="hljs-comment"># Multiple tool schemas</span>
tools = [
    {
        <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;function&quot;</span>,
        <span class="hljs-string">&quot;function&quot;</span>: {
            <span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;get_current_weather&quot;</span>,
            <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;Get current weather for a location&quot;</span>,
            <span class="hljs-string">&quot;parameters&quot;</span>: {
                <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;object&quot;</span>,
                <span class="hljs-string">&quot;properties&quot;</span>: {
                    <span class="hljs-string">&quot;location&quot;</span>: {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>, <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;City name&quot;</span>}
                },
                <span class="hljs-string">&quot;required&quot;</span>: [<span class="hljs-string">&quot;location&quot;</span>],
            },
        },
    },
    {
        <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;function&quot;</span>,
        <span class="hljs-string">&quot;function&quot;</span>: {
            <span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;get_weather_forecast&quot;</span>,
            <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;Get weather forecast for a location&quot;</span>,
            <span class="hljs-string">&quot;parameters&quot;</span>: {
                <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;object&quot;</span>,
                <span class="hljs-string">&quot;properties&quot;</span>: {
                    <span class="hljs-string">&quot;location&quot;</span>: {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>, <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;City name&quot;</span>},
                    <span class="hljs-string">&quot;date&quot;</span>: {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>, <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;Date in YYYY-MM-DD format&quot;</span>},
                },
                <span class="hljs-string">&quot;required&quot;</span>: [<span class="hljs-string">&quot;location&quot;</span>, <span class="hljs-string">&quot;date&quot;</span>],
            },
        },
    },
]

response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;deepseek-ai/DeepSeek-R1-0528&quot;</span>,
    messages=messages,
    tools=tools,
    tool_choice=<span class="hljs-string">&quot;auto&quot;</span>
)
`,wrap:!1}}),Ml=new b({props:{code:"JTIzJTIwZXhlY3V0ZSUyMHRoZSUyMHJlc3BvbnNlJTBBcmVzcG9uc2VfbWVzc2FnZSUyMCUzRCUyMHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UlMEElMEElMjMlMjBjaGVjayUyMGlmJTIwdGhlJTIwbW9kZWwlMjB3YW50cyUyMHRvJTIwY2FsbCUyMGZ1bmN0aW9ucyUwQWlmJTIwcmVzcG9uc2VfbWVzc2FnZS50b29sX2NhbGxzJTNBJTBBJTIwJTIwJTIwJTIwJTIzJTIwcHJvY2VzcyUyMHRoZSUyMHRvb2wlMjBjYWxscyUwQSUyMCUyMCUyMCUyMGZvciUyMHRvb2xfY2FsbCUyMGluJTIwcmVzcG9uc2VfbWVzc2FnZS50b29sX2NhbGxzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZnVuY3Rpb25fbmFtZSUyMCUzRCUyMHRvb2xfY2FsbC5mdW5jdGlvbi5uYW1lJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZnVuY3Rpb25fYXJncyUyMCUzRCUyMGpzb24ubG9hZHModG9vbF9jYWxsLmZ1bmN0aW9uLmFyZ3VtZW50cyklMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBleGVjdXRlJTIwdGhlJTIwZnVuY3Rpb24lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZiUyMGZ1bmN0aW9uX25hbWUlMjAlM0QlM0QlMjAlMjJnZXRfY3VycmVudF93ZWF0aGVyJTIyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJT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wQSUyMCUyMCUyMCUyMCUyMyUyMGdldCUyMHRoZSUyMGZpbmFsJTIwcmVzcG9uc2UlMjB3aXRoJTIwZnVuY3Rpb24lMjByZXN1bHRzJTBBJTIwJTIwJTIwJTIwZmluYWxfcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJkZWVwc2Vlay1haSUyRkRlZXBTZWVrLVIxLTA1MjglMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtZXNzYWdlcyUzRG1lc3NhZ2VzJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGZpbmFsX3Jlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCUwQWVsc2UlM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjByZXNwb25zZV9tZXNzYWdlLmNvbnRlbnQlMEE=",highlighted:`<span class="hljs-comment"># execute the response</span>
response_message = response.choices[<span class="hljs-number">0</span>].message

<span class="hljs-comment"># check if the model wants to call functions</span>
<span class="hljs-keyword">if</span> response_message.tool_calls:
    <span class="hljs-comment"># process the tool calls</span>
    <span class="hljs-keyword">for</span> tool_call <span class="hljs-keyword">in</span> response_message.tool_calls:
        function_name = tool_call.function.name
        function_args = json.loads(tool_call.function.arguments)

        <span class="hljs-comment"># execute the function</span>
        <span class="hljs-keyword">if</span> function_name == <span class="hljs-string">&quot;get_current_weather&quot;</span>:
            result = get_current_weather(function_args[<span class="hljs-string">&quot;location&quot;</span>])
        <span class="hljs-keyword">elif</span> function_name == <span class="hljs-string">&quot;get_weather_forecast&quot;</span>:
            result = get_weather_forecast(function_args[<span class="hljs-string">&quot;location&quot;</span>], function_args[<span class="hljs-string">&quot;date&quot;</span>])

        <span class="hljs-comment"># add the result to the conversation</span>
        messages.append({
            <span class="hljs-string">&quot;tool_call_id&quot;</span>: tool_call.<span class="hljs-built_in">id</span>,
            <span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;tool&quot;</span>,
            <span class="hljs-string">&quot;name&quot;</span>: function_name,
            <span class="hljs-string">&quot;content&quot;</span>: json.dumps(result),
        })

    <span class="hljs-comment"># get the final response with function results</span>
    final_response = client.chat.completions.create(
        model=<span class="hljs-string">&quot;deepseek-ai/DeepSeek-R1-0528&quot;</span>,
        messages=messages,
    )

    <span class="hljs-keyword">return</span> final_response.choices[<span class="hljs-number">0</span>].message.content
<span class="hljs-keyword">else</span>:
    <span class="hljs-keyword">return</span> response_message.content
`,wrap:!1}}),ol=new g({props:{title:"Additional Configuration",local:"additional-configuration",headingTag:"h2"}}),Jl=new g({props:{title:"Provider Selection",local:"provider-selection",headingTag:"h3"}}),v=new Qt({props:{id:"provider-config",options:["openai","huggingface_hub"],$$slots:{default:[Gs]},$$scope:{ctx:f}}}),cl=new g({props:{title:"Tool Choice Options",local:"tool-choice-options",headingTag:"h3"}}),jl=new b({props:{code:"JTIzJTIwTGV0JTIwdGhlJTIwbW9kZWwlMjBkZWNpZGUlMjAoZGVmYXVsdCklMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0LmNvbXBsZXRpb25zLmNyZWF0ZSglMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMmRlZXBzZWVrLWFpJTJGRGVlcFNlZWstUjEtMDUyOCUyMiUyQyUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTNEbWVzc2FnZXMlMkMlMEElMjAlMjAlMjAlMjB0b29scyUzRHRvb2xzJTJDJTBBJTIwJTIwJTIwJTIwdG9vbF9jaG9pY2UlM0QlMjJhdXRvJTIyJTIwJTIwJTIzJTIwTW9kZWwlMjBkZWNpZGVzJTIwd2hlbiUyMHRvJTIwY2FsbCUyMGZ1bmN0aW9ucyUwQSk=",highlighted:`<span class="hljs-comment"># Let the model decide (default)</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;deepseek-ai/DeepSeek-R1-0528&quot;</span>,
    messages=messages,
    tools=tools,
    tool_choice=<span class="hljs-string">&quot;auto&quot;</span>  <span class="hljs-comment"># Model decides when to call functions</span>
)`,wrap:!1}}),ul=new b({props:{code:"JTIzJTIwRm9yY2UlMjB0aGUlMjBtb2RlbCUyMHRvJTIwY2FsbCUyMGF0JTIwbGVhc3QlMjBvbmUlMjBmdW5jdGlvbiUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LmNoYXQuY29tcGxldGlvbnMuY3JlYXRlKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyZGVlcHNlZWstYWklMkZEZWVwU2Vlay1SMS0wNTI4JTIyJTJDJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlM0RtZXNzYWdlcyUyQyUwQSUyMCUyMCUyMCUyMHRvb2xzJTNEdG9vbHMlMkMlMEElMjAlMjAlMjAlMjB0b29sX2Nob2ljZSUzRCUyMnJlcXVpcmVkJTIyJTIwJTIwJTIzJTIwTXVzdCUyMGNhbGwlMjBhdCUyMGxlYXN0JTIwb25lJTIwZnVuY3Rpb24lMEEp",highlighted:`<span class="hljs-comment"># Force the model to call at least one function</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;deepseek-ai/DeepSeek-R1-0528&quot;</span>,
    messages=messages,
    tools=tools,
    tool_choice=<span class="hljs-string">&quot;required&quot;</span>  <span class="hljs-comment"># Must call at least one function</span>
)`,wrap:!1}}),V=new Qt({props:{id:"tool-choice-options",options:["openai","huggingface_hub"],$$slots:{default:[Vs]},$$scope:{ctx:f}}}),rl=new g({props:{title:"Strict Mode",local:"strict-mode",headingTag:"h3"}}),ml=new b({props:{code:"JTIzJTIwRGVmaW5lJTIwdG9vbHMlMjB3aXRoJTIwc3RyaWN0JTIwbW9kZSUwQXRvb2xzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIw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IwJTIwJTIwJTIycmVxdWlyZWQlMjIlM0ElMjAlNUIlMjJsb2NhdGlvbiUyMiU1RCUyQyUwQSUyQiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmFkZGl0aW9uYWxQcm9wZXJ0aWVzJTIyJTNBJTIwRmFsc2UlMkMlMjAlMjAlMjMlMjBTdHJpY3QlMjBtb2RlJTIwcmVxdWlyZW1lbnQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QlMkMlMEElMkIlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdHJpY3QlMjIlM0ElMjBUcnVlJTJDJTIwJTIwJTIzJTIwRW5hYmxlJTIwc3RyaWN0JTIwbW9kZSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSU1RA==",highlighted:`<span class="hljs-comment"># Define tools with strict mode</span>
tools = [
    {
        <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;function&quot;</span>,
        <span class="hljs-string">&quot;function&quot;</span>: {
            <span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;get_current_weather&quot;</span>,
            <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;Get current weather for a location&quot;</span>,
            <span class="hljs-string">&quot;parameters&quot;</span>: {
                <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;object&quot;</span>,
                <span class="hljs-string">&quot;properties&quot;</span>: {
                    <span class="hljs-string">&quot;location&quot;</span>: {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>, <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;City name&quot;</span>},
                },
                <span class="hljs-string">&quot;required&quot;</span>: [<span class="hljs-string">&quot;location&quot;</span>],
+                <span class="hljs-string">&quot;additionalProperties&quot;</span>: <span class="hljs-literal">False</span>,  <span class="hljs-comment"># Strict mode requirement</span>
            },
+            <span class="hljs-string">&quot;strict&quot;</span>: <span class="hljs-literal">True</span>,  <span class="hljs-comment"># Enable strict mode</span>
        },
    },
]`,wrap:!1}}),dl=new g({props:{title:"Streaming Responses",local:"streaming-responses",headingTag:"h3"}}),bl=new b({props:{code:"JTIzJTIwRW5hYmxlJTIwc3RyZWFtaW5nJTIwd2l0aCUyMGZ1bmN0aW9uJTIwY2FsbHMlMEFzdHJlYW0lMjAlM0QlMjBjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJkZWVwc2Vlay1haSUyRkRlZXBTZWVrLVIxLTA1MjglMjIlMkMlMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUzRG1lc3NhZ2VzJTJDJTBBJTIwJTIwJTIwJTIwdG9vbHMlM0R0b29scyUyQyUwQSUyMCUyMCUyMCUyMHRvb2xfY2hvaWNlJTNEJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMHN0cmVhbSUzRFRydWUlMjAlMjAlMjMlMjBFbmFibGUlMjBzdHJlYW1pbmclMEEpJTBBJTBBJTIzJTIwUHJvY2VzcyUyMHRoZSUyMHN0cmVhbSUwQWZvciUyMGNodW5rJTIwaW4lMjBzdHJlYW0lM0ElMEElMjAlMjAlMjAlMjBpZiUyMGNodW5rLmNob2ljZXMlNUIwJTVELmRlbHRhLnRvb2xfY2FsbHMlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBIYW5kbGUlMjB0b29sJTIwY2FsbCUyMGNodW5rcyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRvb2xfY2FsbHMlMjAlM0QlMjBjaHVuay5jaG9pY2VzJTVCMCU1RC5kZWx0YS50b29sX2NhbGxzJTBBJTIwJTIwJTIwJTIwJTBBJTIwJTIwJTIwJTIwaWYlMjBjaHVuay5jaG9pY2VzJTVCMCU1RC5kZWx0YS5jb250ZW50JTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwSGFuZGxlJTIwY29udGVudCUyMGNodW5rcyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGNvbnRlbnQlMjAlM0QlMjBjaHVuay5jaG9pY2VzJTVCMCU1RC5kZWx0YS5jb250ZW50",highlighted:`<span class="hljs-comment"># Enable streaming with function calls</span>
stream = client.chat.completions.create(
    model=<span class="hljs-string">&quot;deepseek-ai/DeepSeek-R1-0528&quot;</span>,
    messages=messages,
    tools=tools,
    tool_choice=<span class="hljs-string">&quot;auto&quot;</span>,
    stream=<span class="hljs-literal">True</span>  <span class="hljs-comment"># Enable streaming</span>
)

<span class="hljs-comment"># Process the stream</span>
<span class="hljs-keyword">for</span> chunk <span class="hljs-keyword">in</span> stream:
    <span class="hljs-keyword">if</span> chunk.choices[<span class="hljs-number">0</span>].delta.tool_calls:
        <span class="hljs-comment"># Handle tool call chunks</span>
        tool_calls = chunk.choices[<span class="hljs-number">0</span>].delta.tool_calls
    
    <span class="hljs-keyword">if</span> chunk.choices[<span class="hljs-number">0</span>].delta.content:
        <span class="hljs-comment"># Handle content chunks</span>
        content = chunk.choices[<span class="hljs-number">0</span>].delta.content`,wrap:!1}}),gl=new g({props:{title:"Next Steps",local:"next-steps",headingTag:"h2"}}),Zl=new As({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/inference-providers/guides/function-calling.md"}}),{c(){n=y("meta"),j=o(),J=y("p"),T=o(),u(a.$$.fragment),M=o(),u(d.$$.fragment),w=o(),U=y("p"),U.textContent=A,E=o(),N=y("p"),N.textContent=Rt,Wl=o(),q=y("blockquote"),q.innerHTML=Et,Vl=o(),u(k.$$.fragment),Ql=o(),S=y("p"),S.textContent=Nt,Rl=o(),Y=y("p"),Y.textContent=kt,El=o(),u(Z.$$.fragment),Nl=o(),X=y("p"),X.textContent=St,kl=o(),u(z.$$.fragment),Sl=o(),_=y("p"),_.textContent=Yt,Yl=o(),u(x.$$.fragment),Xl=o(),F=y("p"),F.textContent=Xt,zl=o(),u(H.$$.fragment),_l=o(),L=y("p"),L.textContent=zt,xl=o(),u(D.$$.fragment),Fl=o(),$=y("blockquote"),$.innerHTML=_t,Hl=o(),P=y("p"),P.textContent=xt,Ll=o(),u(O.$$.fragment),Dl=o(),K=y("p"),K.textContent=Ft,Pl=o(),G=y("blockquote"),G.innerHTML=Ht,Ol=o(),u(ll.$$.fragment),Kl=o(),tl=y("p"),tl.textContent=Lt,lt=o(),u(sl.$$.fragment),tt=o(),el=y("p"),el.innerHTML=Dt,st=o(),nl=y("p"),nl.innerHTML=Pt,et=o(),u(Ml.$$.fragment),nt=o(),al=y("p"),al.textContent=Ot,Mt=o(),u(ol.$$.fragment),at=o(),il=y("p"),il.textContent=Kt,ot=o(),u(Jl.$$.fragment),it=o(),Tl=y("p"),Tl.textContent=ls,Jt=o(),u(v.$$.fragment),Tt=o(),yl=y("p"),yl.textContent=ts,yt=o(),W=y("blockquote"),W.innerHTML=ss,ct=o(),u(cl.$$.fragment),wt=o(),wl=y("p"),wl.innerHTML=es,pt=o(),pl=y("p"),pl.innerHTML=ns,jt=o(),u(jl.$$.fragment),Ut=o(),Ul=y("p"),Ul.textContent=Ms,ut=o(),u(ul.$$.fragment),It=o(),Il=y("p"),Il.innerHTML=as,rt=o(),u(V.$$.fragment),ht=o(),u(rl.$$.fragment),mt=o(),hl=y("p"),hl.textContent=os,Ct=o(),u(ml.$$.fragment),dt=o(),Cl=y("p"),Cl.textContent=is,ft=o(),Q=y("blockquote"),Q.innerHTML=Js,bt=o(),u(dl.$$.fragment),At=o(),fl=y("p"),fl.textContent=Ts,gt=o(),u(bl.$$.fragment),Bt=o(),Al=y("p"),Al.textContent=ys,qt=o(),R=y("blockquote"),R.innerHTML=cs,Zt=o(),u(gl.$$.fragment),$t=o(),Bl=y("p"),Bl.textContent=ws,Gt=o(),ql=y("ul"),ql.innerHTML=ps,vt=o(),u(Zl.$$.fragment),Wt=o(),vl=y("p"),this.h()},l(l){const t=ds("svelte-u9bgzb",document.head);n=c(t,"META",{name:!0,content:!0}),t.forEach(s),j=i(l),J=c(l,"P",{}),Is(J).forEach(s),T=i(l),I(a.$$.fragment,l),M=i(l),I(d.$$.fragment,l),w=i(l),U=c(l,"P",{"data-svelte-h":!0}),p(U)!=="svelte-cp37g1"&&(U.textContent=A),E=i(l),N=c(l,"P",{"data-svelte-h":!0}),p(N)!=="svelte-1sqnw1z"&&(N.textContent=Rt),Wl=i(l),q=c(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p(q)!=="svelte-1evt5ic"&&(q.innerHTML=Et),Vl=i(l),I(k.$$.fragment,l),Ql=i(l),S=c(l,"P",{"data-svelte-h":!0}),p(S)!=="svelte-158dyhv"&&(S.textContent=Nt),Rl=i(l),Y=c(l,"P",{"data-svelte-h":!0}),p(Y)!=="svelte-r0gx1"&&(Y.textContent=kt),El=i(l),I(Z.$$.fragment,l),Nl=i(l),X=c(l,"P",{"data-svelte-h":!0}),p(X)!=="svelte-5c0cr"&&(X.textContent=St),kl=i(l),I(z.$$.fragment,l),Sl=i(l),_=c(l,"P",{"data-svelte-h":!0}),p(_)!=="svelte-18k9bcx"&&(_.textContent=Yt),Yl=i(l),I(x.$$.fragment,l),Xl=i(l),F=c(l,"P",{"data-svelte-h":!0}),p(F)!=="svelte-104xyur"&&(F.textContent=Xt),zl=i(l),I(H.$$.fragment,l),_l=i(l),L=c(l,"P",{"data-svelte-h":!0}),p(L)!=="svelte-17qvq9b"&&(L.textContent=zt),xl=i(l),I(D.$$.fragment,l),Fl=i(l),$=c(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p($)!=="svelte-7mvilh"&&($.innerHTML=_t),Hl=i(l),P=c(l,"P",{"data-svelte-h":!0}),p(P)!=="svelte-1c9i8c8"&&(P.textContent=xt),Ll=i(l),I(O.$$.fragment,l),Dl=i(l),K=c(l,"P",{"data-svelte-h":!0}),p(K)!=="svelte-k8gu1e"&&(K.textContent=Ft),Pl=i(l),G=c(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p(G)!=="svelte-xsjz7g"&&(G.innerHTML=Ht),Ol=i(l),I(ll.$$.fragment,l),Kl=i(l),tl=c(l,"P",{"data-svelte-h":!0}),p(tl)!=="svelte-fnff52"&&(tl.textContent=Lt),lt=i(l),I(sl.$$.fragment,l),tt=i(l),el=c(l,"P",{"data-svelte-h":!0}),p(el)!=="svelte-1ipjtjp"&&(el.innerHTML=Dt),st=i(l),nl=c(l,"P",{"data-svelte-h":!0}),p(nl)!=="svelte-us9ts0"&&(nl.innerHTML=Pt),et=i(l),I(Ml.$$.fragment,l),nt=i(l),al=c(l,"P",{"data-svelte-h":!0}),p(al)!=="svelte-vcr3fu"&&(al.textContent=Ot),Mt=i(l),I(ol.$$.fragment,l),at=i(l),il=c(l,"P",{"data-svelte-h":!0}),p(il)!=="svelte-jniacp"&&(il.textContent=Kt),ot=i(l),I(Jl.$$.fragment,l),it=i(l),Tl=c(l,"P",{"data-svelte-h":!0}),p(Tl)!=="svelte-t5ru84"&&(Tl.textContent=ls),Jt=i(l),I(v.$$.fragment,l),Tt=i(l),yl=c(l,"P",{"data-svelte-h":!0}),p(yl)!=="svelte-rzv6k"&&(yl.textContent=ts),yt=i(l),W=c(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p(W)!=="svelte-1pudsfw"&&(W.innerHTML=ss),ct=i(l),I(cl.$$.fragment,l),wt=i(l),wl=c(l,"P",{"data-svelte-h":!0}),p(wl)!=="svelte-mwabcx"&&(wl.innerHTML=es),pt=i(l),pl=c(l,"P",{"data-svelte-h":!0}),p(pl)!=="svelte-1a0mz1x"&&(pl.innerHTML=ns),jt=i(l),I(jl.$$.fragment,l),Ut=i(l),Ul=c(l,"P",{"data-svelte-h":!0}),p(Ul)!=="svelte-uucedl"&&(Ul.textContent=Ms),ut=i(l),I(ul.$$.fragment,l),It=i(l),Il=c(l,"P",{"data-svelte-h":!0}),p(Il)!=="svelte-1qb7iqa"&&(Il.innerHTML=as),rt=i(l),I(V.$$.fragment,l),ht=i(l),I(rl.$$.fragment,l),mt=i(l),hl=c(l,"P",{"data-svelte-h":!0}),p(hl)!=="svelte-7x1cpf"&&(hl.textContent=os),Ct=i(l),I(ml.$$.fragment,l),dt=i(l),Cl=c(l,"P",{"data-svelte-h":!0}),p(Cl)!=="svelte-1mgo9hh"&&(Cl.textContent=is),ft=i(l),Q=c(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p(Q)!=="svelte-gzxax6"&&(Q.innerHTML=Js),bt=i(l),I(dl.$$.fragment,l),At=i(l),fl=c(l,"P",{"data-svelte-h":!0}),p(fl)!=="svelte-f48anb"&&(fl.textContent=Ts),gt=i(l),I(bl.$$.fragment,l),Bt=i(l),Al=c(l,"P",{"data-svelte-h":!0}),p(Al)!=="svelte-1wy0sx2"&&(Al.textContent=ys),qt=i(l),R=c(l,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p(R)!=="svelte-1cpx4rx"&&(R.innerHTML=cs),Zt=i(l),I(gl.$$.fragment,l),$t=i(l),Bl=c(l,"P",{"data-svelte-h":!0}),p(Bl)!=="svelte-11of2v"&&(Bl.textContent=ws),Gt=i(l),ql=c(l,"UL",{"data-svelte-h":!0}),p(ql)!=="svelte-qd51wm"&&(ql.innerHTML=ps),vt=i(l),I(Zl.$$.fragment,l),Wt=i(l),vl=c(l,"P",{}),Is(vl).forEach(s),this.h()},h(){B(n,"name","hf:doc:metadata"),B(n,"content",Rs),B(q,"class","tip"),B($,"class","tip"),B(G,"class","warning"),B(W,"class","warning"),B(Q,"class","warning"),B(R,"class","warning")},m(l,t){fs(document.head,n),e(l,j,t),e(l,J,t),e(l,T,t),r(a,l,t),e(l,M,t),r(d,l,t),e(l,w,t),e(l,U,t),e(l,E,t),e(l,N,t),e(l,Wl,t),e(l,q,t),e(l,Vl,t),r(k,l,t),e(l,Ql,t),e(l,S,t),e(l,Rl,t),e(l,Y,t),e(l,El,t),r(Z,l,t),e(l,Nl,t),e(l,X,t),e(l,kl,t),r(z,l,t),e(l,Sl,t),e(l,_,t),e(l,Yl,t),r(x,l,t),e(l,Xl,t),e(l,F,t),e(l,zl,t),r(H,l,t),e(l,_l,t),e(l,L,t),e(l,xl,t),r(D,l,t),e(l,Fl,t),e(l,$,t),e(l,Hl,t),e(l,P,t),e(l,Ll,t),r(O,l,t),e(l,Dl,t),e(l,K,t),e(l,Pl,t),e(l,G,t),e(l,Ol,t),r(ll,l,t),e(l,Kl,t),e(l,tl,t),e(l,lt,t),r(sl,l,t),e(l,tt,t),e(l,el,t),e(l,st,t),e(l,nl,t),e(l,et,t),r(Ml,l,t),e(l,nt,t),e(l,al,t),e(l,Mt,t),r(ol,l,t),e(l,at,t),e(l,il,t),e(l,ot,t),r(Jl,l,t),e(l,it,t),e(l,Tl,t),e(l,Jt,t),r(v,l,t),e(l,Tt,t),e(l,yl,t),e(l,yt,t),e(l,W,t),e(l,ct,t),r(cl,l,t),e(l,wt,t),e(l,wl,t),e(l,pt,t),e(l,pl,t),e(l,jt,t),r(jl,l,t),e(l,Ut,t),e(l,Ul,t),e(l,ut,t),r(ul,l,t),e(l,It,t),e(l,Il,t),e(l,rt,t),r(V,l,t),e(l,ht,t),r(rl,l,t),e(l,mt,t),e(l,hl,t),e(l,Ct,t),r(ml,l,t),e(l,dt,t),e(l,Cl,t),e(l,ft,t),e(l,Q,t),e(l,bt,t),r(dl,l,t),e(l,At,t),e(l,fl,t),e(l,gt,t),r(bl,l,t),e(l,Bt,t),e(l,Al,t),e(l,qt,t),e(l,R,t),e(l,Zt,t),r(gl,l,t),e(l,$t,t),e(l,Bl,t),e(l,Gt,t),e(l,ql,t),e(l,vt,t),r(Zl,l,t),e(l,Wt,t),e(l,vl,t),Vt=!0},p(l,[t]){const js={};t&2&&(js.$$scope={dirty:t,ctx:l}),Z.$set(js);const Us={};t&2&&(Us.$$scope={dirty:t,ctx:l}),v.$set(Us);const us={};t&2&&(us.$$scope={dirty:t,ctx:l}),V.$set(us)},i(l){Vt||(h(a.$$.fragment,l),h(d.$$.fragment,l),h(k.$$.fragment,l),h(Z.$$.fragment,l),h(z.$$.fragment,l),h(x.$$.fragment,l),h(H.$$.fragment,l),h(D.$$.fragment,l),h(O.$$.fragment,l),h(ll.$$.fragment,l),h(sl.$$.fragment,l),h(Ml.$$.fragment,l),h(ol.$$.fragment,l),h(Jl.$$.fragment,l),h(v.$$.fragment,l),h(cl.$$.fragment,l),h(jl.$$.fragment,l),h(ul.$$.fragment,l),h(V.$$.fragment,l),h(rl.$$.fragment,l),h(ml.$$.fragment,l),h(dl.$$.fragment,l),h(bl.$$.fragment,l),h(gl.$$.fragment,l),h(Zl.$$.fragment,l),Vt=!0)},o(l){m(a.$$.fragment,l),m(d.$$.fragment,l),m(k.$$.fragment,l),m(Z.$$.fragment,l),m(z.$$.fragment,l),m(x.$$.fragment,l),m(H.$$.fragment,l),m(D.$$.fragment,l),m(O.$$.fragment,l),m(ll.$$.fragment,l),m(sl.$$.fragment,l),m(Ml.$$.fragment,l),m(ol.$$.fragment,l),m(Jl.$$.fragment,l),m(v.$$.fragment,l),m(cl.$$.fragment,l),m(jl.$$.fragment,l),m(ul.$$.fragment,l),m(V.$$.fragment,l),m(rl.$$.fragment,l),m(ml.$$.fragment,l),m(dl.$$.fragment,l),m(bl.$$.fragment,l),m(gl.$$.fragment,l),m(Zl.$$.fragment,l),Vt=!1},d(l){l&&(s(j),s(J),s(T),s(M),s(w),s(U),s(E),s(N),s(Wl),s(q),s(Vl),s(Ql),s(S),s(Rl),s(Y),s(El),s(Nl),s(X),s(kl),s(Sl),s(_),s(Yl),s(Xl),s(F),s(zl),s(_l),s(L),s(xl),s(Fl),s($),s(Hl),s(P),s(Ll),s(Dl),s(K),s(Pl),s(G),s(Ol),s(Kl),s(tl),s(lt),s(tt),s(el),s(st),s(nl),s(et),s(nt),s(al),s(Mt),s(at),s(il),s(ot),s(it),s(Tl),s(Jt),s(Tt),s(yl),s(yt),s(W),s(ct),s(wt),s(wl),s(pt),s(pl),s(jt),s(Ut),s(Ul),s(ut),s(It),s(Il),s(rt),s(ht),s(mt),s(hl),s(Ct),s(dt),s(Cl),s(ft),s(Q),s(bt),s(At),s(fl),s(gt),s(Bt),s(Al),s(qt),s(R),s(Zt),s($t),s(Bl),s(Gt),s(ql),s(vt),s(Wt),s(vl)),s(n),C(a,l),C(d,l),C(k,l),C(Z,l),C(z,l),C(x,l),C(H,l),C(D,l),C(O,l),C(ll,l),C(sl,l),C(Ml,l),C(ol,l),C(Jl,l),C(v,l),C(cl,l),C(jl,l),C(ul,l),C(V,l),C(rl,l),C(ml,l),C(dl,l),C(bl,l),C(gl,l),C(Zl,l)}}}const Rs='{"title":"Function Calling with Inference Providers","local":"function-calling-with-inference-providers","sections":[{"title":"Defining Functions","local":"defining-functions","sections":[],"depth":2},{"title":"Handling Functions in Chats","local":"handling-functions-in-chats","sections":[],"depth":2},{"title":"Multiple Functions","local":"multiple-functions","sections":[],"depth":2},{"title":"Additional Configuration","local":"additional-configuration","sections":[{"title":"Provider Selection","local":"provider-selection","sections":[],"depth":3},{"title":"Tool Choice Options","local":"tool-choice-options","sections":[],"depth":3},{"title":"Strict Mode","local":"strict-mode","sections":[],"depth":3},{"title":"Streaming Responses","local":"streaming-responses","sections":[],"depth":3}],"depth":2},{"title":"Next Steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function Es(f){return hs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class _s extends ms{constructor(n){super(),Cs(this,n,Es,Qs,rs,{})}}export{_s as component};
