Skip to main content

Module tools

Module tools 

Source
Expand description

Tool calling: format detection and per-model response parsing.

Prompt formatting is handled by HuggingFace chat templates (the tools variable is passed to the template engine). This module handles the output side: detecting and parsing tool calls from model responses in various formats.

Enums§

ToolCallFormat
Tool-call output format used by a model family.

Functions§

extract_text_content
Extract text content from response, removing Qwen3 tool call XML tags.
extract_text_content_for_format
Extract text content from response, removing tool call markers for the given format.
has_qwen35_xml_tool_calls
Detect whether text contains Qwen3.5 XML parameter-style tool calls.
has_tool_calls
Check if text contains Qwen3 tool calls.
has_tool_calls_for_format
Check if text contains tool calls in the given format.
parse_llama_tool_calls
Parse Llama 3.1+ tool calls.
parse_mistral_tool_calls
Parse Mistral tool calls.
parse_qwen3_tool_calls
Parse Qwen3 XML tool calls from model output and convert to OpenAI format.
parse_qwen35_xml_tool_calls
Parse Qwen3.5 XML parameter-style tool calls from model output.
parse_tool_calls_for_format
Parse tool calls from model output using the given format.