Expand description
§Prompt Template Engine
Versioned, variable-interpolated prompt templates with built-in A/B testing.
§Overview
- Templates — named prompt blueprints with
{{variable}}placeholders, optional system prompts, and version tags. - Registry — hot-reloadable store for all templates; load from TOML.
- A/B Experiments — route traffic between template variants, collect per-variant latency and quality metrics, and determine winners via a two-proportion Z-test.
§Quick start
use tokio_prompt_orchestrator::templates::{PromptTemplate, TemplateRegistry};
use std::collections::HashMap;
let registry = TemplateRegistry::new();
let t = PromptTemplate::builder("summarise")
.version("v2")
.system("You are a concise summariser.")
.body("Summarise the following in {{max_words}} words or fewer:\n\n{{text}}")
.tag("summarisation")
.build();
registry.register(t);
let mut vars = HashMap::new();
vars.insert("max_words", "50");
vars.insert("text", "The quick brown fox…");
let rendered = registry.render("summarise", &vars).unwrap();
println!("{rendered}");Structs§
- AbExperiment
- An A/B experiment that routes traffic between template variants.
- Experiment
Report - A point-in-time report for an A/B experiment.
- Experiment
Variant - A single variant in an A/B experiment.
- Prompt
Template - A versioned prompt template with variable placeholders.
- Template
Builder - Fluent builder for
PromptTemplate. - Template
Registry - Thread-safe registry of named prompt templates.
- Variant
Metrics - Metrics collected per A/B variant.
- Variant
Report
Enums§
- Template
Error - Template lookup errors.