Metadata-Version: 2.4
Name: llm-prompt-engine
Version: 1.1.0
Summary: Safe LLM prompt templating with validation guards
Author-email: Yao Xu <yaoxu@example.com>
License: MIT
Project-URL: Homepage, https://github.com/yaohuay/prompt-template-engine
Project-URL: Repository, https://github.com/yaohuay/prompt-template-engine
Keywords: template,LLM,prompt,templating,validation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# 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

```bash
pip install prompt-template-engine
```

## Quick Start

```python
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.

```python
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 name
- `min_length` / `max_length`: String length constraints
- `regex`: Regular expression pattern
- `choices`: Allowed string values
- `validator`: Custom validation function

### `TemplateTemplate`

A reusable template with name, body, and associated guards.

## License

MIT
