Skip to main content

//clika-runtime/io.clika.modelverse/GenerationListener

GenerationListener

[common]
interface GenerationListener

The stream of one generation. The calls arrive in order on the model's own worker thread, never on the thread that called GenerativeModel.chat: onToken and onThinking as text is produced, then exactly one of onDone or onError. A listener that needs the main thread posts to it.

Functions​

NameSummary
onDone[common]
abstract fun onDone(report: GenerationReport)
The generation ended; report says how and what it cost.
onError[common]
abstract fun onError(message: String)
The generation failed before or during decoding; nothing follows.
onThinking[common]
open fun onThinking(text: String)
The next piece of the model's reasoning, on a model whose Capabilities.thinking is not ThinkingControl.NONE and whose channel is on for the request; never called otherwise.
onToken[common]
abstract fun onToken(text: String)
The next piece of the reply's visible text.
onToolCall[common]
open fun onToolCall(call: ToolCall)
One call the reply made, after its text and before onDone; the same calls ride GenerationReport.toolCalls. Never called when the request offered no tools.