Skip to main content

Module prompt

Module prompt 

Source
Expand description

Composable prompt construction with variable interpolation.

PromptTemplate supports {variable} placeholders and composable sections (persona, instructions, examples, constraints). Use PromptBuilder for fluent construction.

use daimon::prompt::PromptTemplate;

let tpl = PromptTemplate::new("You are {role}. Today is {date}.")
    .var("role", "a helpful assistant")
    .var("date", "2026-03-03");

assert_eq!(tpl.render_static(), "You are a helpful assistant. Today is 2026-03-03.");

Structs§

FewShotTemplate
A collection of input/output example pairs injected into a prompt to guide the model’s behaviour through demonstration.
PromptBuilder
Fluent builder for composing prompts from sections.
PromptTemplate
A prompt template with {variable} interpolation.

Traits§

DynamicContext
Provides a named variable value resolved at runtime (e.g. current date, user profile, database lookup).
ErasedDynamicContext
Object-safe wrapper for DynamicContext.