A lightweight Python package for managing and organizing prompt templates with auto-discovery and variable substitution.
Project description
gs_prompt_manager
A lightweight Python package for managing and organizing prompt templates. Automatically discovers, loads, and manages prompt classes that inherit from PromptBase.
✨ Features
- 🔍 Auto-discovery: Automatically finds and loads prompt classes from specified directories
- 📦 Template Management: Define reusable prompt templates with variable substitution
- 🎯 Type Safety: Built-in validation for prompt pieces and metadata
- 🔧 Flexible: Support for both chat and system prompts
- 📝 Metadata: Rich metadata support for prompts (tags, tools, examples, etc.)
- 🔄 Predefined Macros: Support for datetime and custom macro substitution
- 🏗️ Extensible: Easy to subclass and customize for specific use cases
🚀 Quick Start
Installation
pip install gs-prompt-manager
Basic Usage
Step 1: Create a Prompt
from gs_prompt_manager import PromptBase
class GreetingPrompt(PromptBase):
"""A simple greeting prompt."""
def set_prompt_chat(self):
return "Hello, {name}! Welcome to {place}."
def set_prompt_system(self):
return "You are a friendly assistant."
def set_name(self):
self.name = "GreetingPrompt"
# Use the prompt
prompt = GreetingPrompt()
print(prompt.get_prompt_chat({"name": "Alice", "place": "Wonderland"}))
# Output: Hello, Alice! Welcome to Wonderland.
Step 2: Manage Multiple Prompts
from gs_prompt_manager import PromptManager
# Auto-discover prompts in a directory
manager = PromptManager(prompt_paths="./my_prompts")
# List available prompts
print(manager.get_prompt_names())
# Get a specific prompt
greeting = manager.get_prompt("GreetingPrompt")
result = greeting.get_prompt_chat({"name": "Bob"})
📖 Documentation
- User Guide - Complete usage guide
- Examples - Real-world integration examples
- Contributing - How to contribute
- Changelog - Version history
💡 Key Concepts
PromptBase
The base class for all prompt templates. Subclass it to create custom prompts:
class MyPrompt(PromptBase):
def set_prompt_chat(self):
return "Your template with {variables}"
def set_name(self):
self.name = "MyPrompt"
PromptManager
Automatically discovers and manages multiple prompt classes:
manager = PromptManager(prompt_paths=["./prompts", "./more_prompts"])
prompt = manager.get_prompt("MyPrompt")
Variable Substitution
Two types of variables are supported:
- Prompt Pieces -
{variable}: User-provided values - Predefined Macros -
<<MACRO>>: System-generated values
def set_prompt_chat(self):
return "User {name} logged in at <<DATETIME>>"
🎯 Use Cases
- LLM Application Development: Manage prompts for ChatGPT, Claude, etc.
- Prompt Engineering: Organize and version control prompt templates
- Multi-Agent Systems: Define prompts for different AI agents
- A/B Testing: Compare different prompt variations
- Prompt Libraries: Build reusable prompt collections
📊 Requirements
- Python 3.8+
- regex >= 2022.1.18
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
👤 Author
Guan Huang
🔗 Links
- GitHub: https://github.com/CoronRing/gs_prompt_manager
- PyPI: https://pypi.org/project/gs-prompt-manager/
- Issues: https://github.com/CoronRing/gs_prompt_manager/issues
- Documentation: https://github.com/CoronRing/gs_prompt_manager/tree/main/docs
⭐ Star History
If you find this project helpful, please consider giving it a star on GitHub!
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gs_prompt_manager-0.0.5.tar.gz.
File metadata
- Download URL: gs_prompt_manager-0.0.5.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80e1f70b68bba9251cafa65c47a3bb34c3ea2ac13c786e1bfc4f4fede50b376e
|
|
| MD5 |
4a9c5519ffc3f77fddaa633ffd08d383
|
|
| BLAKE2b-256 |
c5733bd101518369f38959b910e7414708a7bb2022e06dfe9eadf60a615a87c5
|
Provenance
The following attestation bundles were made for gs_prompt_manager-0.0.5.tar.gz:
Publisher:
publish-to-pypi.yml on CoronRing/gs_prompt_manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gs_prompt_manager-0.0.5.tar.gz -
Subject digest:
80e1f70b68bba9251cafa65c47a3bb34c3ea2ac13c786e1bfc4f4fede50b376e - Sigstore transparency entry: 971584424
- Sigstore integration time:
-
Permalink:
CoronRing/gs_prompt_manager@c9264b56332bcba88895642971cc02b59fb44a45 -
Branch / Tag:
refs/tags/V0.0.5 - Owner: https://github.com/CoronRing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@c9264b56332bcba88895642971cc02b59fb44a45 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gs_prompt_manager-0.0.5-py3-none-any.whl.
File metadata
- Download URL: gs_prompt_manager-0.0.5-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92331a6dc8965e38f5cb4325bfb723fb350cc339c984f410b89b20cf344e18f1
|
|
| MD5 |
9e145bc014f20982c47902b392eebb68
|
|
| BLAKE2b-256 |
90887ac58f74ba2059ab6e6015c76c1e8796d29a61cf085d216070151cf6a473
|
Provenance
The following attestation bundles were made for gs_prompt_manager-0.0.5-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on CoronRing/gs_prompt_manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gs_prompt_manager-0.0.5-py3-none-any.whl -
Subject digest:
92331a6dc8965e38f5cb4325bfb723fb350cc339c984f410b89b20cf344e18f1 - Sigstore transparency entry: 971584431
- Sigstore integration time:
-
Permalink:
CoronRing/gs_prompt_manager@c9264b56332bcba88895642971cc02b59fb44a45 -
Branch / Tag:
refs/tags/V0.0.5 - Owner: https://github.com/CoronRing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@c9264b56332bcba88895642971cc02b59fb44a45 -
Trigger Event:
release
-
Statement type: