Role
The role of a message sender in a chat conversation.
Roles determine how the LLM treats each message. Standard roles include:
System — Sets the model's behavior and personality.
User — Input from the human user.
Assistant — Responses from the model.
Tool — Results returned by tool execution.
For providers that use non-standard role names, use custom to create a custom role, or simply instantiate Role directly.
Serializes to/from lowercase JSON strings (e.g. "system", "user").
Parameters
value
The role name as a string.
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