Prompt Template Engine
A Python template engine designed for safe LLM prompt management with built-in validation guards and variable constraints.
Features
- Template Registration: Register named templates with validation guards
- Variable Guards: Enforce min/max length, regex patterns, choices, and custom validators
- Safe Rendering: Automatic variable substitution with error checking
- Random Rendering: Pick random templates for A/B testing or variety
- Template Lookup: Check existence and list all registered templates
Installation
pip install prompt-template-engine
Quick Start
from prompt_template_engine import TemplateEngine, GuardCondition
engine = TemplateEngine()
engine.add_template("hello", "Hello, {name}!", {"name": GuardCondition(name="name", min_length=1)})
result = engine.render("hello", {"name": "World"})
# Returns: "Hello, World!"
API Reference
TemplateEngine
The main engine class for registering and rendering templates.
engine = TemplateEngine()
engine.add_template(name, template_str, guards)
engine.render(name, variables)
engine.has_template(name)
engine.get_template(name)
engine.list_templates()
engine.random()
engine.random_render(variables)
GuardCondition
A dataclass defining validation rules for template variables:
name: Variable namemin_length/max_length: String length constraintsregex: Regular expression patternchoices: Allowed string valuesvalidator: Custom validation function
TemplateTemplate
A reusable template with name, body, and associated guards.
License
MIT
Metadata
Release files for llm-prompt-engine 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_prompt_engine-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for llm_prompt_engine-1.1.0-py3-none-any.whl |
Release files / llm_prompt_engine-1.1.0-py3-none-any.whl
| Download URL | llm_prompt_engine-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d3a5c143bbb10c9a847ca9ecfd1dd03fa97d96e71c7a1d8ef1d869ca28382ed
|
|
BLAKE2b-256 checksum How to use checksums |
88de18aac753a9f39f27b3ee5d07b9245366ac894875e9b040db3d83757c673c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for llm-prompt-engine 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.