Skip to main content

:::note Generated reference Generated from honeyframeapi 0.1.8 — do not edit by hand. :::

Helpers

Functions importable from honeyframeapi whose implementation lives in a private module. Import them from the package, not from the module.

collect_stream()​

collect_stream(events: Iterable[dict]) -> dict

Fold a stream of SSE events into one final result dict.

The Python analogue of the web reducer's terminal state — drain a HoneyframeClient.stream_chat / Agent.ask_stream generator into a single answer when you don't need token-by-token rendering:

result = collect_stream(agent.ask_stream("Top 5 branches by revenue?"))
print(result["text"])

Returns {text, thinking, tool_calls, citations, artifact, usage, stop_reason, error}. tool_calls pairs each tool_start with its matching tool_result summary; error is set if the stream errored.

parse_sse_frames()​

parse_sse_frames(buffer: str) -> tuple[list[dict], str]

Split buffer into complete SSE events, returning (events, rest).

Each event is {"event": <name>, "data": <parsed json>}. rest is any trailing partial frame (no terminating blank line yet) to prepend to the next chunk. Comment/heartbeat frames (no data: line) and non-JSON data payloads are skipped — matching the web parser exactly. Line endings are normalised first; a trailing \r is held back in rest in case the next chunk starts with its \n.


Verified against honeyframeapi 0.1.8.