Functions§
- ends_
with_ partial_ token - Check if a buffer ends with a partial occurrence of a token Returns Some(length) if there’s a partial match, None otherwise
- ensure_
capacity - Ensure arrays have capacity for the given tool ID
- find_
common_ prefix - Find the common prefix of two strings Used for incremental argument streaming when partial JSON returns different intermediate states
- get_
tool_ indices - Get a mapping of tool names to their indices
- get_
unstreamed_ args - Get unstreamed tool call arguments Returns tool call items for arguments that have been parsed but not yet streamed This ensures tool calls are properly completed even if the model generates final arguments in the last chunk
- is_
complete_ json - Check if a string contains complete, valid JSON
- normalize_
arguments_ field - Normalize the arguments/parameters field in a tool call object. If the object has “parameters” but not “arguments”, copy parameters to arguments.
- normalize_
name_ field - Normalize the name/tool_name field in a tool call object. If the object has “tool_name” but not “name”, copy tool_name to name.
- normalize_
tool_ call_ fields - Normalize all tool call fields (both name and arguments). Combines normalize_name_field and normalize_arguments_field.
- reset_
current_ tool_ state - Reset state for the current tool being parsed (used when skipping invalid tools). This preserves the parser’s overall state (current_tool_id, prev_tool_call_arr) but clears the state specific to the current incomplete tool.
- reset_
parser_ state - Reset the entire parser state (used at the start of a new request). Clears all accumulated tool calls and resets all state to initial values.