Render captured prompt templates without reloading sources

This commit is contained in:
2026-09-30 03:24:12 +00:00
parent ba9c972faa
commit d818e0d162
6 changed files with 264 additions and 4 deletions

View File

@@ -2,6 +2,18 @@ package prompt
import "text/template"
// CompiledTemplates is the immutable parsed template set for one captured
// prompt. Callers must not mutate its templates after handing it to a renderer.
type CompiledTemplates struct {
Session *template.Template
Messages []*template.Template
}
// TemplateLookup provides parsed templates for a captured prompt identity.
type TemplateLookup interface {
GetCompiledTemplates(id, version string) (CompiledTemplates, bool)
}
// CompileTemplate checks static syntax with the same grammar and function
// names as rendering, without evaluating request inputs or variables.
func CompileTemplate(name, raw string) (*template.Template, error) {