Skip to main content

select_tool

Function select_tool 

Source
pub fn select_tool(
    output: &str,
    tools: &[ToolDefinition],
) -> Result<ToolCall, ToolCallError>
Expand description

Parse raw model output and extract the first tool call.

The parser looks for the <tool_call>…</tool_call> pattern emitted by the model and validates:

  1. That a name field is present.
  2. That the name appears in tools (when tools is non-empty).
  3. That the arguments value, if present, is a valid JSON object.

On success the returned ToolCall carries a freshly generated ID.

§Errors