Message

sealed interface Message(source)

Represents a message exchanged in a chat with LLM. Messages can be categorized by their type and role, denoting the purpose and source of the message.

Represents both a message from LLM and a message to LLM from user or environment.

Inheritors

Types

Link copied to clipboard
data class Assistant(val content: String, val metaInfo: ResponseMetaInfo, val mediaContent: MediaContent? = null, val finishReason: String? = null) : Message.Response

Represents a message generated by the assistant as a response.

Link copied to clipboard
sealed interface Request : Message

Represents a request message in the chat.

Link copied to clipboard
sealed interface Response : Message

Represents a response message in the chat.

Link copied to clipboard

Defines the role of the message in the chat (e.g., system, user, assistant, tool).

Link copied to clipboard
data class System(val content: String, val metaInfo: RequestMetaInfo) : Message.Request

Represents a system-generated message.

Link copied to clipboard
sealed interface Tool : Message

Represents messages exchanged with tools, either as calls or results.

Link copied to clipboard
data class User(val content: String, val metaInfo: RequestMetaInfo, val mediaContent: List<MediaContent> = emptyList()) : Message.Request

Represents a message sent by the user as a request.

Properties

Link copied to clipboard
abstract val content: String

The content of the message.

Link copied to clipboard

Stores metadata information for the current message instance, such as token count and timestamp.

Link copied to clipboard
abstract val role: Message.Role

The role associated with the message.