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?")
}Content copied to clipboard
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
Adds a generic message to the prompt.
Link copied to clipboard
Adds multiple messages to the prompt.
Link copied to clipboard
Adds a system message to the prompt using a TextContentBuilder.
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.
Adds a user message to the prompt.