Skip to content

[FEAT]: Add structured prompt template validation#120

Open
spencrr wants to merge 3 commits into
microsoft:mainfrom
spencrr:dev/spencrr/structured-prompt-template
Open

[FEAT]: Add structured prompt template validation#120
spencrr wants to merge 3 commits into
microsoft:mainfrom
spencrr:dev/spencrr/structured-prompt-template

Conversation

@spencrr

@spencrr spencrr commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a structured PromptTemplate model with validated YAML loading and rendering.

  • Replaces bare jinja2.Template loading with PromptTemplate.from_yaml().
  • Validates YAML through a strict private Pydantic schema.
  • Rejects missing and unexpected render arguments.
  • Verifies declared parameters against Jinja AST variables.
  • Migrates LLMDriver and LLMJudge to the structured template API.
  • Adds coverage for rendering, schema failures, parameter drift, block scalars, malformed YAML, and non-mapping YAML.

Breaking changes

load_prompt_template() has been removed in favor of PromptTemplate.from_yaml().

The loader now returns a PromptTemplate rather than a jinja2.Template; callers using Jinja-specific APIs must migrate to the structured API.

Checklist

  • pre-commit run --all-files passes
  • Tests added or updated for structured loading, rendering validation, schema failures, and raw YAML
  • Documentation updated in the prompt-template module docstring

spencrr added 3 commits July 15, 2026 14:57
Return an immutable PromptTemplate from the YAML loader, validate declared render parameters against both call arguments and the Jinja AST, and add focused unit coverage for metadata and parameter errors.
Replace manual prompt-template schema checks with a strict private Pydantic model, wrap validation failures in a domain exception, reject unknown fields and duplicate parameters, and declare Pydantic as a direct dependency.
Adds PromptTemplate.from_yaml(), private loading and compilation stages, generic uniqueness validation, explicit module exports, migrated consumers, and raw YAML coverage.
@spencrr
spencrr requested a review from a team July 15, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant