Skip to main content

YAML-powered prompt manager with multi-backend support

Project description

Prompt Gear

🧠 YAML-powered prompt manager with multi-backend support

Prompt Gear is a flexible prompt management tool that can be embedded into any Python application (LangGraph, LangChain, FastAPI, etc.). It supports multiple storage backends and provides both CLI and Python SDK interfaces.

✨ Features

  • Multi-backend storage: Filesystem (YAML), SQLite, PostgreSQL
  • YAML-based prompt format: Human-readable and version-controllable
  • File input support: Create prompts from files for better organization
  • Advanced version management: Sequence-based versioning with explicit latest tracking
  • Dual interface: CLI tool + Python SDK
  • Flexible configuration: System prompts, user prompts, and custom config
  • Environment-based config: Use .env files for backend configuration
  • Robust data integrity: Transaction-based operations with automatic rollback
  • uv + pyproject.toml: Modern Python packaging ready for PyPI

🚀 Quick Start

Installation

pip install prompt-gear

Initialize in your project

# Initialize with filesystem backend (default)
promptgear init --backend filesystem

# Initialize with SQLite backend
promptgear init --backend sqlite

# Initialize with PostgreSQL backend
promptgear init --backend postgres

Create a prompt

# Direct input
promptgear create chatbot_greeting --version v1 \
  --system "You are a helpful assistant that speaks politely." \
  --user "Hello! How can I help you? {{user_input}}" \
  --config '{"temperature": 0.7, "max_tokens": 512}'

# File input for complex prompts
promptgear create complex_chatbot \
  --system-file system_prompt.txt \
  --user-file user_template.txt \
  --config-file config.yaml

# Mix file and direct input
promptgear create hybrid_prompt \
  --system-file detailed_system.txt \
  --user "Simple user message: {{input}}" \
  --config '{"temperature": 0.5}'

Use in Python

from promptgear import PromptManager

pm = PromptManager()
prompt = pm.get_prompt("chatbot_greeting", "v1")

print(prompt.system_prompt)
print(prompt.user_prompt)
print(prompt.config["temperature"])

📁 YAML Format

Prompts are stored in YAML format:

name: chatbot_greeting
version: v1
system_prompt: >
  You are a helpful assistant that speaks politely.
user_prompt: >
  Hello! How can I help you? {{user_input}}
config:
  temperature: 0.7
  max_tokens: 512

🔧 Configuration

Configure via .env file:

# Filesystem backend
PROMPT_GEAR_BACKEND=filesystem
PROMPT_GEAR_PROMPT_DIR=./prompts

# SQLite backend
PROMPT_GEAR_BACKEND=sqlite
PROMPT_GEAR_DB_URL=sqlite:///prompts.db

# PostgreSQL backend
PROMPT_GEAR_BACKEND=postgres
PROMPT_GEAR_DB_URL=postgresql://user:pass@localhost/prompts

� Version Management

Prompt Gear uses an advanced sequence-based versioning system:

Version Sequence Numbers

  • Each prompt version gets an auto-incrementing sequence number
  • Sequence numbers are maintained independently per prompt name
  • Deleted versions don't affect sequence numbering (e.g., v1→v2→v4 after deleting v3)

Latest Version Tracking

  • Each prompt has exactly one version marked as "latest"
  • Creating a new version automatically updates the latest flag
  • Deleting the latest version automatically promotes the highest sequence number version

Examples

# Create versions - sequence numbers auto-assigned
v1 = pm.create_prompt("example", "v1", "System v1", "User v1")  # seq=1, latest=True
v2 = pm.create_prompt("example", "v2", "System v2", "User v2")  # seq=2, latest=True

# v1 is automatically marked as not latest
v1_updated = pm.get_prompt("example", "v1")  # seq=1, latest=False

# Get latest version without specifying version
latest = pm.get_prompt("example")  # Returns v2

# Delete latest version
pm.delete_prompt("example", "v2")
new_latest = pm.get_prompt("example")  # Returns v1 (automatically promoted)

�📚 CLI Commands

  • promptgear init - Initialize Prompt Gear with backend selection
  • promptgear create - Create a new prompt (automatically becomes latest)
  • promptgear get - Get a prompt (latest version if version not specified)
  • promptgear list - List all prompts with their latest versions
  • promptgear delete - Delete a prompt version (auto-promotes new latest)
  • promptgear versions - List all versions of a prompt
  • promptgear status - Show backend status and statistics

🧩 Python SDK

from promptgear import PromptManager

# Initialize
pm = PromptManager()

# Create prompt (automatically gets sequence number and latest flag)
prompt = pm.create_prompt(
    name="my_prompt",
    version="v1",
    system_prompt="You are helpful.",
    user_prompt="{{user_input}}",
    config={"temperature": 0.8}
)

# Get latest version (no version specified)
latest = pm.get_prompt("my_prompt")

# Get specific version
specific = pm.get_prompt("my_prompt", "v1")

# List prompts (returns latest versions)
prompts = pm.list_prompts()

# List all versions of a prompt
versions = pm.list_versions("my_prompt")

# Update prompt
pm.update_prompt("my_prompt", "v1", system_prompt="Updated system prompt")

# Delete prompt version
pm.delete_prompt("my_prompt", "v1")  # Latest flag auto-managed

🏗️ Development Status

Currently in Phase 3 development:

  • ✅ Basic schema and filesystem backend
  • ✅ Core PromptManager functionality
  • ✅ CLI interface with backend selection
  • ✅ SQLite backend with structured storage
  • ✅ PostgreSQL backend with connection pooling
  • ✅ Advanced version management with sequence numbers
  • ✅ Robust data integrity and transaction support
  • ✅ Comprehensive test coverage across all backends
  • ⏳ Advanced features and optimizations (Phase 4)
  • ⏳ PyPI packaging (Phase 4)

📄 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

prompt_gear-0.1.0b1.tar.gz (67.9 kB view details)

Uploaded Source

Built Distribution

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

prompt_gear-0.1.0b1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file prompt_gear-0.1.0b1.tar.gz.

File metadata

  • Download URL: prompt_gear-0.1.0b1.tar.gz
  • Upload date:
  • Size: 67.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for prompt_gear-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 c2660960e52d77e00e74296bba5dda621797556dd7e8707e76cfb19aab1f8a00
MD5 fe7be3069a1d217fdad3f63eaf82a680
BLAKE2b-256 0753df1cd611a1898a55f9f9b706b8e0d6e61d40513bc1280c2d8f775942e304

See more details on using hashes here.

File details

Details for the file prompt_gear-0.1.0b1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for prompt_gear-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 75ad231ce8383cfbe311e522336f3f38933158582a6e0dcee73e10d772c6c6e7
MD5 026b90632b6022b81b629a87fc820951
BLAKE2b-256 03d45c1bc5bb0ef5423423e916835bc57ecbcbf062b94128d2059baf0f7fde68

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