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.0.tar.gz (51.0 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.0-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cuebit-0.2.0.tar.gz
  • Upload date:
  • Size: 51.0 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.0.tar.gz
Algorithm Hash digest
SHA256 60826e7ce72aac26a635e4e860c6e3881959900a3e3cb258856bfdc7ce57068d
MD5 52c56cefe252a0d19aef6722c99c1edb
BLAKE2b-256 a201d6f52e7f7c362ea016f640ca8bc8bae9a5ce63488eee97eba83b5482301f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cuebit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 28.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0351df9099eceb81e92e304b75b8e1e04e37f0eb62d9bcdab0d2a3d11c6ac15
MD5 dcee16235fa91f4dc5c6a0e787901a66
BLAKE2b-256 83f3a170c5b717cabae8dfdd8a3f378e37bda523db523bff3b2e60e3c7d1e59e

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