Skip to main content

Module streaming_parser

Module streaming_parser 

Source
Expand description

Streaming tool-call parser — state-machine extraction from partial LLM output.

Detects <tool_call> blocks incrementally as tokens arrive, firing callbacks as soon as </tool_call> is seen. Handles malformed tags and unclosed JSON tolerantly.

Ported from hermes-rs parser.rs philosophy.

Structs§

StreamingToolCallParser
State-machine streaming parser for XML tool calls
ToolCall
A detected tool call from streaming output

Enums§

ParserEvent
Events emitted by the streaming parser

Functions§

parse_tool_calls
Convenience: parse a full (non-streaming) response containing tool_call XML.
recover_tool_calls
Split a completed response into prose and the tool calls it embedded as <tool_call> XML.