Message

@Serializable
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
@Serializable
data class Assistant(val content: String, val finishReason: String? = null) : Message.Response

Represents a message generated by the assistant as a response.

Link copied to clipboard
@Serializable
sealed interface Request : Message

Represents a request message in the chat.

Link copied to clipboard
@Serializable
sealed interface Response : Message

Represents a response message in the chat.

Link copied to clipboard
@Serializable
enum Role : Enum<Message.Role>

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

Link copied to clipboard
@Serializable
data class System(val content: String) : Message.Request

Represents a system-generated message.

Link copied to clipboard
@Serializable
sealed interface Tool : Message

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

Link copied to clipboard
@Serializable
data class User(val content: String) : 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
abstract val role: Message.Role

The role associated with the message.