PromptBuilder

A builder class for creating prompts using a DSL approach.

PromptBuilder allows constructing prompts by adding different types of messages (system, user, assistant, tool) in a structured way.

Example usage:

val prompt = prompt("example-prompt") {
system("You are a helpful assistant.")
user("What is the capital of France?")
}

Functions

Link copied to clipboard
fun assistant(finishReason: String? = null, rawResponse: JsonObject? = null, id: String? = null, init: ResponseMessagePartsBuilder.() -> Unit): PromptBuilder

Adds an assistant message to the prompt using a TextContentBuilder.

fun assistant(parts: List<MessagePart.ResponsePart>, finishReason: String? = null, rawResponse: JsonObject? = null, id: String? = null): PromptBuilder

Adds an assistant message to the prompt.

Link copied to clipboard
fun build(): Prompt

Builds and returns a Prompt object from the current state of the builder.

Link copied to clipboard

Adds a generic message to the prompt.

Link copied to clipboard

Adds multiple messages to the prompt.

Link copied to clipboard
fun reasoning(content: String, id: String? = null, summary: String? = null, encrypted: String? = null): PromptBuilder
Link copied to clipboard
fun system(cache: CacheControl? = null, init: TextContentBuilder.() -> Unit): PromptBuilder

Adds a system message to the prompt using a TextContentBuilder.

fun system(content: String, cache: CacheControl? = null): PromptBuilder

Adds a system message to the prompt.

Link copied to clipboard
Link copied to clipboard
fun toolResult(tool: String, output: String, id: String? = null, isError: Boolean = false): PromptBuilder
Link copied to clipboard

Adds a user message to the prompt with attachments.

Adds a user message to the prompt with optional attachments.

fun user(content: String, cache: CacheControl? = null): PromptBuilder

Adds a user message to the prompt.