<div align="center"><picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/dark_background_logo.svg">
<img alt="hyperprompt" src="assets/light_background_logo.svg" width=700">
</picture></div>
**`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:
```bash
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
```python
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
```python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/gilad-rubin/hyperprompts",
"name": "hyperprompts",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "prompt, template, ai, llm, hyperprompts",
"author": "Gillad Rubin",
"author_email": "gilad.rubin@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/1f/dc/fb4f635469e73b2bcb0e20b6af91bdbf3d99e67c5ee1a326b36d6a4f1d2a/hyperprompts-0.1.0.tar.gz",
"platform": null,
"description": "<div align=\"center\"><picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"assets/dark_background_logo.svg\">\n <img alt=\"hyperprompt\" src=\"assets/light_background_logo.svg\" width=700\">\n</picture></div>\n\n\n**`hyperprompt`** is a lightweight Python package designed for creating dynamic and customizable text templates using Pythonic logic. \n\nWith 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.\n\n## Installation\n\nInstall hyperprompt using pip:\n\n```bash\npip install hyperprompt\n```\n\n## Features\n\n* \ud83d\ude80 **Pythonic and Intuitive**: Define meta-prompts using standard Python functions and control structures.\n* \ud83d\udee0\ufe0f **Conditional Logic**: Leverage Python's control flow to create dynamic and context-aware templates.\n\n## Usage Example\n### Defining the Meta-Prompt\n```python\nfrom hyperprompt import hyperprompt\n\n# Step One: Define the meta-prompt\n@hyperprompt\ndef greeting_template(user_role: str, language: str):\n match language:\n case \"English\":\n greeting = \"Hello, {name}!\"\n case \"Spanish\":\n greeting = \"\u00a1Hola, {name}!\" \n \n role_info = \"You have {tasks} tasks pending\" if user_role == \"admin\" else None\n footer = \"Have a great day!\"\n```\n### Compiling\n```python\ntemplate, placeholders = greeting_template(user_role=\"admin\", language=\"English\")\nprint(placeholders) # ['name', 'tasks']\n\nfinal_prompt = template.format(name=\"Alice\", tasks=\"5\")\nprint(final_prompt) # Hello, Alice! You have 5 tasks pending. Have a great day!\n\ntemplate, placeholders = greeting_template(user_role=\"user\", language=\"Spanish\")\nprint(placeholders) # ['name']\n\nfinal_prompt = template.format(name=\"Carlos\") \nprint(final_prompt) # Hello, Carlos! Have a great day!\n```\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.",
"bugtrack_url": null,
"license": "MIT",
"summary": "A lightweight prompt template system for LLM-based projects",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/gilad-rubin/hyperprompts",
"Repository": "https://github.com/gilad-rubin/hyperprompts"
},
"split_keywords": [
"prompt",
" template",
" ai",
" llm",
" hyperprompts"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a581e01395e4d2445c3657fe84013fe895b16dc665c2abdc20c77949a931e6d3",
"md5": "4b2952f94b60610305d3fc62c6a502ce",
"sha256": "65e858e06a0cfa814ea3341bdee9d23ffad5429bbde4fb1c5f7c144e6617c1e6"
},
"downloads": -1,
"filename": "hyperprompts-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4b2952f94b60610305d3fc62c6a502ce",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 3058,
"upload_time": "2024-08-20T04:35:49",
"upload_time_iso_8601": "2024-08-20T04:35:49.419145Z",
"url": "https://files.pythonhosted.org/packages/a5/81/e01395e4d2445c3657fe84013fe895b16dc665c2abdc20c77949a931e6d3/hyperprompts-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1fdcfb4f635469e73b2bcb0e20b6af91bdbf3d99e67c5ee1a326b36d6a4f1d2a",
"md5": "61da14aaa74304091a266b8b49221312",
"sha256": "fb51d9c6c948f988a455661309adebf49a6f4a75c771585ee637655661b1f918"
},
"downloads": -1,
"filename": "hyperprompts-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "61da14aaa74304091a266b8b49221312",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 2680,
"upload_time": "2024-08-20T04:35:51",
"upload_time_iso_8601": "2024-08-20T04:35:51.225477Z",
"url": "https://files.pythonhosted.org/packages/1f/dc/fb4f635469e73b2bcb0e20b6af91bdbf3d99e67c5ee1a326b36d6a4f1d2a/hyperprompts-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-20 04:35:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gilad-rubin",
"github_project": "hyperprompts",
"github_not_found": true,
"lcname": "hyperprompts"
}