TokenEvent

sealed interface TokenEvent(source)

Events emitted by a streaming text-generation engine (e.g. Flow<TokenEvent>).

Inheritors

Types

Link copied to clipboard
data class Completed(val tokenCount: Int, val stopReason: StopReason) : TokenEvent

Generation finished. This is the last event emitted.

Link copied to clipboard
data class Error(val exception: InferenceException) : TokenEvent

An error reported in-band. If terminal, no further events follow.

Link copied to clipboard
data class Token(val index: Int, val tokenId: Int, val text: String) : TokenEvent

A generated token.