user

fun user(content: String, attachments: List<MediaContent> = emptyList())(source)

Adds a user message to the prompt with optional media attachments.

User messages represent input from the user to the language model. This method supports adding text content along with a list of media attachments such as images, audio, or documents.

Parameters

content

The content of the user message.

attachments

The list of media attachments associated with the user message. Defaults to an empty list if no attachments are provided.


fun user(content: String, block: AttachmentBuilder.() -> Unit)(source)

Adds a user message to the prompt with media attachments.

User messages represent input from the user to the language model. This method allows attaching media content like images, audio, or documents.

Example:

// Simple text message
user("What is the capital of France?")

// Message with attachments using a lambda
user("Please analyze this image") {
image("photo.jpg")
}

Parameters

content

The content of the user message

block

Optional lambda to configure attachments using AttachmentBuilder


Adds a user message to the prompt using a ContentBuilderWithAttachment.

This allows for more complex message construction with both text and attachments.

Example:

user {
text("I have a question about programming.")
text("How do I implement a binary search in Kotlin?")
attachments {
image("screenshot.png")
}
}

Parameters

body

The initialization block for the ContentBuilderWithAttachment