Expand description
§Prompt Template Engine
Simple {{variable}} substitution engine with filter support.
§Variable Syntax
{{var}}— plain substitution.{{var | upper}}— apply theupperfilter.{{var | lower}}— apply thelowerfilter.{{var | truncate:100}}— truncate to 100 characters.{{var | default:"fallback"}}— use"fallback"ifvaris missing.
§Example
use tokio_prompt_orchestrator::template::{
PromptTemplate, TemplateContext, TemplateValue,
};
let t = PromptTemplate::from_str("Hello, {{name | upper}}!").unwrap();
let mut ctx = TemplateContext::new();
ctx.set("name", TemplateValue::Text("world".to_string()));
let rendered = t.render(&ctx).unwrap();
assert_eq!(rendered, "Hello, WORLD!");Structs§
- Prompt
Template - A compiled prompt template.
- Template
Context - Variable bindings for template rendering.
- Template
Library - A named store of
PromptTemplates.
Enums§
- Template
Error - Errors that can occur during template parsing or rendering.
- Template
Value - A typed value that can be stored in a
TemplateContext.