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?")
}

Types

Link copied to clipboard
inner class ToolMessageBuilder

Builder class for adding tool-related messages to the prompt.

Functions

Link copied to clipboard

Adds an assistant message to the prompt using a TextContentBuilder.

fun assistant(content: String)

Adds an assistant message to the prompt.

Link copied to clipboard
fun message(message: Message)

Adds a generic message to the prompt.

Link copied to clipboard
fun messages(messages: List<Message>)

Adds multiple messages to the prompt.

Link copied to clipboard
fun system(init: TextContentBuilder.() -> Unit)

Adds a system message to the prompt using a TextContentBuilder.

fun system(content: String)

Adds a system message to the prompt.

Link copied to clipboard

Adds tool-related messages to the prompt using a ToolMessageBuilder.

Link copied to clipboard
fun user(init: TextContentBuilder.() -> Unit)

Adds a user message to the prompt using a TextContentBuilder.

fun user(content: String)

Adds a user message to the prompt.