StreamFrameFlowBuilder

Represents a wrapper around a FlowCollector that provides methods for emitting StreamFrame objects.

This is mainly used for combining chunked tool calls and only emit completed tool calls.

Constructors

Link copied to clipboard
constructor(flowCollector: FlowCollector<StreamFrame>)

Functions

Link copied to clipboard
suspend fun emitEnd(finishReason: String? = null, metaInfo: ResponseMetaInfo? = null)

Emits a StreamFrame.End with the given finishReason.

Link copied to clipboard
suspend fun emitReasoningDelta(id: String? = null, text: String? = null, summary: String? = null, index: Int? = null)

Emits a StreamFrame.ReasoningDelta with the given text.

Link copied to clipboard
suspend fun emitTextDelta(text: String, index: Int? = null)

Emits a StreamFrame.TextDelta with the given text.

Link copied to clipboard
suspend fun emitToolCallDelta(id: String? = null, name: String? = null, args: String? = null, index: Int? = null)

Updates the coroutine context to signal we're currently combining a tool call, this does not emit anything yet, that happens only in tryEmitPendingToolCall.

Link copied to clipboard

Emits a pendingReasoningRef if it exists and then clears it.

Link copied to clipboard
suspend fun tryEmitPendingText()

Emits a pendingTextRef if it exists and then clears it.

Link copied to clipboard

Emits a pendingToolCallRef if it exists and then clears it.