Message
A single message in a chat conversation.
Messages consist of a Role and a Content.Request payload. Use extension functions like String.asUserMessage() for quick creation, or construct manually for full control.
See also
Samples
// All roles.
// Now supported roles: Role.USER, Role.ASSISTANT, Role.SYSTEM, Role.TOOL)
// Using roles in dsl-chat.
val dslChat = koryChat(
model = "gpt-5.6-sol"
) {
// System role.
system("You are helpful assistant.")
// User role.
user("Hello, What is the weather like in London?")
// Tool role.
tool("Current weather in London is Sunny.")
// Assistant role.
assistant("Hello, current weather in **London** is sunny. Have a nice day :)")
}
// Using roles in non-dsl chat.
val chat = Chat(
model = "gpt-5.6-sol",
messages = listOf(
Message(
role = Role.System,
content = Content.Text("You are helpful assistant.")
),
Message(
role = Role.User,
content = Content.Text("Hello, What is the weather like in London?")
),
Message(
role = Role.Tool,
content = Content.ToolResult(
toolCallId = "tool_call_id_1",
name = "get_weather",
content = "Current weather in London is Sunny.")
),
Message(
role = Role.Assistant,
content = Content.Text("Hello, current weather in **London** is sunny. Have a nice day :)")
)
)
)Content copied to clipboard