Skip to main content

attach_tools

Function attach_tools 

Source
pub fn attach_tools(
    body: &mut Value,
    tools: &Option<Vec<ToolDefinition>>,
    native_function_calling: bool,
)
Expand description

Attach tool definitions to a chat-completion request body.

When native_function_calling is true and tools are present, sets:

  • body.tools = the JSON-serialized tool definitions
  • body.tool_choice = "auto"

When native_function_calling is false, tools are still attached to the request body so backends that auto-detect them can use them, but tool_choice is omitted (the model is expected to emit XML in content instead, prompted by the system message).

When tools is None, this is a no-op.