hyperprompt is a lightweight Python package designed for creating dynamic and customizable text templates using Pythonic logic.
With hyperprompt, you define meta-prompts using pure Python, compile them with configuration inputs to produce templates with placeholders, and then compile these templates with actual data to generate the final output.
Installation
Install hyperprompt using pip:
pip install hyperprompt
Features
- 🚀 Pythonic and Intuitive: Define meta-prompts using standard Python functions and control structures.
- 🛠️ Conditional Logic: Leverage Python's control flow to create dynamic and context-aware templates.
Usage Example
Defining the Meta-Prompt
from hyperprompt import hyperprompt
# Step One: Define the meta-prompt
@hyperprompt
def greeting_template(user_role: str, language: str):
match language:
case "English":
greeting = "Hello, {name}!"
case "Spanish":
greeting = "¡Hola, {name}!"
role_info = "You have {tasks} tasks pending" if user_role == "admin" else None
footer = "Have a great day!"
Compiling
template, placeholders = greeting_template(user_role="admin", language="English")
print(placeholders) # ['name', 'tasks']
final_prompt = template.format(name="Alice", tasks="5")
print(final_prompt) # Hello, Alice! You have 5 tasks pending. Have a great day!
template, placeholders = greeting_template(user_role="user", language="Spanish")
print(placeholders) # ['name']
final_prompt = template.format(name="Carlos")
print(final_prompt) # Hello, Carlos! Have a great day!
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for hyperprompts 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hyperprompts-0.1.0.tar.gz | 2.7 kB | Without provenance | Details for hyperprompts-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hyperprompts-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hyperprompts-0.1.0-py3-none-any.whl |
Total release size: 5.7 kB
Release files / hyperprompts-0.1.0.tar.gz
| Download URL | hyperprompts-0.1.0.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb51d9c6c948f988a455661309adebf49a6f4a75c771585ee637655661b1f918
|
|
BLAKE2b-256 checksum How to use checksums |
1fdcfb4f635469e73b2bcb0e20b6af91bdbf3d99e67c5ee1a326b36d6a4f1d2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.14 Darwin/23.6.0
|
Release files / hyperprompts-0.1.0-py3-none-any.whl
| Download URL | hyperprompts-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65e858e06a0cfa814ea3341bdee9d23ffad5429bbde4fb1c5f7c144e6617c1e6
|
|
BLAKE2b-256 checksum How to use checksums |
a581e01395e4d2445c3657fe84013fe895b16dc665c2abdc20c77949a931e6d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.14 Darwin/23.6.0
|
Security for hyperprompts 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.