You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

prompt-hot-reloading

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prompt-hot-reloading

Hot-reloadable prompt library for Python apps

0.1.4
pipPyPI
Maintainers
1

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 support fs (file system) and s3 (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

  • github/steventkrawczyk
  • linkedin/steventkrawczyk
  • x/KrawfyS

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

MIT

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.