A powerful, lazy-loading prompt configuration manager.
Project description
**dynaprompt ** - Lazy-loading prompt configuration manager built directly on Dynaconf's principles.

DynaPrompt is a powerful, lazy-loading prompt configuration manager inspired by Dynaconf. It offers a structured way to manage, version, and render LLM prompts while separating prompt text from configuration metadata.
🚀 30-Second Quickstart
pip install dynaprompt
- Create a
prompts.toml:
[default.greeting]
template = "Hello {{ name }}! You are a helpful assistant."
[production.greeting]
template = "Hello {{ name }}! You are a professional consultant."
- Use it in Python:
from dynaprompt import DynaPrompt
prompts = DynaPrompt(settings_files=["prompts.toml"])
# Renders: "Hello Emam! You are a helpful assistant."
print(prompts.greeting.render(name="Emam").text)
💡 Why DynaPrompt?
1. Lazy Loading is the Core
Most libraries load prompts at import time. This makes environment swapping hard and slows down startup.
The "Old" Way (Hardcoded/Manual):
# Loaded once, forever. Hard to swap for tests/production.
SYSTEM_PROMPT = open("prompts/system.txt").read()
The DynaPrompt Way:
from dynaprompt import prompts
# File is only read NOW. Respects ENV_FOR_DYNAPROMPT=production automatically.
print(prompts.system.render())
2. Why not just use Dynaconf?
Since Dynaconf handles strings, why a new library? DynaPrompt adds prompt-specific logic:
- Jinja2 First-Class: Automatic variable injection, recursive flattening, and secret resolution.
- Schema Auto-loading: Automatically registers Pydantic models from
.pyfiles as response schemas. - Prompt Inheritance: Use
extendsto share model config (temperature, max_tokens) between templates. - Render State: Remembers previous variables for precise partial updates via
.rerender().
3. Comparison with others
| Feature | DynaPrompt | Prompt-Poet / Promptix | f-strings |
|---|---|---|---|
| Boilerplate | Zero (just a folder) | Medium (manual registration) | High |
| Lazy Loading | ✅ Yes | ❌ No | ❌ No |
| Env Layers | ✅ Native | ⚠️ Manual | ❌ No |
| Inheritance | ✅ Native | ❌ No | ❌ No |
| Schemas | ✅ Auto-discovery | ⚠️ Manual | ❌ No |
✨ Features
- File-based Prompt Management: Write prompt templates in clean Markdown (
.mdor.txt) with YAML frontmatter, or group multiple prompts in aprompts.tomlfile. - Auto-Discovery & Companion Files: Pass a directory like
settings_files=["prompts/"]and DynaPrompt automatically loads all.mdfiles. It also auto-discovers a siblingprompts.tomlfor managing metadata separately. - Automatic Name Sanitization: Filenames like
Call Analysis.mdbecomeprompts.call_analysis. - Validation & Hooks: Enforce constraints on rendered prompts and intercept rendering with a powerful hook system.
🛠 Usage
Loading from a Directory
DynaPrompt excels at organizing templates as files.
from dynaprompt import DynaPrompt
prompts = DynaPrompt(
settings_files=["examples/"], # Scans for .md, .toml, .py schemas
environments=True
)
# Accessing analyzer.md template
rendered = prompts.analyzer.render(user_name="Emam", text="DynaPrompt is great!")
print(rendered.text)
print(rendered.config["model"]) # "gemini-1.5-pro" (from frontmatter or .toml)
# Partial update: keeps "user_name" but changes "text"
updated = prompts.analyzer.rerender(text="It's really fast.")
Schema Integration
DynaPrompt automatically registers Pydantic models found in your settings_files.
# If examples/schemas.py defines class UserProfile(BaseModel):
prompts = DynaPrompt(settings_files=["examples/"])
# Model is available as an attribute
user_schema = prompts.UserProfile
# Use it in rendering (automatically injects JSON schema if referenced in template)
rendered = prompts.fetch_user.render(username="em2m")
🔍 Inspection & Tab-Completion
DynaPrompt is designed for developer productivity.
- Tab-Completion: Use
dir(prompts)or hitTabin your IDE to see all available prompts and schemas. - History Tracking: Inspect exactly where a prompt was loaded from and how it was merged across layers.
# See loading history for a prompt
print(prompts.inspect("customer_support"))
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 dynaprompt-0.1.0.tar.gz.
File metadata
- Download URL: dynaprompt-0.1.0.tar.gz
- Upload date:
- Size: 997.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c130e1deea174cfec1c6fa51dfdb5d3868f1b3b97f59100795f8f34f3165e1f
|
|
| MD5 |
a0946ce3250bc6b291291837037002c5
|
|
| BLAKE2b-256 |
550dec8cb4d6546e8a09c0e21a8af5c88d6ae50b207571da41a6125721295099
|
File details
Details for the file dynaprompt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dynaprompt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd56cb2c9cc609e1fc337b19c7b4b551ca133ff56147601aa0e782c57b8e6c1e
|
|
| MD5 |
9fc305916a286881db58c682b6a3a6a9
|
|
| BLAKE2b-256 |
f7c08d856f4c66ac8230a628ae47617f7a37dfc32d2eb1aa8a3fb7c6a7339627
|