Skip to main content

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 {} 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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for templens 0.1.0
File Size Uploaded Provenance Actions
templens-0.1.0.tar.gz 4.4 kB Without provenance Details for templens-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for templens 0.1.0
File Interpreter ABI Platform Actions
templens-0.1.0-py3-none-any.whl Python 3 none any Details for templens-0.1.0-py3-none-any.whl

Total release size: 9.4 kB

Release files / templens-0.1.0.tar.gz

Download URL templens-0.1.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
184007f319205c6de952d9717b43d40249bc86a26c8f86796187f3d9bdf2ade5
BLAKE2b-256 checksum
How to use checksums
9ac0033d554c4404a03ddcdd32868026ce1f552019b8a025e4b1686c3e80e2c7
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.0-py3-none-any.whl

Download URL templens-0.1.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcf68fe2d3864e05eedf77bc9689e29ee7df7b0420623bc6b0e538be6170e3c5
BLAKE2b-256 checksum
How to use checksums
c79042ab93730620aa5fc04dd40f00e69a640bb5d117387684a8c6c1cf639409
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.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page