A very simple prompt management tool
Project description
Welcome to the Simple Prompt Manager! ✨
This is a very simple and lightweight library designed for managing and generating text prompts based on templates, particularly useful in generative AI projects. It supports loading templates from text files and creating them at runtime, allowing for dynamic text generation by replacing placeholders with specified values. This makes it an ideal tool for applications that require flexible and dynamic prompt generation, such as chatbots, content creation tools, and other AI-driven applications.
Installation
Install it using pip:
pip install simple-prompt-manager
Usage
Basic Usage
Initialize the PromptManager and generate a prompt using a runtime template:
from promptmanager import PromptManager
# Initialize the PromptManager
pm = PromptManager()
# Add a new template at runtime
pm.add_template("greeting", "Hello, <<name>>! Welcome to the PromptManager.")
# Generate a prompt
prompt = pm.generate_prompt("greeting", name="Alice")
print(prompt) # Output: Hello, Alice! Welcome to the PromptManager.
Using a Custom Templates Directory
Create a custom directory for your templates and load them:
import os
from promptmanager import PromptManager
# Create a custom directory for templates
custom_dir = "my_templates"
os.makedirs(custom_dir, exist_ok=True)
# Initialize the PromptManager with the custom directory
pm = PromptManager(templates_dir=custom_dir)
# Add a template file manually in the custom directory
with open(os.path.join(custom_dir, "farewell.txt"), "w") as file:
file.write("Goodbye, <<name>>! See you soon.")
# Load templates from the custom directory
pm.templates = pm._load_templates()
# Generate a prompt from the file-based template
prompt = pm.generate_prompt("farewell", name="Bob")
print(prompt) # Output: Goodbye, Bob! See you soon.
Examples
You can find an example script demonstrating how to use this package with Queen song lyrics in the examples directory. The basic_usage.py script covers adding templates at runtime and generating prompts inspired by songs like "Bohemian Rhapsody", "We Will Rock You", and "Another One Bites the Dust".
Changelog
For a detailed list of changes and updates, please refer to the CHANGELOG.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 simple_prompt_manager-0.1.3.tar.gz.
File metadata
- Download URL: simple_prompt_manager-0.1.3.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d753f88a6f2e126dad73213c0e014c45ed88a5ad53500c9b920abf999db8a6c0
|
|
| MD5 |
bd1a34b1faa33859ad439a55e41f91a4
|
|
| BLAKE2b-256 |
6aff35db26bd6da1270de322896be1aa7d7f9e66261ec4bc2d5f70fdd7fbfdb2
|
File details
Details for the file simple_prompt_manager-0.1.3-py3-none-any.whl.
File metadata
- Download URL: simple_prompt_manager-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdb15fa5d98701aa3f4a525b8ca0682aff65a2ab87e48e83e51a6adb4dd77229
|
|
| MD5 |
87a72b03dafc3c3ba420933c5684e915
|
|
| BLAKE2b-256 |
91180fbaee9a980c68ab7a8e84131c5addeb8f7707bdb0143a9f84796df8ccd0
|