Skip to content

About

SQLite response caching with TTL, model namespaces, and opt-in lexical similarity. Fully offline.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Prompt Vault

A SQLite response cache with TTL, model namespaces, exact matching, and opt-in lexical similarity.

tests Python License

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.

Run it

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.

How it works

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.

Where it fits

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.

Example output

See the checked demo output. It comes from the quickstart command and is a small fixture demonstration, not a performance benchmark.

Verify

python -m unittest discover -s tests -v

Tests 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.

Limitations and tradeoffs

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.

Project layout

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

Related labs

Evidence Search · Eval Forge · Prompt Vault · Drift Radar · Route Lab

License

MIT. See LICENSE.

About

SQLite response caching with TTL, model namespaces, and opt-in lexical similarity. Fully offline.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages