Skip to main content

Lightweight prompt version control.

Project description

📝 py-prompt-versioner

License: MIT Python: 3.9+ Built with: uv

Stop copy-pasting 500-line f-strings. py-prompt-versioner is a lightweight utility designed for AI engineers who want to treat their prompts like code. Store prompts in Markdown, version them properly, and inject variables with ease.


✨ Features

  • Frontmatter Metadata: Store model settings (temperature, model name) directly within the prompt file.
  • Jinja2 Templating: Support for complex variable injection, loops, and logic.
  • Strict Validation: Powered by Pydantic to ensure your metadata is always correct.
  • CLI First: Bootstrap your prompt directory structure in one command.
  • Path-Agnostic: Works seamlessly across Windows, Mac, and Linux.

🚀 Installation

Install via pip:

pip install py-prompt-versioner

or using uv for lightning-fast-setup:

uv add py-prompt-versioner

🛠 Quick Start

  1. Initialize your project Use the CLI to create your prompt directory structure.
# Creates a default /prompts folder
prompt-versioner init

# Or specify a custom path
prompt-versioner init --path ./my_ai_assets
  1. Create a prompt file Your prompts live in .md files with YAML frontmatter. Example: prompts/sample_task/v1.md
---
version: "v1"
model: "gpt-4o"
temperature: 0.7
---

Act as a professional editor. Summarize the following text: {{ text }}

📖 Usage Guide

Integrate py-prompt-versioner into your Python workflow to load and render prompts dynamically.

from prompt_versioner import PromptManager

# 1. Initialize the manager with your prompts directory
pm = PromptManager(path="./prompts")

# 2. Load and render a specific version with variables
result = pm.get_prompt(
    task_name="sample_task",
    version="v1",
    variables={"text": "The quick brown fox jumps over the lazy dog."}
)

# 3. Use the result
print(f"Using model: {result['metadata'].model}")
print(f"Prompt: {result['content']}")

📂 Project Structure

A typical setup using py-prompt-versioner looks like this:

.
├── prompts/
│   ├── classification/
│   │   ├── v1.md
│   │   └── v2.md
│   └── summarization/
│       └── base.md
├── main.py
└── pyproject.toml

⚙️ How it Works

Component Responsibility
CLI Scaffolding and directory management
Frontmatter Parsing metadata (YAML) from Markdown files
Pydantic Validating metadata structure and types
Jinja2 Handling variable injection and logic

🤝 Contributing

Contributions are welcome! If you have a feature request or found a bug, please open an issue or submit a pull request on GitHub.

  1. Fork the repo.
  2. Clone it locally.
  3. Submit a PR with your changes. Pssss, don't forget to ruff your codes!

📄 License

Distributed under the MIT License. See LICENSE for more information.

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

py_prompt_versioner-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

py_prompt_versioner-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_prompt_versioner-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for py_prompt_versioner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e8f31ad6b9b4ea968720b5ee0515950611cfe335615ceaea0e58070322f9d938
MD5 071c5fb20f18087aa616bca13123f0d6
BLAKE2b-256 3ec110bd05db6ba936afab53223acbba03575e105db2fb35f2b9783d364150f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_prompt_versioner-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for py_prompt_versioner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01e1f1bf6cdf0f2390060417e86c8511d52bbee5a2101696d8d024b792d04276
MD5 8166e98b38291ac2d6b7c214dee2249a
BLAKE2b-256 dc7cdee10f26fe5591ec5edbf5c77301bab8c6d0779096ffcc1d2c3671a46371

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