Skip to main content
hyperprompt

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.

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)

Source distribution for hyperprompts 0.1.0
File Size Uploaded
hyperprompts-0.1.0.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hyperprompts 0.1.0
File Interpreter ABI Platform
hyperprompts-0.1.0-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page