prompt

fun prompt(id: String, params: LLMParams = LLMParams(), build: PromptBuilder.() -> Unit): Prompt(source)

Creates a new prompt using the Prompt DSL.

This function allows creating a prompt with a specific ID and parameters.

Example:

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

Return

A new Prompt object

Parameters

id

The identifier for the prompt

params

The parameters for the language model

build

The initialization block for the PromptBuilder


fun prompt(existing: Prompt, build: PromptBuilder.() -> Unit): Prompt(source)

Extends an existing prompt using the Prompt DSL.

This function allows adding more messages to an existing prompt.

Example:

val basePrompt = prompt("base-prompt") {
system("You are a helpful assistant.")
}

val extendedPrompt = prompt(basePrompt) {
user("What is the capital of France?")
}

Return

A new Prompt object based on the existing one

Parameters

existing

The existing prompt to extend

build

The initialization block for the PromptBuilder