Gemini.SSE.Parser (GeminiEx v0.0.1)
View SourceServer-Sent Events (SSE) parser for streaming responses.
Handles partial chunks and maintains state across multiple calls. Properly parses SSE format with incremental data.
Summary
Functions
Extract text content from a streaming event.
Finalize parsing and return any remaining events in buffer.
Create a new SSE parser state.
Parse incoming SSE chunk and return events + updated state.
Check if an event indicates the stream is done.
Types
Functions
Extract text content from a streaming event.
Finalize parsing and return any remaining events in buffer.
Call this when the stream is complete to get any final partial events.
@spec new() :: t()
Create a new SSE parser state.
@spec parse_chunk(String.t(), t()) :: parse_result()
Parse incoming SSE chunk and return events + updated state.
Examples
iex> parser = SSE.Parser.new()
iex> chunk = "data: {\"text\": \"hello\"}
"
iex> {:ok, events, new_parser} = SSE.Parser.parse_chunk(chunk, parser)
iex> length(events)
1
Check if an event indicates the stream is done.