Skip to main content

Module sse

Module sse 

Source
Expand description

Reading the Azure Server-Sent Events stream: one line at a time, and far enough into a response to know which parser the rest of it belongs to.

Structsยง

ClassifiedResponse ๐Ÿ”’
The head of an Azure response, read far enough to know which parser the rest of it belongs to.

Enumsยง

AzureStreamEvent ๐Ÿ”’
One Azure SSE event name, classified once instead of by a separate &str match in each parser that reacts to it.
ParsedResponseLine ๐Ÿ”’

Constantsยง

ALL_EXPECTED_EVENTS ๐Ÿ”’
Azure events that no parser needs to react to, or that some parser handles while another legitimately sees them. An event outside this list is logged as unexpected, so a name Azure starts sending has to be added here even when nothing acts on it.

Functionsยง

classified ๐Ÿ”’
The classification, once the round is known, failing if Azure never named the response.
detect_response_kind ๐Ÿ”’
Reads the head of lines until it is clear whether the round is a tool call or a text answer, and hands the rest of the stream on to the parser that suits it.
parser_for_item ๐Ÿ”’
Which parser the rest of the round belongs to, going by the item it just announced, or None for an item that says nothing about it.
sse_field ๐Ÿ”’
The value of an SSE field, or None when the line is a different field. The space after the colon is optional in the SSE grammar, so a data:{...} line carries an item like any other.