Chat
An immutable conversation container holding a list of Message objects and a model name.
This is the primary data structure for representing a chat session. It can be created manually or via the io.kory.core.dsl.chat.koryChat DSL builder.
Samples
// Creating chat using dsl.
val chat = koryChat(
// Model name: String(required)
model = "gpt-5.6-sol"
) {
// Messages
user("Hello, what's your name?") // Message from user(text)
assistant("Hello, i'm ChatGPT sol. How can I help?") // Message from assistant(text)
// Message from user(parts)
user {
text("What do you see in the photo?") // Add Text(String)
image(ImageSource.FilePath("path/to/photo.jpg")) // Add Image(ImageSource)
}
}Content copied to clipboard
// Creating chat without dsl.
val chat = Chat(
// Model name: String(required)
model = "gpt-5.6-sol",
// Messages: List<Message>(required)
messages = listOf(
Message(
role = Role.User,
content = Content.Text("Hello, what's your name?")
),
Message(
role = Role.Assistant,
content = Content.Text("Hello, i'm ChatGPT sol. How can I help?")
),
Message(
role = Role.User,
// Parts. List<ContentPart>(Required)
content = Content.Parts(
listOf(
ContentPart.Text("What do you see in the photo?"),
ContentPart.Image(ImageSource.FilePath("path/to/photo.jpg"))
)
)
),
)
)Content copied to clipboard
Properties
Functions
Link copied to clipboard
Returns a copy of this chat with additional messages appended.
Link copied to clipboard
fun asChatRequest(temperature: Double? = null, maxTokens: Int? = null, topK: Int? = null, reasoning: ReasoningConfig? = null, tools: ToolsBuilder.() -> Unit): ChatRequest
Converts this chat into a ChatRequest with tools defined via DSL.
fun asChatRequest(temperature: Double? = null, maxTokens: Int? = null, topK: Int? = null, reasoning: ReasoningConfig? = null, tools: List<ChatTool> = emptyList()): ChatRequest
Converts this chat into a ChatRequest with optional generation parameters.