Package-level declarations

Types

Link copied to clipboard
class IncompleteStreamException(message: String = "Stream completed without receiving an End frame", cause: Throwable? = null) : Exception

Signals that a streaming response terminated without receiving a StreamFrame.End frame.

Link copied to clipboard
sealed interface StreamFrame

Represents a frame of a streaming response from a LLM.

Link copied to clipboard

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

Link copied to clipboard

Represents an error that can occur during buildStreamFrameFlow operations.

Functions

Link copied to clipboard

Builds a Flow of StreamFrame objects. Should be used only in case model does not produce completion events.

Link copied to clipboard

Collects the textual content of a Flow of StreamFrame objects and returns it as a single string.

Link copied to clipboard
suspend fun FlowCollector<StreamFrame>.emitEnd(finishReason: String? = null, metaInfo: ResponseMetaInfo? = null)

Emits a StreamFrame.End with the given finishReason.

Link copied to clipboard
suspend fun FlowCollector<StreamFrame>.emitReasoningComplete(id: String? = null, text: String, summary: String? = null, encrypted: String? = null, index: Int? = null)
suspend fun FlowCollector<StreamFrame>.emitReasoningComplete(id: String? = null, text: List<String>, summary: List<String>? = null, encrypted: String? = null, index: Int? = null)

Emits a StreamFrame.ReasoningComplete with the given text.

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

Emits a StreamFrame.ReasoningDelta with the given text and summary.

Link copied to clipboard
suspend fun FlowCollector<StreamFrame>.emitTextComplete(text: String, index: Int? = null)

Emits a StreamFrame.TextComplete with the given text.

Link copied to clipboard
suspend fun FlowCollector<StreamFrame>.emitTextDelta(text: String, index: Int? = null)

Emits a StreamFrame.TextDelta with the given text.

Link copied to clipboard
suspend fun FlowCollector<StreamFrame>.emitToolCallComplete(id: String?, name: String, content: String, index: Int? = null)

Emits a StreamFrame.ToolCallComplete with the given id, name and content.

Link copied to clipboard
suspend fun FlowCollector<StreamFrame>.emitToolCallDelta(id: String?, name: String?, content: String?, index: Int? = null)

Emits a StreamFrame.ToolCallDelta with the given id, name and content.

Link copied to clipboard

Returns a transformed flow of StreamFrame.TextDelta objects that contains only the textual content.

Link copied to clipboard

Ensures that the stream contains a StreamFrame.End frame before completing.

Link copied to clipboard

Builds a Flow of StreamFrame objects.

Link copied to clipboard

Create a Flow of StreamFrame.TextDelta objects from a list of String content.

Link copied to clipboard

Extracts the assistant response from frames, if any.

Link copied to clipboard
Link copied to clipboard

Extracts the reasoning response from frames, if any.

Link copied to clipboard

Converts a list of Message.Response to a list of StreamFrame. Final StreamFrame.End is also emitted.

Converts a Message.Response to a list of StreamFrame. First it emits the delta frames for each content part for each message, then complete frame with the full message content.

Link copied to clipboard

Extracts only tool calls from frames.