Skip to main content

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

Metadata

Release files for prompthub-my 0.4.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 prompthub-my 0.4.0
File Size Uploaded Provenance Actions
prompthub_my-0.4.0.tar.gz 24.3 kB Without provenance Details for prompthub_my-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prompthub-my 0.4.0
File Interpreter ABI Platform Actions
prompthub_my-0.4.0-py3-none-any.whl Python 3 none any Details for prompthub_my-0.4.0-py3-none-any.whl

Total release size: 61.2 kB

Release files / prompthub_my-0.4.0.tar.gz

Download URL prompthub_my-0.4.0.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ce6ee9ac5d17ba1bbbd3d42232aa5e80b3836e087fbb864feed63b92776b7b10
BLAKE2b-256 checksum
How to use checksums
6f0c641118fa70ce63434a1eb8f2d6f6e27a3d9ab8ba9f9cf2eaa02898eee4fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.4 CPython/3.13.5 Windows/11

Release files / prompthub_my-0.4.0-py3-none-any.whl

Download URL prompthub_my-0.4.0-py3-none-any.whl
Size 37.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
575b73a48e053442cfe26be71c31454ba72af0d90b7a9ecfe828d0d3d0bde54e
BLAKE2b-256 checksum
How to use checksums
77977fe8954f4c6e935e96cf8936de04cf693e12a7ab701a2fceee944007bc74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.4 CPython/3.13.5 Windows/11

Security for prompthub-my 0.4.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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