Hot-reloadable prompt library for Python apps
Project description
Prompt Hot Reloading
Prompt hot reloading is a technique that allows you to update your prompts without restarting your application. This is useful for development and testing, as you can make changes to your prompts and see the results immediately.
Getting Started
Installation
pip install prompt-hot-reloading
Usage
The prompt registry is a simple dictionary that maps prompt names to prompt text. It listens for changes to the prompt source and updates the registry accordingly.
from prompt_hot_reloading.prompt_source.file_system_source import FileSystemSource
from prompt_hot_reloading import PromptRegistry
prompt_source = FileSystemSource("prompts")
prompt_registry = PromptRegistry(prompt_source)
def handle_message(user_message: str):
completion = client.chat.completions.create(
model="gpt-4.1",
messages=[
{"role": "developer", "content": prompt_registry["system_prompt"]},
{"role": "user", "content": user_message}
]
)
return completion.choices[0].message.content
Deployment
The create_prompt_registry function is a factory that picks the appropriate prompt source based on the PROMPT_SOURCE environment variable. Today, we support fs (file system) and s3 (S3 polling).
from prompt_hot_reloading import create_prompt_registry
prompt_registry = create_prompt_registry()
Environment Variables
PROMPT_SOURCE: The type of prompt source to use. Currently, we supportfs(file system) ands3(S3 polling).PROMPT_DIR: The path to the directory containing the prompt files.PROMPT_S3_BUCKET: The name of the S3 bucket containing the prompt files.PROMPT_S3_PREFIX: The prefix of the S3 key containing the prompt files.PROMPT_S3_POLL_INTERVAL: The interval in seconds to poll the S3 bucket for changes.
Miscellaneous
Creator
Steve Krawczyk
Contributing
Contributions are welcome! Please feel free to submit a pull request.
License
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 prompt_hot_reloading-0.1.4.tar.gz.
File metadata
- Download URL: prompt_hot_reloading-0.1.4.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1339003d8a73ab177628ae8e6576ae8d24bb774806dc1ed398723f385dddc48f
|
|
| MD5 |
1d04e1d0657b3f8e87ecd42ae04caaa7
|
|
| BLAKE2b-256 |
41102c6724fceaadbd93ac2f52d2df4c101c428410f70e885191b6b765a4af6b
|
File details
Details for the file prompt_hot_reloading-0.1.4-py3-none-any.whl.
File metadata
- Download URL: prompt_hot_reloading-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b80a5d9e5267765cc3f1ea0a0197a634bdde00d0dc9fde51c6daa477b8790f77
|
|
| MD5 |
e2fa1c6a33a32f74f3a28ba27ab43800
|
|
| BLAKE2b-256 |
b7a416ab093182cfa9579c3ec678982f4bb62be3898195b01c0e61611ef686ab
|