Skip to main content

Prompt Versioning and Management for GenAI

Project description

🚀 Cuebit - Prompt Versioning and Management for GenAI

Cuebit is an open-source, local-first prompt registry and version control system designed for GenAI development teams — complete with version tracking, version history, lineage tracking, aliases, tagging, and an interactive dashboard.

alt text

✨ Features

  • 🔐 Prompt version control with full history and lineage tracking
  • 🏷️ Alias system (e.g. summarizer-prod → versioned prompt)
  • 🧠 Tags and metadata for organizing prompts
  • 📁 Project & Task-based prompt grouping
  • 📋 Example management for documenting prompt usage patterns
  • 📑 Template variables detection and validation
  • 🔍 Version comparison with visual diffs
  • 📈 Streamlit-based visual dashboard
  • ⚙️ REST API powered by FastAPI (/api/v1/...)
  • 🔄 Full CLI support for automation
  • 🧪 Prompt template preview and rendering
  • 👤 Audit trail: created_at, updated_at, updated_by
  • 📤 Import/Export functionality for backup and sharing

📦 Installation

# Install from PyPI
pip install cuebit

# Or install from source
git clone https://github.com/iRahulPandey/Cuebit.git
cd cuebit
pip install -e .

🚀 Getting Started

🌱 Initializing Cuebit

# Initialize the Cuebit prompt registry
cuebit init

# Optionally specify a custom data directory
cuebit init --data-dir /path/to/your/data

Cuebit automatically stores its database in a standard user data directory. You can also set the CUEBIT_DB_PATH environment variable to specify a custom database location.

🧪 Registering a Prompt in Python

from cuebit.registry import PromptRegistry

registry = PromptRegistry()
registry.register_prompt(
    task="summarization",
    template="Summarize: {input}",
    meta={"model": "gpt-4", "temperature": 0.7},
    tags=["prod"],
    project="bloggen",
    updated_by="alice",
    examples=[{
        "input": "The quick brown fox jumps over the lazy dog.",
        "output": "A fox jumps over a dog.",
        "description": "Basic example"
    }]
)

🧭 Setting Aliases

registry.add_alias(prompt_id, "summarizer-prod")

🔁 Updating a Prompt (Creates a new version)

registry.update_prompt(
    prompt_id,
    new_template="Summarize concisely: {input}",
    updated_by="bob"
)

📋 Adding Examples

registry.add_example(
    prompt_id,
    input_text="Climate change is a global challenge...",
    output_text="Climate change poses worldwide risks requiring immediate action.",
    description="Climate topic example"
)

Using in a Streamlit App

import streamlit as st
from cuebit.registry import PromptRegistry
from langchain_openai import ChatOpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain

# Initialize registry - works with zero configuration!
registry = PromptRegistry()

# Get prompt by alias
prompt = registry.get_prompt_by_alias("summarizer-prod")

# Create LangChain PromptTemplate
prompt_template = PromptTemplate(
    input_variables=["input_text"],
    template=prompt.template
)

# Initialize LangChain ChatOpenAI model
llm = ChatOpenAI(
    model=prompt.meta.get("model", "gpt-3.5-turbo"),
    temperature=prompt.meta.get("temperature", 0.7),
    max_tokens=prompt.meta.get("max_tokens", 500)
)

# Create LLM Chain
summarization_chain = LLMChain(
    llm=llm,
    prompt=prompt_template
)

# Generate summary
summary = summarization_chain.run(input_text="Your text to summarize")

🧪 Streamlit Dashboard

cuebit serve --host 127.0.0.1 --port 8000  # launches API + UI

The dashboard provides:

  • Project and prompt browsing
  • Visual prompt builder with variable detection
  • Version history with visual diffs
  • Import/Export functionality
  • Usage statistics

🔧 Command Line Interface

# Start the server and dashboard
cuebit serve

# List all projects
cuebit list projects

# List prompts in a project
cuebit list prompts --project my-project

# Create a new prompt
cuebit create prompt --task summarization \
    --template "Summarize: {input}" \
    --project my-project --tags "prod,gpt-4"

# Set an alias
cuebit set-alias 123abc summarizer-prod

# Render a prompt with variables
cuebit render --alias summarizer-prod \
    --vars '{"input":"Text to summarize"}'

# Export prompts to JSON
cuebit export --format json --file exports.json

📚 API Reference

  • GET /api/v1/projects - List all projects
  • GET /api/v1/projects/{project}/prompts - List prompts in a project
  • GET /api/v1/prompts - List all prompts (with pagination and filtering)
  • POST /api/v1/prompts - Create a new prompt
  • GET /api/v1/prompts/{prompt_id} - Get a specific prompt
  • PUT /api/v1/prompts/{prompt_id} - Update a prompt (creates new version)
  • POST /api/v1/prompts/{prompt_id}/alias - Set an alias for a prompt
  • GET /api/v1/prompts/alias/{alias} - Get a prompt by its alias
  • POST /api/v1/prompts/render - Render a prompt with variables
  • GET /api/v1/prompts/{prompt_id}/history - Get version history
  • POST /api/v1/prompts/compare - Compare two prompt versions
  • POST /api/v1/prompts/{prompt_id}/rollback - Rollback to a previous version
  • DELETE /api/v1/prompts/{prompt_id} - Delete a prompt (soft by default)
  • GET /api/v1/export - Export prompts
  • POST /api/v1/import - Import prompts

alt text

🔍 Advanced Configuration

Environment Variables

  • CUEBIT_DB_PATH: Set a custom database location (e.g., sqlite:///path/to/your/prompts.db)

Using With Different Database Backends

Cuebit uses SQLAlchemy, so you can connect to different database backends:

# PostgreSQL example
registry = PromptRegistry("postgresql://user:password@localhost/cuebit")

# MySQL example
registry = PromptRegistry("mysql+pymysql://user:password@localhost/cuebit")

🛠️ Development

To contribute:

# Clone the repository
git clone https://github.com/iRahulPandey/Cuebit.git
cd cuebit

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Build package
python -m build

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

cuebit-0.2.1.tar.gz (50.5 kB view details)

Uploaded Source

Built Distribution

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

cuebit-0.2.1-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file cuebit-0.2.1.tar.gz.

File metadata

  • Download URL: cuebit-0.2.1.tar.gz
  • Upload date:
  • Size: 50.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for cuebit-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3852198fbb2d7ba019650291c35f1e8ad1830ffbe2df61e32bb3ffe963bf7d5f
MD5 2e68e1f3545a1389602b08ff853f7a40
BLAKE2b-256 c802fb827e84f7494e4374a57cf06715b6e15ddb8c80706f4a9f10eeadec30c8

See more details on using hashes here.

File details

Details for the file cuebit-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cuebit-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for cuebit-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d8b8e1ccbc4b682f19e3ddcbff8030c112aa5de423dd2c2262c50f6e832e65e
MD5 6721eeb50ea2e3523f980d4f2151ae90
BLAKE2b-256 b4f6cd6f6d7a2690e06a1d598d153f1b01df069a6a1bf618b13bdbe963ae0a61

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