ChatChunkChoice

@Serializable
data class ChatChunkChoice(val index: Int, val content: Content.StreamResponse, val finishReason: String? = null)

A single choice within a streaming io.kory.core.chat.chunk.ChatChunk.

Unlike ChatChoice which holds a complete list of contents, this holds a single incremental Content.StreamResponse item — either a Content.Text fragment, Content.Reasoning fragment, or Content.ToolCallDelta.

See also

Samples

// We formulate the printMessage based on the content.
val printMessage: String = when (val content = chunkChoice.content) {
    is Content.Reasoning -> "Reasoning chunk: $content"
    is Content.Text -> "Output chunk: $content"
    is Content.ToolCallDelta -> "Tool call delta chunk: $content"
}

// Print information about the chunk.
println("Chunk index: ${chunkChoice.index}" +
        "\n$printMessage" +
        "\n${if (!chunkChoice.finishReason.isNullOrBlank()) chunkChoice.finishReason else ""}")

Constructors

Link copied to clipboard
constructor(index: Int, content: Content.StreamResponse, finishReason: String? = null)

Properties

Link copied to clipboard

The incremental content chunk for this choice.

Link copied to clipboard

Why the model stopped. null while still streaming.

Link copied to clipboard
val index: Int

The index of this choice (0-based).