Add your description here
Project description
broprompt
Lightweight Python library for prompt template management with dynamic parameter handling.
Features
- Load prompt templates from markdown files
- Dynamic parameter access via dot notation
- Template + parameter combination into final prompt strings
- Export/import parameters as dictionaries
- Function-to-tool conversion utilities
- Parameter validation and extraction
Usage
from broprompt.prompt_engineering import Prompt
# Load template from markdown file
prompts = Prompt.from_markdown("system_prompt.md")
# Set parameters
prompts.params.role = "assistant"
prompts.params.domain = "coding"
# Get final prompt string
final_prompt = prompts.str
# Export parameters
params_dict = prompts.to_dict()
# Import parameters
prompts.from_dict({"role": "expert", "tone": "professional"})
Tools Module
from broprompt.tools import convert_to_tool, register_tools
# Convert function to tool definition
def my_function(name: str, age: int) -> str:
"""Greets a person with their name and age."""
return f"Hello {name}, you are {age} years old!"
tool_def = convert_to_tool(my_function)
# Register multiple tools
tools = register_tools([my_function])
Context Module
from broprompt.context import Context
# Create a context (LangChain Document equivalent)
ctx = Context(
context="This is the document content",
metadata={"source": "file.txt", "type": "text"}
)
# Access content
print(ctx.context) # Direct access
# Automatic fields
print(ctx.id) # Auto-generated UUID
print(ctx.created_at) # UTC timestamp
Template Format
Use {parameter_name} placeholders in your markdown files:
# System Prompt
You are {role}, specialized in {domain}.
Respond in {tone} tone.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
broprompt-0.1.4.tar.gz
(6.7 kB
view details)
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 broprompt-0.1.4.tar.gz.
File metadata
- Download URL: broprompt-0.1.4.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdd455715db5f21537b934ef854393173bd1add02320afd7e68253c2f5078d27
|
|
| MD5 |
6babafc301395d86d41566f93d11436b
|
|
| BLAKE2b-256 |
dc7db81c0b084f559c9dd1e517b324c0ea6086558c05103cd094cc3ff7c1d65f
|
File details
Details for the file broprompt-0.1.4-py3-none-any.whl.
File metadata
- Download URL: broprompt-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d42c5c2d64040668260a054534ca321245d8de17c6d3edddbd9b3c70b7285b3
|
|
| MD5 |
f84acf72401e58e77ffed8799a302de2
|
|
| BLAKE2b-256 |
2246960636d24b601d13fa512edd48e6ccfdc1f427947c45bd3efee2995b9281
|