nemoguardrails.server.experimental.provider.sse
Parse Server-Sent Events without provider-specific knowledge.
The parser preserves complete upstream events byte-for-byte while exposing the event type and joined data fields needed by provider adapters.
Module Contents
Classes
Functions
API
Bases: ValueError
Report SSE bytes that common clients interpret differently.
Represent one complete SSE event.
Return joined SSE data fields, or None when none are present.
Return the last SSE event field, or None when it is absent.
Event field and comment lines without line endings.
Original event bytes, including its terminating blank line when supplied by the upstream server.
Create an event while retaining its original representation.
Parameters:
Exactly one complete SSE block, without stream-start BOM handling.
Returns: ServerSentEvent
The parsed event representation.
Bases: ValueError
Report an SSE event that exceeds the configured buffering limit.
Bases: ValueError
Report an unfinished SSE block containing fields at end of stream.
Yield complete SSE blocks from arbitrary HTTP byte chunks.
Preserve raw bytes, including an initial BOM ignored only for field parsing. Drop unfinished comment tails; reject all other unfinished field blocks.
Parameters:
Raw upstream response byte stream.
Maximum bytes buffered for one event.
Raises:
ValueError: Ifmax_event_bytesis not positive.ServerSentEventTooLarge: If one event exceeds the limit.TruncatedServerSentEvent: If the stream ends in an unfinished field block.AmbiguousServerSentEvent: If a line after stream start begins with a BOM.