Templens
Templens is a lightweight Python library for validating named variables in LLM prompt templates before sending them to a model.
Install
pip install templens
Quick start
from templens import Prompt
prompt = Prompt("Explain {topic} using {context}")
result = prompt.validate(
variables={
"topic": "RAG",
"context": "Retrieval Augmented Generation",
}
)
print(result.is_valid) # True
print(result.missing_variables) # []
Missing variables and names not used by the template both make the result invalid:
result = prompt.validate(variables={"topic": "RAG"})
print(result.is_valid) # False
print(result.missing_variables) # ['context']
print(result.unexpected_variables) # []
ValidationResult also exposes provided_variables, and its string form
provides a human-readable summary. Escaped braces ({{ and }}) are treated as
literal text. Templates must use named fields; automatic positional fields such
as {} and numbered positional fields such as {0} raise
PromptTemplateError.
Development
uv sync --extra dev
uv run pytest
uv run ruff check .
Templens does not connect to an LLM and has no runtime dependencies.
Metadata
Release files for templens 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| templens-0.1.1.tar.gz | 4.6 kB | Without provenance | Details for templens-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| templens-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for templens-0.1.1-py3-none-any.whl |
Total release size: 9.6 kB
Release files / templens-0.1.1.tar.gz
| Download URL | templens-0.1.1.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fa1a4f07db485ba2ec0ffb0639450178b49f8466da913c3edb41155c5ea9f68
|
|
BLAKE2b-256 checksum How to use checksums |
3a99eb943f2901e5da38cab4ced6ac528ae74c056d92e578dfc3ac733cf51c26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.3
|
Release files / templens-0.1.1-py3-none-any.whl
| Download URL | templens-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
820b5e21a8700f0bec43e8c716b35f349285c7d757104af9329466041df6388f
|
|
BLAKE2b-256 checksum How to use checksums |
21337f575dd2dfa87d5d50757d6e0dc807ec1bedcda093e503d90981b22ba641
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.3
|
Security for templens 0.1.1
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.