Skip to main content

Prompt Manager

Prompt Manager is a flexible system for managing and processing prompt templates for use with language models. It simplifies the process of loading, managing, and formatting prompts, allowing you to focus on developing your AI applications.

Features

  • Load prompts from text files or direct text input
  • Insert variables into prompts using double braces {{variable}}
  • Handle various file types and encoding issues with a universal file opener
  • Flexible API for ease of use

Installation

Install the package using pip:

pip install prompt_manager

Usage

Basic Usage

To load and process a template named example_template with no dependencies:

from prompt_manager import PromptManager

# Initialize the PromptManager with the path to the prompts folder
pm = PromptManager("path/to/prompts/folder")

# Load a prompt template and insert variables
prompt = pm.get_prompt("example_template.txt", name="John Doe", age=30)
print(prompt)

Using Direct Text Prompts

To use a direct text prompt and replace placeholders with direct values:

from prompt_manager import PromptManager

pm = PromptManager()

# Use a direct text prompt
prompt = pm.get_prompt("Hello, {{name}}!", name="Alice")
print(prompt)

Loading File Content as Variables

To load and process a template and replace placeholders with the content of other files:

from prompt_manager import PromptManager

pm = PromptManager("path/to/prompts/folder")

# Load a prompt template and insert file content as variables
prompt = pm.get_prompt("example_template.txt", variable1=pm.load_file("sub_template1.txt"), variable2=pm.load_file("sub_template2.txt"))
print(prompt)

Exception Handling

  • Raises FileNotFoundError if the template file does not exist.
  • Raises ValueError if required placeholders are not provided or if there are issues with file dependencies.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

If you have suggestions for improvements, feel free to submit a pull request or open an issue.

Contact

Author: Bryan Anye
Email: bryan.anye.5@gmail.com
GitHub: BryanNsoh

Metadata

Release files for llm-prompt-manager 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-prompt-manager 0.1.2
File Size Uploaded
llm_prompt_manager-0.1.2.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-prompt-manager 0.1.2
File Interpreter ABI Platform
llm_prompt_manager-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / llm_prompt_manager-0.1.2.tar.gz

Download URL llm_prompt_manager-0.1.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8e97aaf6622a166b15cf279e12cb75b79f4d5401b4e446ebe951aee2a1fdc710
BLAKE2b-256 checksum
How to use checksums
c6030592e8f8113d5653891058ff4408c1bd723703c7cba72477d3dd2d534158
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.2

Release files / llm_prompt_manager-0.1.2-py3-none-any.whl

Download URL llm_prompt_manager-0.1.2-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0ed3d70d4c2383c1ba226b91be9b7a8e26ab4f67624f67f16b40b1e43c6fba4
BLAKE2b-256 checksum
How to use checksums
95d836e102f084d8c19392a48999f609cfc0f02899d99beb794ce24b05b0b220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page