Assistant

data class Assistant @JvmOverloads constructor(val parts: List<MessagePart.ResponsePart>, val metaInfo: ResponseMetaInfo, val finishReason: String? = null, val rawResponse: JsonObject? = null, val id: String? = null) : Message(source)

An assistant-role message returned by the LLM. May contain text, reasoning, and/or tool calls.

Constructors

Link copied to clipboard
constructor(parts: List<MessagePart.ResponsePart>, metaInfo: ResponseMetaInfo, finishReason: String? = null, rawResponse: JsonObject? = null, id: String? = null)
constructor(part: MessagePart.ResponsePart, metaInfo: ResponseMetaInfo, finishReason: String? = null, rawResponse: JsonObject? = null, id: String? = null)

Convenience constructor that wraps a single MessagePart.ResponsePart in a list.

constructor(content: String, metaInfo: ResponseMetaInfo, finishReason: String? = null, rawResponse: JsonObject? = null, id: String? = null)

Convenience constructor that creates a MessagePart.Text from a raw string.

Properties

Link copied to clipboard

The reason the LLM stopped generating (e.g. "stop", "tool_calls"), or null if unknown.

Link copied to clipboard
open override val id: String?

Optional unique identifier for the message.

Link copied to clipboard
open override val metaInfo: ResponseMetaInfo

Response metadata including token counts and timestamp.

Link copied to clipboard
open override val parts: List<MessagePart.ResponsePart>

The response parts (text, reasoning, tool calls) produced by the LLM.

Link copied to clipboard

The raw JSON response body from the provider, or null if not captured.

Link copied to clipboard
open override val role: Message.Role

The role associated with the message.

Functions

Link copied to clipboard
open fun textContent(): String

Extracts and concatenates the textual content from all MessagePart.Text elements in the message. Messages are joined by a newline character ("\n").

open fun textContent(separator: String): String

Extracts and concatenates the textual content from all MessagePart.Text elements in the message.

Link copied to clipboard

Converts a Message.Assistant 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.