Learn how to do OpenAI compatible function calling on Friendli Serverless Endpoints.
get_weather
function that retrieves weather information, ask a question that prompts the model to use the tool, and execute the tool to execute the final response.
Tool Definition
get_weather
) with a JSON Schema.location
: The location to look up weather information for.date
: The date to look up weather information for.tools
array and passed to the model.Calling the model
messages
array.tools
and messages
defined above.Execution tool
get_weather
function is executed as follows:Adding tool responses
messages
array and pass it back to the model.Generating the final response
tool_choice
, tools
, and parallel_tool_calls
parameters.
Parameter | Description | default |
---|---|---|
tool_choice | Specifies how the model should choose tools. Has four options: “none”, “auto”, “required”, or named tool choice. | auto |
tools | The list of tool objects that define the functions the model can call. | - |
parallel_tool_calls | Boolean value (True or False ) specifying whether to make tool calls in parallel. | True |
tool_choice
optionstool_choice
parameter to tell the model to use a function.
none
: Disables the use of tools.auto
: Enables the model to decide whether to use tools and which ones to use.required
: Forces the model to use a tool, but the model chooses which one.