prompt-gear


Nameprompt-gear JSON
Version 0.1.0b2 PyPI version JSON
download
home_pageNone
SummaryYAML-powered prompt manager with multi-backend support
upload_time2025-07-23 01:08:28
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords ai llm management prompt template
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```bash
pip install prompt-gear
```

### Initialize in your project

```bash
# 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

```bash
# 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

```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:

```yaml
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:

```env
# 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

```python
# 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

```python
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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "prompt-gear",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "AI, LLM, management, prompt, template",
    "author": null,
    "author_email": "miniGears <wenyi@wygears.com>",
    "download_url": "https://files.pythonhosted.org/packages/26/36/819610cba5e113a23f50bce7cf02a529ed13fc355557471733c835198c2b/prompt_gear-0.1.0b2.tar.gz",
    "platform": null,
    "description": "# Prompt Gear\n\n\ud83e\udde0 **YAML-powered prompt manager with multi-backend support**\n\nPrompt 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.\n\n## \u2728 Features\n\n- \u2705 **Multi-backend storage**: Filesystem (YAML), SQLite, PostgreSQL\n- \u2705 **YAML-based prompt format**: Human-readable and version-controllable\n- \u2705 **File input support**: Create prompts from files for better organization\n- \u2705 **Advanced version management**: Sequence-based versioning with explicit latest tracking\n- \u2705 **Dual interface**: CLI tool + Python SDK\n- \u2705 **Flexible configuration**: System prompts, user prompts, and custom config\n- \u2705 **Environment-based config**: Use `.env` files for backend configuration\n- \u2705 **Robust data integrity**: Transaction-based operations with automatic rollback\n- \u2705 **uv + pyproject.toml**: Modern Python packaging ready for PyPI\n\n## \ud83d\ude80 Quick Start\n\n### Installation\n\n```bash\npip install prompt-gear\n```\n\n### Initialize in your project\n\n```bash\n# Initialize with filesystem backend (default)\npromptgear init --backend filesystem\n\n# Initialize with SQLite backend\npromptgear init --backend sqlite\n\n# Initialize with PostgreSQL backend\npromptgear init --backend postgres\n```\n\n### Create a prompt\n\n```bash\n# Direct input\npromptgear create chatbot_greeting --version v1 \\\n  --system \"You are a helpful assistant that speaks politely.\" \\\n  --user \"Hello! How can I help you? {{user_input}}\" \\\n  --config '{\"temperature\": 0.7, \"max_tokens\": 512}'\n\n# File input for complex prompts\npromptgear create complex_chatbot \\\n  --system-file system_prompt.txt \\\n  --user-file user_template.txt \\\n  --config-file config.yaml\n\n# Mix file and direct input\npromptgear create hybrid_prompt \\\n  --system-file detailed_system.txt \\\n  --user \"Simple user message: {{input}}\" \\\n  --config '{\"temperature\": 0.5}'\n```\n\n### Use in Python\n\n```python\nfrom promptgear import PromptManager\n\npm = PromptManager()\nprompt = pm.get_prompt(\"chatbot_greeting\", \"v1\")\n\nprint(prompt.system_prompt)\nprint(prompt.user_prompt)\nprint(prompt.config[\"temperature\"])\n```\n\n## \ud83d\udcc1 YAML Format\n\nPrompts are stored in YAML format:\n\n```yaml\nname: chatbot_greeting\nversion: v1\nsystem_prompt: >\n  You are a helpful assistant that speaks politely.\nuser_prompt: >\n  Hello! How can I help you? {{user_input}}\nconfig:\n  temperature: 0.7\n  max_tokens: 512\n```\n\n## \ud83d\udd27 Configuration\n\nConfigure via `.env` file:\n\n```env\n# Filesystem backend\nPROMPT_GEAR_BACKEND=filesystem\nPROMPT_GEAR_PROMPT_DIR=./prompts\n\n# SQLite backend\nPROMPT_GEAR_BACKEND=sqlite\nPROMPT_GEAR_DB_URL=sqlite:///prompts.db\n\n# PostgreSQL backend\nPROMPT_GEAR_BACKEND=postgres\nPROMPT_GEAR_DB_URL=postgresql://user:pass@localhost/prompts\n```\n\n## \ufffd Version Management\n\nPrompt Gear uses an advanced sequence-based versioning system:\n\n### Version Sequence Numbers\n- Each prompt version gets an auto-incrementing sequence number\n- Sequence numbers are maintained independently per prompt name\n- Deleted versions don't affect sequence numbering (e.g., v1\u2192v2\u2192v4 after deleting v3)\n\n### Latest Version Tracking\n- Each prompt has exactly one version marked as \"latest\"\n- Creating a new version automatically updates the latest flag\n- Deleting the latest version automatically promotes the highest sequence number version\n\n### Examples\n\n```python\n# Create versions - sequence numbers auto-assigned\nv1 = pm.create_prompt(\"example\", \"v1\", \"System v1\", \"User v1\")  # seq=1, latest=True\nv2 = pm.create_prompt(\"example\", \"v2\", \"System v2\", \"User v2\")  # seq=2, latest=True\n\n# v1 is automatically marked as not latest\nv1_updated = pm.get_prompt(\"example\", \"v1\")  # seq=1, latest=False\n\n# Get latest version without specifying version\nlatest = pm.get_prompt(\"example\")  # Returns v2\n\n# Delete latest version\npm.delete_prompt(\"example\", \"v2\")\nnew_latest = pm.get_prompt(\"example\")  # Returns v1 (automatically promoted)\n```\n\n## \ufffd\ud83d\udcda CLI Commands\n\n- `promptgear init` - Initialize Prompt Gear with backend selection\n- `promptgear create` - Create a new prompt (automatically becomes latest)\n- `promptgear get` - Get a prompt (latest version if version not specified)\n- `promptgear list` - List all prompts with their latest versions\n- `promptgear delete` - Delete a prompt version (auto-promotes new latest)\n- `promptgear versions` - List all versions of a prompt\n- `promptgear status` - Show backend status and statistics\n\n## \ud83e\udde9 Python SDK\n\n```python\nfrom promptgear import PromptManager\n\n# Initialize\npm = PromptManager()\n\n# Create prompt (automatically gets sequence number and latest flag)\nprompt = pm.create_prompt(\n    name=\"my_prompt\",\n    version=\"v1\",\n    system_prompt=\"You are helpful.\",\n    user_prompt=\"{{user_input}}\",\n    config={\"temperature\": 0.8}\n)\n\n# Get latest version (no version specified)\nlatest = pm.get_prompt(\"my_prompt\")\n\n# Get specific version\nspecific = pm.get_prompt(\"my_prompt\", \"v1\")\n\n# List prompts (returns latest versions)\nprompts = pm.list_prompts()\n\n# List all versions of a prompt\nversions = pm.list_versions(\"my_prompt\")\n\n# Update prompt\npm.update_prompt(\"my_prompt\", \"v1\", system_prompt=\"Updated system prompt\")\n\n# Delete prompt version\npm.delete_prompt(\"my_prompt\", \"v1\")  # Latest flag auto-managed\n```\n\n## \ud83c\udfd7\ufe0f Development Status\n\nCurrently in **Phase 3** development:\n- \u2705 Basic schema and filesystem backend\n- \u2705 Core PromptManager functionality\n- \u2705 CLI interface with backend selection\n- \u2705 SQLite backend with structured storage\n- \u2705 PostgreSQL backend with connection pooling\n- \u2705 Advanced version management with sequence numbers\n- \u2705 Robust data integrity and transaction support\n- \u2705 Comprehensive test coverage across all backends\n- \u23f3 Advanced features and optimizations (Phase 4)\n- \u23f3 PyPI packaging (Phase 4)\n\n## \ud83d\udcc4 License\n\nMIT License\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "YAML-powered prompt manager with multi-backend support",
    "version": "0.1.0b2",
    "project_urls": {
        "Documentation": "https://github.com/miniGears/prompt-gear#readme",
        "Homepage": "https://github.com/miniGears/prompt-gear",
        "Issues": "https://github.com/miniGears/prompt-gear/issues",
        "Repository": "https://github.com/miniGears/prompt-gear"
    },
    "split_keywords": [
        "ai",
        " llm",
        " management",
        " prompt",
        " template"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0eb861da4e892683f752577488851c956b20ccb0d2c9a3b5d127754b59f5ef10",
                "md5": "ea1bc8ab0cfbcf60c6809614c85184d8",
                "sha256": "d918ce53a7855c8412146c7100058045e4cdf30307a9e2a88c7adf1d083fb7cb"
            },
            "downloads": -1,
            "filename": "prompt_gear-0.1.0b2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ea1bc8ab0cfbcf60c6809614c85184d8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 26698,
            "upload_time": "2025-07-23T01:08:26",
            "upload_time_iso_8601": "2025-07-23T01:08:26.713006Z",
            "url": "https://files.pythonhosted.org/packages/0e/b8/61da4e892683f752577488851c956b20ccb0d2c9a3b5d127754b59f5ef10/prompt_gear-0.1.0b2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2636819610cba5e113a23f50bce7cf02a529ed13fc355557471733c835198c2b",
                "md5": "089de1dc46bd8999a112b11b4bc87e09",
                "sha256": "7051f51882dc3e2c4c1f8ac85e214aa0cf4c896cb8a21054f970f4bfd9bf3f02"
            },
            "downloads": -1,
            "filename": "prompt_gear-0.1.0b2.tar.gz",
            "has_sig": false,
            "md5_digest": "089de1dc46bd8999a112b11b4bc87e09",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 69099,
            "upload_time": "2025-07-23T01:08:28",
            "upload_time_iso_8601": "2025-07-23T01:08:28.123964Z",
            "url": "https://files.pythonhosted.org/packages/26/36/819610cba5e113a23f50bce7cf02a529ed13fc355557471733c835198c2b/prompt_gear-0.1.0b2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-23 01:08:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "miniGears",
    "github_project": "prompt-gear#readme",
    "github_not_found": true,
    "lcname": "prompt-gear"
}
        
Elapsed time: 2.60432s