---
tags: [gradio-custom-component, ]
title: gradio_prompttaghelper
short_description: A fast prompt generator based on tagged words
colorFrom: blue
colorTo: yellow
sdk: gradio
pinned: false
app_file: space.py
---
# `gradio_prompttaghelper`
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
A fast prompt generator based on tagged words
## Installation
```bash
pip install gradio_prompttaghelper
```
## Usage
```python
#
# demo/app.py
#
import gradio as gr
from gradio_prompttaghelper import PromptTagHelper
# Example data structure for the tags and groups
TAG_DATA = {
"Quality": [
"best quality", "masterpiece", "high resolution", "4k", "8k",
"sharp focus", "detailed", "photorealistic"
],
"Lighting": [
"cinematic lighting", "volumetric lighting", "god rays",
"golden hour", "studio lighting", "dramatic lighting"
],
"Style": [
"anime style", "oil painting", "concept art", "fantasy",
"steampunk", "vaporwave", "line art"
],
"Negative Prompts": [
"blurry", "noisy", "low resolution", "low quality", "watermark",
"text", "bad anatomy", "extra limbs", "disfigured"
]
}
with gr.Blocks() as demo:
gr.Markdown("# Prompt Tag Helper Demo")
gr.Markdown("Click on the tags below to add them to the prompt textboxes.")
with gr.Row():
with gr.Column(scale=2): # Give more space to the textboxes
# Create the target Textbox and give it a unique `elem_id`.
positive_prompt_box = gr.Textbox(
label="Positive Prompt",
placeholder="Click tags from 'Prompt Keywords' to add them here...",
lines=5,
elem_id="positive-prompt-textbox" # This ID must be unique
)
negative_prompt_box = gr.Textbox(
label="Negative Prompt",
placeholder="Click tags from 'Negative Keywords' to add them here...",
lines=5,
elem_id="negative-prompt-textbox" # This ID must be unique
)
with gr.Column(scale=1): # Give less space to the helpers
# Create an instance of the PromptTagHelper for the Positive Prompt box.
PromptTagHelper(
label="Prompt Keywords",
value={k: v for k, v in TAG_DATA.items() if "Negative" not in k},
target_textbox_id="positive-prompt-textbox"
)
# Create another instance for the Negative Prompt box.
PromptTagHelper(
label="Negative Keywords",
value={"Negative Prompts": TAG_DATA["Negative Prompts"]},
target_textbox_id="negative-prompt-textbox",
min_width=150
)
if __name__ == '__main__':
demo.launch()
```
## `PromptTagHelper`
### Initialization
<table>
<thead>
<tr>
<th align="left">name</th>
<th align="left" style="width: 25%;">type</th>
<th align="left">default</th>
<th align="left">description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>value</code></td>
<td align="left" style="width: 25%;">
```python
typing.Optional[typing.Dict[str, typing.List[str]]][
typing.Dict[str, typing.List[str]][
str, typing.List[str][str]
],
None,
]
```
</td>
<td align="left"><code>None</code></td>
<td align="left">A dictionary where keys are group names and values are lists of tags.</td>
</tr>
<tr>
<td align="left"><code>target_textbox_id</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">The `elem_id` of the `gr.Textbox` component to target. Required.</td>
</tr>
<tr>
<td align="left"><code>label</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">The label for this component, displayed above the groups.</td>
</tr>
<tr>
<td align="left"><code>visible</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If False, the component will be hidden.</td>
</tr>
<tr>
<td align="left"><code>elem_id</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM.</td>
</tr>
<tr>
<td align="left"><code>scale</code></td>
<td align="left" style="width: 25%;">
```python
int | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">The relative size of the component compared to others in a `gr.Row` or `gr.Column`.</td>
</tr>
<tr>
<td align="left"><code>min_width</code></td>
<td align="left" style="width: 25%;">
```python
int | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">The minimum-width of the component in pixels.</td>
</tr>
<tr>
<td align="left"><code>container</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If False, the component will not be wrapped in a container.</td>
</tr>
<tr>
<td align="left"><code>elem_classes</code></td>
<td align="left" style="width: 25%;">
```python
list[str] | str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">An optional list of strings to assign as CSS classes to the component.</td>
</tr>
</tbody></table>
### User function
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.
The code snippet below is accurate in cases where the component is used as both an input and an output.
```python
def predict(
value: Any
) -> typing.Optional[typing.Dict[str, typing.List[str]]][
typing.Dict[str, typing.List[str]][
str, typing.List[str][str]
],
None,
]:
return value
```
Raw data
{
"_id": null,
"home_page": null,
"name": "gradio-prompttaghelper",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "gradio-custom-component, gradio-template-Fallback",
"author": null,
"author_email": "YOUR NAME <YOUREMAIL@domain.com>",
"download_url": "https://files.pythonhosted.org/packages/71/13/c1a518e2c4de5a5eba110bb03a97bf3646c0df0df65f408ddd58ebde4032/gradio_prompttaghelper-0.0.1.tar.gz",
"platform": null,
"description": "---\ntags: [gradio-custom-component, ]\ntitle: gradio_prompttaghelper\nshort_description: A fast prompt generator based on tagged words\ncolorFrom: blue\ncolorTo: yellow\nsdk: gradio\npinned: false\napp_file: space.py\n---\n\n# `gradio_prompttaghelper`\n<img alt=\"Static Badge\" src=\"https://img.shields.io/badge/version%20-%200.0.1%20-%20orange\"> \n\nA fast prompt generator based on tagged words\n\n## Installation\n\n```bash\npip install gradio_prompttaghelper\n```\n\n## Usage\n\n```python\n#\n# demo/app.py\n#\nimport gradio as gr\nfrom gradio_prompttaghelper import PromptTagHelper \n\n# Example data structure for the tags and groups\nTAG_DATA = {\n \"Quality\": [\n \"best quality\", \"masterpiece\", \"high resolution\", \"4k\", \"8k\", \n \"sharp focus\", \"detailed\", \"photorealistic\"\n ],\n \"Lighting\": [\n \"cinematic lighting\", \"volumetric lighting\", \"god rays\", \n \"golden hour\", \"studio lighting\", \"dramatic lighting\"\n ],\n \"Style\": [\n \"anime style\", \"oil painting\", \"concept art\", \"fantasy\", \n \"steampunk\", \"vaporwave\", \"line art\"\n ],\n \"Negative Prompts\": [\n \"blurry\", \"noisy\", \"low resolution\", \"low quality\", \"watermark\",\n \"text\", \"bad anatomy\", \"extra limbs\", \"disfigured\"\n ]\n}\n\nwith gr.Blocks() as demo:\n gr.Markdown(\"# Prompt Tag Helper Demo\")\n gr.Markdown(\"Click on the tags below to add them to the prompt textboxes.\")\n\n with gr.Row():\n with gr.Column(scale=2): # Give more space to the textboxes\n # Create the target Textbox and give it a unique `elem_id`.\n positive_prompt_box = gr.Textbox(\n label=\"Positive Prompt\",\n placeholder=\"Click tags from 'Prompt Keywords' to add them here...\",\n lines=5,\n elem_id=\"positive-prompt-textbox\" # This ID must be unique\n )\n negative_prompt_box = gr.Textbox(\n label=\"Negative Prompt\",\n placeholder=\"Click tags from 'Negative Keywords' to add them here...\",\n lines=5,\n elem_id=\"negative-prompt-textbox\" # This ID must be unique\n )\n\n with gr.Column(scale=1): # Give less space to the helpers\n # Create an instance of the PromptTagHelper for the Positive Prompt box.\n PromptTagHelper(\n label=\"Prompt Keywords\",\n value={k: v for k, v in TAG_DATA.items() if \"Negative\" not in k},\n target_textbox_id=\"positive-prompt-textbox\"\n )\n \n # Create another instance for the Negative Prompt box.\n PromptTagHelper(\n label=\"Negative Keywords\",\n value={\"Negative Prompts\": TAG_DATA[\"Negative Prompts\"]},\n target_textbox_id=\"negative-prompt-textbox\",\n min_width=150\n )\n\nif __name__ == '__main__':\n demo.launch()\n```\n\n## `PromptTagHelper`\n\n### Initialization\n\n<table>\n<thead>\n<tr>\n<th align=\"left\">name</th>\n<th align=\"left\" style=\"width: 25%;\">type</th>\n<th align=\"left\">default</th>\n<th align=\"left\">description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>value</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\ntyping.Optional[typing.Dict[str, typing.List[str]]][\n typing.Dict[str, typing.List[str]][\n str, typing.List[str][str]\n ],\n None,\n]\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">A dictionary where keys are group names and values are lists of tags.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>target_textbox_id</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">The `elem_id` of the `gr.Textbox` component to target. Required.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">The label for this component, displayed above the groups.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>visible</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, the component will be hidden.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_id</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional string that is assigned as the id of this component in the HTML DOM.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>scale</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">The relative size of the component compared to others in a `gr.Row` or `gr.Column`.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>min_width</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">The minimum-width of the component in pixels.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>container</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, the component will not be wrapped in a container.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_classes</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional list of strings to assign as CSS classes to the component.</td>\n</tr>\n</tbody></table>\n\n\n\n\n### User function\n\nThe impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).\n\n- When used as an Input, the component only impacts the input signature of the user function.\n- When used as an output, the component only impacts the return signature of the user function.\n\nThe code snippet below is accurate in cases where the component is used as both an input and an output.\n\n\n\n ```python\n def predict(\n value: Any\n ) -> typing.Optional[typing.Dict[str, typing.List[str]]][\n typing.Dict[str, typing.List[str]][\n str, typing.List[str][str]\n ],\n None,\n]:\n return value\n ```\n \n",
"bugtrack_url": null,
"license": null,
"summary": "A fast prompt generator based on tagged words",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [
"gradio-custom-component",
" gradio-template-fallback"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c60edd0fa03561349a01478325801f02c399697ec7967323546033643d510b71",
"md5": "06394607a1321cb6f6824c13b2c52f39",
"sha256": "fd4398e5485ceb5d5d354453213f9cbd3143932ef8bd109bc919eebc9fb903ea"
},
"downloads": -1,
"filename": "gradio_prompttaghelper-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "06394607a1321cb6f6824c13b2c52f39",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 1113673,
"upload_time": "2025-07-15T00:09:53",
"upload_time_iso_8601": "2025-07-15T00:09:53.370033Z",
"url": "https://files.pythonhosted.org/packages/c6/0e/dd0fa03561349a01478325801f02c399697ec7967323546033643d510b71/gradio_prompttaghelper-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7113c1a518e2c4de5a5eba110bb03a97bf3646c0df0df65f408ddd58ebde4032",
"md5": "49bdd5b72e3157cdf8fd272d744e6c73",
"sha256": "2029a570c1a3d9ff1d01bdbab01d35d78c15994b4c5945634e11e497318c5635"
},
"downloads": -1,
"filename": "gradio_prompttaghelper-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "49bdd5b72e3157cdf8fd272d744e6c73",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 1172480,
"upload_time": "2025-07-15T00:09:56",
"upload_time_iso_8601": "2025-07-15T00:09:56.545248Z",
"url": "https://files.pythonhosted.org/packages/71/13/c1a518e2c4de5a5eba110bb03a97bf3646c0df0df65f408ddd58ebde4032/gradio_prompttaghelper-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-15 00:09:56",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "gradio-prompttaghelper"
}