Skip to main content

A lightweight toolkit for storing, running, and evaluating LLM prompts.

Project description

PromptVault

Python License

PromptVault is a lightweight Python SDK for tracking LLM prompt evaluations locally. You define the metrics. PromptVault tracks how they evolve.

Install

pip install PromptSafeAI

The package installs as PromptSafeAI but imports as promptvault:

from promptvault import experiment, run, evaluate

Quickstart

from promptvault import experiment, run, evaluate

with experiment(name="summarizer-test", model="claude-sonnet-4-6", vars={"text": text}):
    result = run("summarize")
    evaluate(result, {"under_100_words": lambda r: len(r.split()) < 100})
    print(result["response"])
→ experiment 'summarizer-test' started (fc5dbdd6)
  run ba5089cd | claude-sonnet-4-6 | 60in 38out | 720ms | $0.000750
  score | under_100_words: True
✓ experiment 'summarizer-test' complete

How it works

An experiment locks in a model and a vars dict. Every run inside it uses the same inputs, so comparisons across prompt versions and models are actually meaningful.

A run loads a prompt, calls the API, and auto-captures everything it returns: response, token counts, latency, cost, and stop reason. You write nothing to log these.

evaluate() runs your metric functions against the response and stores each result in a local SQLite file (promptvault.db). The metrics are yours — booleans, numbers, strings, whatever you decide "better" means.

Prompt files

Prompts live as plain text files in prompts/:

prompts/
  summarize.txt          # user template (required)
  summarize.system.txt   # system template (optional)

Templates use {{var}} placeholders, filled from the experiment's vars:

Summarize the following text in 2-3 sentences: {{text}}

Git tracks your prompt history; PromptVault tracks which runs used which version (via prompt_hash).

Querying your results

promptvault.db is plain SQLite. Query it however you like.

How a metric evolved across prompt versions:

SELECT r.prompt_hash, s.value
FROM runs r JOIN scores s ON s.run_id = r.run_id
WHERE r.prompt_name = 'summarize' AND s.metric_name = 'under_100_words'
ORDER BY r.timestamp;

How the same prompt performs across models:

SELECT r.model, s.metric_name, s.value
FROM runs r JOIN scores s ON s.run_id = r.run_id
WHERE r.prompt_name = 'summarize'
ORDER BY r.model;

Configuration

Two optional environment variables:

  • PROMPTVAULT_HOME — anchor prompts/ and promptvault.db to one directory instead of the current working directory. Set this when your app runs from varying locations.
  • PROMPTVAULT_RATES — path to a JSON file of per-token rates that extends or overrides the built-in cost table ({"model-id": {"input": 0.000003, "output": 0.000015}}). Models with no rate data record cost_usd as NULL — never a fake 0.0.

API keys come from the environment: ANTHROPIC_API_KEY for Claude models, OPENAI_API_KEY for GPT models.

Why not X

  • DeepEval / RAGAS — opinionated built-in metrics, not yours.
  • LangSmith / Braintrust — cloud services with accounts; not local.
  • Rolling your own logger — no structure, and a combinatorial mess once you try to compare versions × models × metrics.

Roadmap

  • v1.1 — LLM-as-judge built-in evaluator.
  • v1.2 — pytest plugin so evals run in CI.
  • v1.3 — CLI command to print an evolution table in the terminal.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptsafeai-0.2.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptsafeai-0.2.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file promptsafeai-0.2.0.tar.gz.

File metadata

  • Download URL: promptsafeai-0.2.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for promptsafeai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ceb1d5f14745db90e8ba4d0fb786f0a68df181bede42f720478fcad4179394ad
MD5 06b51a2f30a9f4c40de1e6f0e8ef77bb
BLAKE2b-256 54b765bfec9173ca3aca09c3ca6d60768486e9cfaf181cad04a6ead987af5f65

See more details on using hashes here.

File details

Details for the file promptsafeai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: promptsafeai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for promptsafeai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6210935d7cc9e7f8c681c84607cd9990c268510906ab0cb5a29b88932c11ad81
MD5 582ea2350491c8400b7ede35e02ac9fe
BLAKE2b-256 6215c2c4d2c99df2f6800c10d563b7d0e212b521192626a3165781d75c390150

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page