Skip to main content

Prompt version control system built on SQLite

Project description

PromptHub

Prompt version control system built on SQLite. Store, version, diff, and roll back LLM prompts — no external services required.

from prompthub import Storage

store = Storage("prompts.db")
prompt = store.create_prompt("my-prompt")
prompt.add_version([("system", "You are helpful."), ("user", "Hello")])

Installation

pip install prompthub                    # core only — zero dependencies
pip install prompthub[langchain]         # + LangChain adapter
pip install prompthub[openai]            # + OpenAI tokenizer
pip install prompthub[anthropic]         # + Anthropic tokenizer
pip install prompthub[huggingface]       # + HuggingFace tokenizer
pip install prompthub[all]              # everything

Features

  • Version control — every add_version() stores a compact diff (Insert/Delete/Replace operations); full snapshots every N versions
  • Rollback — soft rollback (new version with old content) or hard rollback (delete history)
  • Diff — line diff, char diff, structured message diff between any two versions
  • Tags — label prompts with custom PromptTag values; filter with a boolean DSL
  • Token counting & cost estimation — attach model tags, count tokens, compute cost per 1M tokens from OpenRouter tariffs
  • LangChain adapter — wrap any Prompt in LangChainPromptAdapter to work with ChatPromptTemplate
  • Zero dependencies — SQLite only; LLM integrations are optional extras

Quick Start

from prompthub import Storage, PromptTag
from prompthub.core.tokenizers.openai_tag import OpenAIModelTag

store = Storage("prompts.db")

# Create prompt with initial version
prompt = store.create_prompt(
    "assistant",
    messages=[("system", "You are concise."), ("user", "Hi!")],
    tags=[PromptTag("production")],
    model_tags=[OpenAIModelTag("gpt-4o")],
)

# Add a new version
prompt.add_version([("system", "You are very concise."), ("user", "Hi!")])

# Diff two versions
diff = prompt.compare_versions_structured(1, 2)

# Soft rollback to version 1 (creates version 3)
prompt.rollback(target_seq=1)

# Fetch latest content as raw messages
messages = store.fetch_prompt("assistant")

# Fetch and work with LangChain
from prompthub.adapters import LangChainPromptAdapter
lc = LangChainPromptAdapter(store.get_prompt("assistant"))
template = lc.get_version_content(2)   # -> ChatPromptTemplate

Project Structure

prompthub/
├── __init__.py              # Public API: Storage, Prompt, PromptGroup, PromptTag, ModelTag
├── adapters/                # High-level adapters (user-facing)
│   └── langchain.py         # LangChainPromptAdapter
├── facade/
│   ├── storage.py           # Storage — main entry point
│   ├── prompt.py            # Prompt — versions, tags, diff, rollback
│   └── prompt_group.py      # PromptGroup — bulk queries
├── core/
│   ├── domain/              # Domain models: operations, diff, tags, tariffs
│   ├── adapters/            # LLM serializers: LangChainAdapter + registry
│   └── tokenizers/          # Token counting: OpenAI, Anthropic, HuggingFace
├── infrastructure/
│   ├── pricing_gateway.py   # Fetch tariffs from OpenRouter API
│   └── tariff_manager.py    # Write tariffs to DB
├── repository/              # SQL layer: PromptRepo, query DSL, schema
└── search/
    └── filters.py           # Boolean filter DSL: FieldEquals, TagFilter, ...

License

MIT

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

prompthub_my-0.1.1.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

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

prompthub_my-0.1.1-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file prompthub_my-0.1.1.tar.gz.

File metadata

  • Download URL: prompthub_my-0.1.1.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.5 Windows/11

File hashes

Hashes for prompthub_my-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e5d42de3216342d5b253e5fdd27c923836170fd8766b2024fe856221aaefc695
MD5 e8ab1a99b57967abf96a8ceeabd42195
BLAKE2b-256 8810c64f9abc86dd8ac1d9f0aa45fbc18baa023d08284de71b58ffbb41198b1e

See more details on using hashes here.

File details

Details for the file prompthub_my-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: prompthub_my-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.5 Windows/11

File hashes

Hashes for prompthub_my-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea748cfc3c8bb0058e7814b000b49d5d5891440c2b0a1cad0992014d9d80f2ec
MD5 2bfa1841671c5136bbe0baf8d05b0197
BLAKE2b-256 27f9b10932d7b826804e8e93a59ec54018be51839082048aefc419b4397be4a3

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