A SQLite response cache with TTL, model namespaces, exact matching, and opt-in lexical similarity.
Built as a focused AI engineering lab: inspectable algorithms, deterministic examples, and explicit failure behavior. Runs offline with the Python standard library. No API keys, model downloads, or paid services.
git clone https://github.com/izzyfrm/prompt-vault.git
cd prompt-vault
python -m prompt_vault put "qwen:prompt-v1" "What is BM25?" "A lexical ranking algorithm."
python -m prompt_vault get "qwen:prompt-v1" "What is BM25?"Requires Python 3.11 or newer. Commands run from the repository root and work in PowerShell, bash, and zsh. An editable install with python -m pip install -e . also exposes the prompt-vault command; direct module execution needs no installation.
Prompt → whitespace normalization → SHA-256 key → namespace isolated SQLite storage → TTL check → exact hit or optional cosine similarity over word counts. Writes use transactions and parameterized SQL. Expired entries are excluded immediately and physically removed with prune.
Place this before a local inference call. Cache only responses you explicitly consider reusable. A cache miss returns null; the library never invokes a provider or spends money.
See the checked demo output. It comes from the quickstart command and is a small fixture demonstration, not a performance benchmark.
python -m unittest discover -s tests -vTests cover core behavior and edge cases. GitHub Actions runs the suite on Python 3.11, 3.12, and 3.13. Local verification is recorded in VALIDATION.md.
Similarity is lexical, not semantic or embedding based. Similar wording can have opposite meanings; keep exact matching for correctness sensitive workloads. Namespaces must include every factor that changes an answer, including model, system prompt revision, generation settings, tenant, and relevant context. Cached responses are plaintext; do not store secrets. Similarity lookup scans all live rows in a namespace.
| Path | Purpose |
|---|---|
prompt_vault.py |
Importable implementation and CLI |
tests/ |
Behavioral and failure case tests |
examples/ |
Reproducible demonstration artifacts |
pyproject.toml |
Package metadata and console entry point |
Evidence Search · Eval Forge · Prompt Vault · Drift Radar · Route Lab
MIT. See LICENSE.