StreamTextResult

class StreamTextResult(sourceStream: Flow<StreamEvent>, val request: LanguageModelRequestMetadata = LanguageModelRequestMetadata(), initialResponse: LanguageModelResponseMetadata = LanguageModelResponseMetadata())(source)

Streaming generation result — memoised replay. A terminal upstream run is collected at most once; later collectors replay the captured events. If every collector leaves before the upstream reaches a terminal state, that producer is cancelled, its partial buffer is discarded, and a later collector starts a fresh upstream run. To preserve full replay for a collector that attaches after the first event, the result keeps the terminal stream event sequence in memory for the result lifetime. Hosts that need minimum peak memory for a guaranteed single-consumer path can collect the model stream directly instead of using this replaying result surface.

Streaming has no default deadline. High-level callers should set CallConfig.timeout, and low-level callers should configure the underlying HTTP/on-device engine socket timeout, so a dead SSE or local engine stream cannot wait forever.

Since

0.3.0-beta01

Constructors

Link copied to clipboard
constructor(sourceStream: Flow<StreamEvent>, request: LanguageModelRequestMetadata = LanguageModelRequestMetadata(), initialResponse: LanguageModelResponseMetadata = LanguageModelResponseMetadata())

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Response metadata captured from the stream. Collecting this flow drains fullStream to terminal completion if the stream has not completed yet.

Link copied to clipboard
Link copied to clipboard

Warnings captured from the stream. Collecting this flow drains fullStream to terminal completion if the stream has not completed yet.

Functions

Link copied to clipboard
fun toUiMessageStream(assistantMessageId: String): Flow<UIMessage>
Link copied to clipboard