Skip to main content

parse_sse

Function parse_sse 

Source
pub fn parse_sse(text: &str) -> (Vec<SseEvent>, usize)
Expand description

Parse SSE format text into events.

SSE format example:

  • event: response.created\ndata: {"id": "resp_123"}
  • event: response.output_text.delta\ndata: {"delta": "hello"}

Events are separated by double newlines (\n\n).

Returns (events, parse_end_position) where parse_end_position is the byte offset in text where parsing stopped (either at end of text, or after skipping an incomplete event).