Skip to main content

Simple prompt version control for AI development

Project description

PromptVersion

Simple prompt version control for AI development

PyPI version Python 3.8+ License: MIT

PromptVersion is a lightweight tool for managing AI prompts with version control, templating, and variable injection. Think "Git for prompts" - but simpler.

Why PromptVersion?

  • 📝 Templated YAML prompts with variable injection
  • 🏷️ Semantic versioning for prompt iterations
  • 🚀 Simple CLI for prompt management
  • 🐍 Clean Python API for integration
  • 📁 No external dependencies - just files and Git

Quick Start

Installation

pip install promptversion

Initialize a repository

promptversion init

Create your first prompt

promptversion create classifier --description "Ticket classifier"

Use in Python

from promptversion import PromptVersion

pv = PromptVersion()

# Render with variables
result = pv.render("classifier", {
    "ticket": "I can't log into my account",
    "max_categories": 3
})

# Use with any LLM
import openai
response = openai.ChatCompletion.create(
    model="gpt-4",
    messages=[{"role": "system", "content": result}]
)

Features

  • Templated YAML prompts with variable injection
  • Internal version control with semantic versioning
  • Simple CLI for prompt management
  • Clean Python API for integration

Prompt Format

Prompts are stored as YAML files in the prompts/ directory:

name: "classifier"
version: "1.0.0"
description: "Classifies support tickets"

variables:
  max_categories:
    default: 5
    type: "integer"
  language:
    default: "en" 
    type: "string"

template: |
  You are a support ticket classifier.
  
  Classify this ticket into up to {{max_categories}} categories.
  Respond in {{language}}.
  
  Ticket: {{ticket}}

CLI Commands

  • promptversion init - Initialize repository
  • promptversion create <n> - Create new prompt
  • promptversion edit <n> - Edit prompt
  • promptversion commit <n> - Commit changes
  • promptversion tag <n> <tag> - Tag version
  • promptversion list - List all prompts
  • promptversion show <n> - Show prompt details
  • promptversion test <n> - Test prompt rendering
  • promptversion versions <n> - Show version history

Python API

from promptversion import PromptVersion

# Initialize
pv = PromptVersion()

# Get prompt
prompt = pv.get("classifier")

# Render with variables
result = prompt.render({"ticket": "Login issue"})

# Get specific version
prompt_v1 = pv.get("classifier", version="1.0.0")

# List all prompts
prompts = pv.list_prompts()

Development

# Clone repository
git clone https://github.com/yourusername/promptversion
cd promptversion

# Install in development mode
pip install -e .[dev]

# Run tests
pytest

# Format code
black promptversion tests

License

MIT License

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

promptversion-0.1.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

promptversion-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file promptversion-0.1.0.tar.gz.

File metadata

  • Download URL: promptversion-0.1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for promptversion-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b958392c71c03465931346d3aad0dd3d66063481c2a1139ae0e77175eb9adf9e
MD5 4dfbaade2c9ae04678195a831a691e18
BLAKE2b-256 cb802850e657fddbd41670b6d4140a4627c0ad6672f61d11da2e0017b41e4ea5

See more details on using hashes here.

File details

Details for the file promptversion-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: promptversion-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for promptversion-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b215fa7c5f14cb8a2d8eae52809e18235637cda83dc9e91d9b6b7b34cadf9b4
MD5 6511335012fcac2a350ddf0dbbfc52a2
BLAKE2b-256 936d2ce9c1ca2bfda963440ddfdf8c000f63464327c161b1d74e950abdab2558

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