Skip to main content

tags: [gradio-custom-component, ] title: gradio_taggrouphelper short_description: A fast prompt generator based on tagged words colorFrom: blue colorTo: yellow sdk: gradio pinned: false app_file: space.py

gradio_taggrouphelper

PyPI - Version

A fast text generator based on tagged words

Installation

pip install gradio_taggrouphelper

Usage

#
# demo/app.py
#
import gradio as gr
from gradio_taggrouphelper import TagGroupHelper 

# 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(theme=gr.themes.Ocean()) as demo:
    gr.Markdown("# Tag Group Helper Demo")
    gr.Markdown("Click on the tags below to add them to the prompt textboxes.")
    gr.Markdown("<span>💻 <a href='https://github.com/DEVAIEXP/gradio_component_taggrouphelper'>GitHub Code</a></span>")
    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.Sidebar(position="right"):           
            # Create an instance of the TagGroupHelper for the Positive Prompt box.
            TagGroupHelper(
                label="Positive Prompt Keywords",
                value={k: v for k, v in TAG_DATA.items() if "Negative" not in k},
                target_textbox_id="positive-prompt-textbox",
                separator=", ",
                interactive=True,
                width=250,
                font_size_scale=90
                
            )
            
            # Create another instance for the Negative Prompt box.
            TagGroupHelper(
                label="Negative Prompt Keywords",
                value={"Negative Prompts": TAG_DATA["Negative Prompts"]},
                target_textbox_id="negative-prompt-textbox",
                separator=", ",
                interactive=True,
                width=250,                
                font_size_scale=90,
                open=False
            )

if __name__ == '__main__':
    demo.launch()

TagGroupHelper

Initialization

name type default description
value
typing.Optional[typing.Dict[str, typing.List[str]]][
    typing.Dict[str, typing.List[str]][
        str, typing.List[str][str]
    ],
    None,
]
None A dictionary where keys are group names and values are lists of tags.
height
int | None
None The height of the component container in pixels.
width
int | None
None The width of the component container in pixels.
label
str | None
None The label for this component, displayed above the groups.
font_size_scale
int
100 A percentage to scale the font size of group headers and tags. Defaults to 100.
open
bool
True If False, all tag groups will be collapsed by default on load. Defaults to True
every
float | None
None If `value` is a callable, run the function 'every' seconds while the client connection is open.
show_label
bool | None
None If False, the label is not displayed.
container
bool
True If False, the component will not be wrapped in a container.
scale
int | None
None The relative size of the component compared to others in a `gr.Row` or `gr.Column`.
min_width
int
160 The minimum width of the component in pixels.
interactive
bool | None
None if True, will be rendered as an selectable component; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.
target_textbox_id
str | None
None The `elem_id` of the `gr.Textbox` component to target. Required.
separator
str
", " The string to use as a separator between tags. Defaults to ", ". Can be set to " " for space separation.
visible
bool
True If False, the component will be hidden.
elem_id
str | None
None An optional string that is assigned as the id of this component in the HTML DOM.
elem_classes
list[str] | str | None
None An optional list of strings to assign as CSS classes to the component.

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.

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

Metadata

Release files for gradio-taggrouphelper 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gradio-taggrouphelper 0.0.4
File Size Uploaded Provenance Actions
gradio_taggrouphelper-0.0.4.tar.gz 1.1 MB Without provenance Details for gradio_taggrouphelper-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gradio-taggrouphelper 0.0.4
File Interpreter ABI Platform Actions
gradio_taggrouphelper-0.0.4-py3-none-any.whl Python 3 none any Details for gradio_taggrouphelper-0.0.4-py3-none-any.whl

Total release size: 2.2 MB

Release files / gradio_taggrouphelper-0.0.4.tar.gz

Download URL gradio_taggrouphelper-0.0.4.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
987f0a55352a93e6de1a8683915948a27cefc378f9221599b1a228270b4c48e3
BLAKE2b-256 checksum
How to use checksums
1b7afc3741a632297aa1539a5533c75dc4d02eef6b9ace07d87fa3561a574551
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release files / gradio_taggrouphelper-0.0.4-py3-none-any.whl

Download URL gradio_taggrouphelper-0.0.4-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
59c8da63def07d6926099904483c8207a87bb4f4ec745ca22d6dbd6b07a93b42
BLAKE2b-256 checksum
How to use checksums
b5eaa692219ad422e10f603a798489c02ec0f72ff6b8df2a5cb05d0e3e6c938f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Security for gradio-taggrouphelper 0.0.4

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.

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