Skip to main content

tokenhelm-prompt

Prompt Intelligence for TokenHelm — prompt attribution, versioning, analytics, and governance for every LLM request TokenHelm tracks. Entirely additive: the TokenHelm v0.1 API is never changed.

Install

pip install tokenhelm-prompt
# optional framework integrations:
pip install "tokenhelm-prompt[langchain]"   # or llamaindex, crewai, adk, openai-agents, haystack

Quick start

from tokenhelm import TokenHelm, DefaultEventDispatcher
from tokenhelm_prompt import YamlRegistry, tracker, analytics, make_dispatcher

# 1. Register a versioned prompt (metadata + a template HASH — never the text).
registry = YamlRegistry("prompts.yaml")
registry.register(
    "invoice_summary",
    owner="ana", application="billing", environment="prod",
    template="Summarize invoice {invoice_id} for {customer}",
)
tracker.use_registry(registry)

# 2. Wrap TokenHelm's dispatcher so events get attributed (no core changes).
th = TokenHelm(dispatcher=make_dispatcher(DefaultEventDispatcher()))

# 3. Every tracked call inside the scope is attributed automatically.
with tracker.prompt("invoice_summary"):
    th.track(response)            # event recorded as invoice_summary@v1

# 4. Per-prompt / per-version analytics.
for row in analytics.by_version():
    print(row.prompt_name, row.prompt_version, row.calls, row.cost, row.failures)
analytics.export("csv", "prompts.csv")

Nested scopes, the @prompt(...) decorator, and async/streaming all work and restore correctly:

from tokenhelm_prompt import prompt

@prompt("translate")
async def translate(...): ...

with tracker.prompt("invoice"):
    with tracker.prompt("translate"):   # inner wins; outer restored on exit
        ...

CLI

tokenhelm-prompt init                       # create a local registry
tokenhelm-prompt list                       # list prompts + current versions
tokenhelm-prompt versions invoice_summary   # immutable version history
tokenhelm-prompt diff invoice_summary v1 v2 # compare by hash (never shows text)
tokenhelm-prompt export --format json -o inventory.json

Guarantees

  • No core changes — TokenHelm's track/trace/track_stream/configure/LLMEvent are untouched; integration is purely via the EventDispatcher seam.
  • Privacy — only metadata + one-way hashes are stored; never rendered prompts, keys, credentials, or PII.
  • Offline-first — the default YAML/SQLite registry needs no network.
  • Additive — with no active scope, behavior is identical to plain TokenHelm.

Release process

Releases are staged through TestPyPI before production PyPI, driven entirely by git tags. Publishing uses PyPI Trusted Publishing (OIDC) — there are no API tokens anywhere.

RC tag  ──►  TestPyPI  ──►  install + smoke test  ──►  GitHub prerelease
final tag ─►  PyPI     ──►  install + smoke test  ──►  GitHub release

A tag is classified automatically: vX.Y.Z is a production release; anything with a pre-release/dev suffix (rc, a, b, .dev — e.g. v0.2.0rc1) goes to TestPyPI. The tag version must match project.version in pyproject.toml (the workflow guards this), so bump the version first.

1. Pre-release to TestPyPI:

# bump pyproject.toml version to 0.2.0rc1 first, then:
git tag v0.2.0rc1
git push origin v0.2.0rc1

This builds, publishes to TestPyPI, installs into a clean venv from TestPyPI, runs scripts/release_smoke_test.py, and cuts a GitHub prerelease.

2. Production to PyPI:

# bump pyproject.toml version to 0.2.0 first, then:
git tag v0.2.0
git push origin v0.2.0

This builds, publishes to PyPI, installs from PyPI into a clean venv, runs the smoke test, and cuts the GitHub release with generated notes and the wheel + sdist attached.

The workflow (.github/workflows/release.yml) also supports workflow_dispatch for a build-and-check dry run (no publish). The testpypi and pypi GitHub environments must each have a Trusted Publisher configured on the respective index.


See docs/ for the architecture, full API reference, and a migration guide. The design lives under specs/001-prompt-intelligence/.

Metadata

Release files for tokenhelm-prompt 0.2.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 tokenhelm-prompt 0.2.0
File Size Uploaded Provenance
tokenhelm_prompt-0.2.0.tar.gz 21.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tokenhelm-prompt 0.2.0
File Interpreter ABI Platform
tokenhelm_prompt-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 51.4 kB

Release files / tokenhelm_prompt-0.2.0.tar.gz

Download URL tokenhelm_prompt-0.2.0.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c1fd87e40ef5498941dc0304d268043718315784c8950f8a8044d9b06fd534ef
BLAKE2b-256 checksum
How to use checksums
f0c41cc3108eaff43cf1ef3cff1dedd28e26b32a4bfc99ad7aa6093ca6eb2403
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

Release files / tokenhelm_prompt-0.2.0-py3-none-any.whl

Download URL tokenhelm_prompt-0.2.0-py3-none-any.whl
Size 30.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
911abaafd586ae0a51322223701703e2438389224a7ea3c827d7ea8ee71bb074
BLAKE2b-256 checksum
How to use checksums
e8e8fc9586b9a392c7ab4262d6082f7b756994a1debe86f8e5c2c7ccde506509
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

Security for tokenhelm-prompt 0.2.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tokenhelm_prompt-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full 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