ccproxy.streaming.sse_parser¶
ccproxy.streaming.sse_parser
¶
Helpers for incrementally parsing server-sent events (SSE).
SSEStreamParser
¶
Accumulate SSE fragments and yield decoded data: payloads.
The parser keeps track of partial lines and events across feed calls so
callers can push raw provider chunks (str or bytes) and only receive
payloads when a full SSE event has been received. data: [DONE] sentinel
events are filtered out automatically.
Source code in ccproxy/streaming/sse_parser.py
feed
¶
Process a streaming fragment and return decoded JSON payloads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
str | bytes | None
|
Raw chunk from the provider. |
required |
Returns:
| Type | Description |
|---|---|
list[Any]
|
List of decoded JSON payloads for completed events. |
list[Any]
|
sentinels are omitted. |
Source code in ccproxy/streaming/sse_parser.py
flush
¶
Return any buffered payload when the stream ends.
Source code in ccproxy/streaming/sse_parser.py
consume_errors
¶
Return and clear parsing errors captured since the last call.