opencode-skills-antigravity 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled-skills/.antigravity-install-manifest.json +7 -1
- package/bundled-skills/docs/integrations/jetski-cortex.md +3 -3
- package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +1 -1
- package/bundled-skills/docs/maintainers/repo-growth-seo.md +3 -3
- package/bundled-skills/docs/maintainers/skills-update-guide.md +1 -1
- package/bundled-skills/docs/sources/sources.md +2 -2
- package/bundled-skills/docs/users/bundles.md +1 -1
- package/bundled-skills/docs/users/claude-code-skills.md +1 -1
- package/bundled-skills/docs/users/gemini-cli-skills.md +1 -1
- package/bundled-skills/docs/users/getting-started.md +1 -1
- package/bundled-skills/docs/users/kiro-integration.md +1 -1
- package/bundled-skills/docs/users/usage.md +4 -4
- package/bundled-skills/docs/users/visual-guide.md +4 -4
- package/bundled-skills/hugging-face-cli/SKILL.md +192 -195
- package/bundled-skills/hugging-face-community-evals/SKILL.md +213 -0
- package/bundled-skills/hugging-face-community-evals/examples/.env.example +3 -0
- package/bundled-skills/hugging-face-community-evals/examples/USAGE_EXAMPLES.md +101 -0
- package/bundled-skills/hugging-face-community-evals/scripts/inspect_eval_uv.py +104 -0
- package/bundled-skills/hugging-face-community-evals/scripts/inspect_vllm_uv.py +306 -0
- package/bundled-skills/hugging-face-community-evals/scripts/lighteval_vllm_uv.py +297 -0
- package/bundled-skills/hugging-face-dataset-viewer/SKILL.md +120 -120
- package/bundled-skills/hugging-face-gradio/SKILL.md +304 -0
- package/bundled-skills/hugging-face-gradio/examples.md +613 -0
- package/bundled-skills/hugging-face-jobs/SKILL.md +25 -18
- package/bundled-skills/hugging-face-jobs/index.html +216 -0
- package/bundled-skills/hugging-face-jobs/references/hardware_guide.md +336 -0
- package/bundled-skills/hugging-face-jobs/references/hub_saving.md +352 -0
- package/bundled-skills/hugging-face-jobs/references/token_usage.md +570 -0
- package/bundled-skills/hugging-face-jobs/references/troubleshooting.md +475 -0
- package/bundled-skills/hugging-face-jobs/scripts/cot-self-instruct.py +718 -0
- package/bundled-skills/hugging-face-jobs/scripts/finepdfs-stats.py +546 -0
- package/bundled-skills/hugging-face-jobs/scripts/generate-responses.py +587 -0
- package/bundled-skills/hugging-face-model-trainer/SKILL.md +11 -12
- package/bundled-skills/hugging-face-model-trainer/references/gguf_conversion.md +296 -0
- package/bundled-skills/hugging-face-model-trainer/references/hardware_guide.md +283 -0
- package/bundled-skills/hugging-face-model-trainer/references/hub_saving.md +364 -0
- package/bundled-skills/hugging-face-model-trainer/references/local_training_macos.md +231 -0
- package/bundled-skills/hugging-face-model-trainer/references/reliability_principles.md +371 -0
- package/bundled-skills/hugging-face-model-trainer/references/trackio_guide.md +189 -0
- package/bundled-skills/hugging-face-model-trainer/references/training_methods.md +150 -0
- package/bundled-skills/hugging-face-model-trainer/references/training_patterns.md +203 -0
- package/bundled-skills/hugging-face-model-trainer/references/troubleshooting.md +282 -0
- package/bundled-skills/hugging-face-model-trainer/references/unsloth.md +313 -0
- package/bundled-skills/hugging-face-model-trainer/scripts/convert_to_gguf.py +424 -0
- package/bundled-skills/hugging-face-model-trainer/scripts/dataset_inspector.py +417 -0
- package/bundled-skills/hugging-face-model-trainer/scripts/estimate_cost.py +150 -0
- package/bundled-skills/hugging-face-model-trainer/scripts/train_dpo_example.py +106 -0
- package/bundled-skills/hugging-face-model-trainer/scripts/train_grpo_example.py +89 -0
- package/bundled-skills/hugging-face-model-trainer/scripts/train_sft_example.py +122 -0
- package/bundled-skills/hugging-face-model-trainer/scripts/unsloth_sft_example.py +512 -0
- package/bundled-skills/hugging-face-paper-publisher/SKILL.md +11 -4
- package/bundled-skills/hugging-face-paper-publisher/examples/example_usage.md +326 -0
- package/bundled-skills/hugging-face-paper-publisher/references/quick_reference.md +216 -0
- package/bundled-skills/hugging-face-paper-publisher/scripts/paper_manager.py +606 -0
- package/bundled-skills/hugging-face-paper-publisher/templates/arxiv.md +299 -0
- package/bundled-skills/hugging-face-paper-publisher/templates/ml-report.md +358 -0
- package/bundled-skills/hugging-face-paper-publisher/templates/modern.md +319 -0
- package/bundled-skills/hugging-face-paper-publisher/templates/standard.md +201 -0
- package/bundled-skills/hugging-face-papers/SKILL.md +241 -0
- package/bundled-skills/hugging-face-trackio/.claude-plugin/plugin.json +19 -0
- package/bundled-skills/hugging-face-trackio/SKILL.md +117 -0
- package/bundled-skills/hugging-face-trackio/references/alerts.md +196 -0
- package/bundled-skills/hugging-face-trackio/references/logging_metrics.md +206 -0
- package/bundled-skills/hugging-face-trackio/references/retrieving_metrics.md +251 -0
- package/bundled-skills/hugging-face-vision-trainer/SKILL.md +595 -0
- package/bundled-skills/hugging-face-vision-trainer/references/finetune_sam2_trainer.md +254 -0
- package/bundled-skills/hugging-face-vision-trainer/references/hub_saving.md +618 -0
- package/bundled-skills/hugging-face-vision-trainer/references/image_classification_training_notebook.md +279 -0
- package/bundled-skills/hugging-face-vision-trainer/references/object_detection_training_notebook.md +700 -0
- package/bundled-skills/hugging-face-vision-trainer/references/reliability_principles.md +310 -0
- package/bundled-skills/hugging-face-vision-trainer/references/timm_trainer.md +91 -0
- package/bundled-skills/hugging-face-vision-trainer/scripts/dataset_inspector.py +814 -0
- package/bundled-skills/hugging-face-vision-trainer/scripts/estimate_cost.py +217 -0
- package/bundled-skills/hugging-face-vision-trainer/scripts/image_classification_training.py +383 -0
- package/bundled-skills/hugging-face-vision-trainer/scripts/object_detection_training.py +710 -0
- package/bundled-skills/hugging-face-vision-trainer/scripts/sam_segmentation_training.py +382 -0
- package/bundled-skills/transformers-js/SKILL.md +639 -0
- package/bundled-skills/transformers-js/references/CACHE.md +339 -0
- package/bundled-skills/transformers-js/references/CONFIGURATION.md +390 -0
- package/bundled-skills/transformers-js/references/EXAMPLES.md +605 -0
- package/bundled-skills/transformers-js/references/MODEL_ARCHITECTURES.md +167 -0
- package/bundled-skills/transformers-js/references/PIPELINE_OPTIONS.md +545 -0
- package/bundled-skills/transformers-js/references/TEXT_GENERATION.md +315 -0
- package/package.json +1 -1
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: "https://github.com/huggingface/skills/tree/main/skills/huggingface-gradio"
|
|
3
|
+
name: hugging-face-gradio
|
|
4
|
+
description: Build or edit Gradio apps, layouts, components, and chat interfaces in Python.
|
|
5
|
+
risk: unknown
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Gradio
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
Use this skill when a user wants a Gradio demo, UI prototype, or Python-based ML interface.
|
|
13
|
+
|
|
14
|
+
Gradio is a Python library for building interactive web UIs and ML demos. This skill covers the core API, patterns, and examples.
|
|
15
|
+
|
|
16
|
+
## Guides
|
|
17
|
+
|
|
18
|
+
Detailed guides on specific topics (read these when relevant):
|
|
19
|
+
|
|
20
|
+
- [Quickstart](https://www.gradio.app/guides/quickstart)
|
|
21
|
+
- [The Interface Class](https://www.gradio.app/guides/the-interface-class)
|
|
22
|
+
- [Blocks and Event Listeners](https://www.gradio.app/guides/blocks-and-event-listeners)
|
|
23
|
+
- [Controlling Layout](https://www.gradio.app/guides/controlling-layout)
|
|
24
|
+
- [More Blocks Features](https://www.gradio.app/guides/more-blocks-features)
|
|
25
|
+
- [Custom CSS and JS](https://www.gradio.app/guides/custom-CSS-and-JS)
|
|
26
|
+
- [Streaming Outputs](https://www.gradio.app/guides/streaming-outputs)
|
|
27
|
+
- [Streaming Inputs](https://www.gradio.app/guides/streaming-inputs)
|
|
28
|
+
- [Sharing Your App](https://www.gradio.app/guides/sharing-your-app)
|
|
29
|
+
- [Custom HTML Components](https://www.gradio.app/guides/custom-HTML-components)
|
|
30
|
+
- [Getting Started with the Python Client](https://www.gradio.app/guides/getting-started-with-the-python-client)
|
|
31
|
+
- [Getting Started with the JS Client](https://www.gradio.app/guides/getting-started-with-the-js-client)
|
|
32
|
+
|
|
33
|
+
## Core Patterns
|
|
34
|
+
|
|
35
|
+
**Interface** (high-level): wraps a function with input/output components.
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import gradio as gr
|
|
39
|
+
|
|
40
|
+
def greet(name):
|
|
41
|
+
return f"Hello {name}!"
|
|
42
|
+
|
|
43
|
+
gr.Interface(fn=greet, inputs="text", outputs="text").launch()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Blocks** (low-level): flexible layout with explicit event wiring.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import gradio as gr
|
|
50
|
+
|
|
51
|
+
with gr.Blocks() as demo:
|
|
52
|
+
name = gr.Textbox(label="Name")
|
|
53
|
+
output = gr.Textbox(label="Greeting")
|
|
54
|
+
btn = gr.Button("Greet")
|
|
55
|
+
btn.click(fn=lambda n: f"Hello {n}!", inputs=name, outputs=output)
|
|
56
|
+
|
|
57
|
+
demo.launch()
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**ChatInterface**: high-level wrapper for chatbot UIs.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import gradio as gr
|
|
64
|
+
|
|
65
|
+
def respond(message, history):
|
|
66
|
+
return f"You said: {message}"
|
|
67
|
+
|
|
68
|
+
gr.ChatInterface(fn=respond).launch()
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Key Component Signatures
|
|
72
|
+
|
|
73
|
+
### `Textbox(value: str | I18nData | Callable | None = None, type: Literal['text', 'password', 'email'] = "text", lines: int = 1, max_lines: int | None = None, placeholder: str | I18nData | None = None, label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, autofocus: bool = False, autoscroll: bool = True, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", text_align: Literal['left', 'right'] | None = None, rtl: bool = False, buttons: list[Literal['copy'] | Button] | None = None, max_length: int | None = None, submit_btn: str | bool | None = False, stop_btn: str | bool | None = False, html_attributes: InputHTMLAttributes | None = None)`
|
|
74
|
+
Creates a textarea for user to enter string input or display string output..
|
|
75
|
+
|
|
76
|
+
### `Number(value: float | Callable | None = None, label: str | I18nData | None = None, placeholder: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", buttons: list[Button] | None = None, precision: int | None = None, minimum: float | None = None, maximum: float | None = None, step: float = 1)`
|
|
77
|
+
Creates a numeric field for user to enter numbers as input or display numeric output..
|
|
78
|
+
|
|
79
|
+
### `Slider(minimum: float = 0, maximum: float = 100, value: float | Callable | None = None, step: float | None = None, precision: int | None = None, label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", randomize: bool = False, buttons: list[Literal['reset']] | None = None)`
|
|
80
|
+
Creates a slider that ranges from {minimum} to {maximum} with a step size of {step}..
|
|
81
|
+
|
|
82
|
+
### `Checkbox(value: bool | Callable = False, label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", buttons: list[Button] | None = None)`
|
|
83
|
+
Creates a checkbox that can be set to `True` or `False`.
|
|
84
|
+
|
|
85
|
+
### `Dropdown(choices: Sequence[str | int | float | tuple[str, str | int | float]] | None = None, value: str | int | float | Sequence[str | int | float] | Callable | DefaultValue | None = DefaultValue(), type: Literal['value', 'index'] = "value", multiselect: bool | None = None, allow_custom_value: bool = False, max_choices: int | None = None, filterable: bool = True, label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", buttons: list[Button] | None = None)`
|
|
86
|
+
Creates a dropdown of choices from which a single entry or multiple entries can be selected (as an input component) or displayed (as an output component)..
|
|
87
|
+
|
|
88
|
+
### `Radio(choices: Sequence[str | int | float | tuple[str, str | int | float]] | None = None, value: str | int | float | Callable | None = None, type: Literal['value', 'index'] = "value", label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", rtl: bool = False, buttons: list[Button] | None = None)`
|
|
89
|
+
Creates a set of (string or numeric type) radio buttons of which only one can be selected..
|
|
90
|
+
|
|
91
|
+
### `Image(value: str | PIL.Image.Image | np.ndarray | Callable | None = None, format: str = "webp", height: int | str | None = None, width: int | str | None = None, image_mode: Literal['1', 'L', 'P', 'RGB', 'RGBA', 'CMYK', 'YCbCr', 'LAB', 'HSV', 'I', 'F'] | None = "RGB", sources: list[Literal['upload', 'webcam', 'clipboard']] | Literal['upload', 'webcam', 'clipboard'] | None = None, type: Literal['numpy', 'pil', 'filepath'] = "numpy", label: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, buttons: list[Literal['download', 'share', 'fullscreen'] | Button] | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, streaming: bool = False, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", webcam_options: WebcamOptions | None = None, placeholder: str | None = None, watermark: WatermarkOptions | None = None)`
|
|
92
|
+
Creates an image component that can be used to upload images (as an input) or display images (as an output)..
|
|
93
|
+
|
|
94
|
+
### `Audio(value: str | Path | tuple[int, np.ndarray] | Callable | None = None, sources: list[Literal['upload', 'microphone']] | Literal['upload', 'microphone'] | None = None, type: Literal['numpy', 'filepath'] = "numpy", label: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, streaming: bool = False, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", format: Literal['wav', 'mp3'] | None = None, autoplay: bool = False, editable: bool = True, buttons: list[Literal['download', 'share'] | Button] | None = None, waveform_options: WaveformOptions | dict | None = None, loop: bool = False, recording: bool = False, subtitles: str | Path | list[dict[str, Any]] | None = None, playback_position: float = 0)`
|
|
95
|
+
Creates an audio component that can be used to upload/record audio (as an input) or display audio (as an output)..
|
|
96
|
+
|
|
97
|
+
### `Video(value: str | Path | Callable | None = None, format: str | None = None, sources: list[Literal['upload', 'webcam']] | Literal['upload', 'webcam'] | None = None, height: int | str | None = None, width: int | str | None = None, label: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", webcam_options: WebcamOptions | None = None, include_audio: bool | None = None, autoplay: bool = False, buttons: list[Literal['download', 'share'] | Button] | None = None, loop: bool = False, streaming: bool = False, watermark: WatermarkOptions | None = None, subtitles: str | Path | list[dict[str, Any]] | None = None, playback_position: float = 0)`
|
|
98
|
+
Creates a video component that can be used to upload/record videos (as an input) or display videos (as an output).
|
|
99
|
+
|
|
100
|
+
### `File(value: str | list[str] | Callable | None = None, file_count: Literal['single', 'multiple', 'directory'] = "single", file_types: list[str] | None = None, type: Literal['filepath', 'binary'] = "filepath", label: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, height: int | str | float | None = None, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", allow_reordering: bool = False, buttons: list[Button] | None = None)`
|
|
101
|
+
Creates a file component that allows uploading one or more generic files (when used as an input) or displaying generic files or URLs for download (as output).
|
|
102
|
+
|
|
103
|
+
### `Chatbot(value: list[MessageDict | Message] | Callable | None = None, label: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, autoscroll: bool = True, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", height: int | str | None = 400, resizable: bool = False, max_height: int | str | None = None, min_height: int | str | None = None, editable: Literal['user', 'all'] | None = None, latex_delimiters: list[dict[str, str | bool]] | None = None, rtl: bool = False, buttons: list[Literal['share', 'copy', 'copy_all'] | Button] | None = None, watermark: str | None = None, avatar_images: tuple[str | Path | None, str | Path | None] | None = None, sanitize_html: bool = True, render_markdown: bool = True, feedback_options: list[str] | tuple[str, ...] | None = ('Like', 'Dislike'), feedback_value: Sequence[str | None] | None = None, line_breaks: bool = True, layout: Literal['panel', 'bubble'] | None = None, placeholder: str | None = None, examples: list[ExampleMessage] | None = None, allow_file_downloads: <class 'inspect._empty'> = True, group_consecutive_messages: bool = True, allow_tags: list[str] | bool = True, reasoning_tags: list[tuple[str, str]] | None = None, like_user_message: bool = False)`
|
|
104
|
+
Creates a chatbot that displays user-submitted messages and responses.
|
|
105
|
+
|
|
106
|
+
### `Button(value: str | I18nData | Callable = "Run", every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, variant: Literal['primary', 'secondary', 'stop', 'huggingface'] = "secondary", size: Literal['sm', 'md', 'lg'] = "lg", icon: str | Path | None = None, link: str | None = None, link_target: Literal['_self', '_blank', '_parent', '_top'] = "_self", visible: bool | Literal['hidden'] = True, interactive: bool = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", scale: int | None = None, min_width: int | None = None)`
|
|
107
|
+
Creates a button that can be assigned arbitrary .click() events.
|
|
108
|
+
|
|
109
|
+
### `Markdown(value: str | I18nData | Callable | None = None, label: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, rtl: bool = False, latex_delimiters: list[dict[str, str | bool]] | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", sanitize_html: bool = True, line_breaks: bool = False, header_links: bool = False, height: int | str | None = None, max_height: int | str | None = None, min_height: int | str | None = None, buttons: list[Literal['copy']] | None = None, container: bool = False, padding: bool = False)`
|
|
110
|
+
Used to render arbitrary Markdown output.
|
|
111
|
+
|
|
112
|
+
### `HTML(value: Any | Callable | None = None, label: str | I18nData | None = None, html_template: str = "${value}", css_template: str = "", js_on_load: str | None = "element.addEventListener('click', function() { trigger('click') });", apply_default_css: bool = True, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool = False, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", min_height: int | None = None, max_height: int | None = None, container: bool = False, padding: bool = False, autoscroll: bool = False, buttons: list[Button] | None = None, server_functions: list[Callable] | None = None, props: Any)`
|
|
113
|
+
Creates a component with arbitrary HTML.
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
## Custom HTML Components
|
|
117
|
+
|
|
118
|
+
If a task requires significant customization of an existing component or a component that doesn't exist in Gradio, you can create one with `gr.HTML`. It supports `html_template` (with `${}` JS expressions and `{{}}` Handlebars syntax), `css_template` for scoped styles, and `js_on_load` for interactivity — where `props.value` updates the component value and `trigger('event_name')` fires Gradio events. For reuse, subclass `gr.HTML` and define `api_info()` for API/MCP support. See the [full guide](https://www.gradio.app/guides/custom-HTML-components).
|
|
119
|
+
|
|
120
|
+
Here's an example that shows how to create and use these kinds of components:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
import gradio as gr
|
|
124
|
+
|
|
125
|
+
class StarRating(gr.HTML):
|
|
126
|
+
def __init__(self, label, value=0, **kwargs):
|
|
127
|
+
html_template = """
|
|
128
|
+
<h2>${label} rating:</h2>
|
|
129
|
+
${Array.from({length: 5}, (_, i) => `<img class='${i < value ? '' : 'faded'}' src='https://upload.wikimedia.org/wikipedia/commons/d/df/Award-star-gold-3d.svg'>`).join('')}
|
|
130
|
+
"""
|
|
131
|
+
css_template = """
|
|
132
|
+
img { height: 50px; display: inline-block; cursor: pointer; }
|
|
133
|
+
.faded { filter: grayscale(100%); opacity: 0.3; }
|
|
134
|
+
"""
|
|
135
|
+
js_on_load = """
|
|
136
|
+
const imgs = element.querySelectorAll('img');
|
|
137
|
+
imgs.forEach((img, index) => {
|
|
138
|
+
img.addEventListener('click', () => {
|
|
139
|
+
props.value = index + 1;
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
"""
|
|
143
|
+
super().__init__(value=value, label=label, html_template=html_template, css_template=css_template, js_on_load=js_on_load, **kwargs)
|
|
144
|
+
|
|
145
|
+
def api_info(self):
|
|
146
|
+
return {"type": "integer", "minimum": 0, "maximum": 5}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
with gr.Blocks() as demo:
|
|
150
|
+
gr.Markdown("# Restaurant Review")
|
|
151
|
+
food_rating = StarRating(label="Food", value=3)
|
|
152
|
+
service_rating = StarRating(label="Service", value=3)
|
|
153
|
+
ambience_rating = StarRating(label="Ambience", value=3)
|
|
154
|
+
average_btn = gr.Button("Calculate Average Rating")
|
|
155
|
+
rating_output = StarRating(label="Average", value=3)
|
|
156
|
+
def calculate_average(food, service, ambience):
|
|
157
|
+
return round((food + service + ambience) / 3)
|
|
158
|
+
average_btn.click(
|
|
159
|
+
fn=calculate_average,
|
|
160
|
+
inputs=[food_rating, service_rating, ambience_rating],
|
|
161
|
+
outputs=rating_output
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
demo.launch()
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Event Listeners
|
|
168
|
+
|
|
169
|
+
All event listeners share the same signature:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
component.event_name(
|
|
173
|
+
fn: Callable | None | Literal["decorator"] = "decorator",
|
|
174
|
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
|
175
|
+
outputs: Component | Sequence[Component] | set[Component] | None = None,
|
|
176
|
+
api_name: str | None = None,
|
|
177
|
+
api_description: str | None | Literal[False] = None,
|
|
178
|
+
scroll_to_output: bool = False,
|
|
179
|
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
|
180
|
+
show_progress_on: Component | Sequence[Component] | None = None,
|
|
181
|
+
queue: bool = True,
|
|
182
|
+
batch: bool = False,
|
|
183
|
+
max_batch_size: int = 4,
|
|
184
|
+
preprocess: bool = True,
|
|
185
|
+
postprocess: bool = True,
|
|
186
|
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
|
187
|
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
|
188
|
+
js: str | Literal[True] | None = None,
|
|
189
|
+
concurrency_limit: int | None | Literal["default"] = "default",
|
|
190
|
+
concurrency_id: str | None = None,
|
|
191
|
+
api_visibility: Literal["public", "private", "undocumented"] = "public",
|
|
192
|
+
time_limit: int | None = None,
|
|
193
|
+
stream_every: float = 0.5,
|
|
194
|
+
key: int | str | tuple[int | str, ...] | None = None,
|
|
195
|
+
validator: Callable | None = None,
|
|
196
|
+
) -> Dependency
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Supported events per component:
|
|
200
|
+
|
|
201
|
+
- **AnnotatedImage**: select
|
|
202
|
+
- **Audio**: stream, change, clear, play, pause, stop, pause, start_recording, pause_recording, stop_recording, upload, input
|
|
203
|
+
- **BarPlot**: select, double_click
|
|
204
|
+
- **BrowserState**: change
|
|
205
|
+
- **Button**: click
|
|
206
|
+
- **Chatbot**: change, select, like, retry, undo, example_select, option_select, clear, copy, edit
|
|
207
|
+
- **Checkbox**: change, input, select
|
|
208
|
+
- **CheckboxGroup**: change, input, select
|
|
209
|
+
- **ClearButton**: click
|
|
210
|
+
- **Code**: change, input, focus, blur
|
|
211
|
+
- **ColorPicker**: change, input, submit, focus, blur
|
|
212
|
+
- **Dataframe**: change, input, select, edit
|
|
213
|
+
- **Dataset**: click, select
|
|
214
|
+
- **DateTime**: change, submit
|
|
215
|
+
- **DeepLinkButton**: click
|
|
216
|
+
- **Dialogue**: change, input, submit
|
|
217
|
+
- **DownloadButton**: click
|
|
218
|
+
- **Dropdown**: change, input, select, focus, blur, key_up
|
|
219
|
+
- **DuplicateButton**: click
|
|
220
|
+
- **File**: change, select, clear, upload, delete, download
|
|
221
|
+
- **FileExplorer**: change, input, select
|
|
222
|
+
- **Gallery**: select, upload, change, delete, preview_close, preview_open
|
|
223
|
+
- **HTML**: change, input, click, double_click, submit, stop, edit, clear, play, pause, end, start_recording, pause_recording, stop_recording, focus, blur, upload, release, select, stream, like, example_select, option_select, load, key_up, apply, delete, tick, undo, retry, expand, collapse, download, copy
|
|
224
|
+
- **HighlightedText**: change, select
|
|
225
|
+
- **Image**: clear, change, stream, select, upload, input
|
|
226
|
+
- **ImageEditor**: clear, change, input, select, upload, apply
|
|
227
|
+
- **ImageSlider**: clear, change, stream, select, upload, input
|
|
228
|
+
- **JSON**: change
|
|
229
|
+
- **Label**: change, select
|
|
230
|
+
- **LinePlot**: select, double_click
|
|
231
|
+
- **LoginButton**: click
|
|
232
|
+
- **Markdown**: change, copy
|
|
233
|
+
- **Model3D**: change, upload, edit, clear
|
|
234
|
+
- **MultimodalTextbox**: change, input, select, submit, focus, blur, stop
|
|
235
|
+
- **Navbar**: change
|
|
236
|
+
- **Number**: change, input, submit, focus, blur
|
|
237
|
+
- **ParamViewer**: change, upload
|
|
238
|
+
- **Plot**: change
|
|
239
|
+
- **Radio**: select, change, input
|
|
240
|
+
- **ScatterPlot**: select, double_click
|
|
241
|
+
- **SimpleImage**: clear, change, upload
|
|
242
|
+
- **Slider**: change, input, release
|
|
243
|
+
- **State**: change
|
|
244
|
+
- **Textbox**: change, input, select, submit, focus, blur, stop, copy
|
|
245
|
+
- **Timer**: tick
|
|
246
|
+
- **UploadButton**: click, upload
|
|
247
|
+
- **Video**: change, clear, start_recording, stop_recording, stop, play, pause, end, upload, input
|
|
248
|
+
|
|
249
|
+
## Prediction CLI
|
|
250
|
+
|
|
251
|
+
The `gradio` CLI includes `info` and `predict` commands for interacting with Gradio apps programmatically. These are especially useful for coding agents that need to use Spaces in their workflows.
|
|
252
|
+
|
|
253
|
+
### `gradio info` — Discover endpoints and parameters
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
gradio info <space_id_or_url>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Returns a JSON payload describing all endpoints, their parameters (with types and defaults), and return values.
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
gradio info gradio/calculator
|
|
263
|
+
# {
|
|
264
|
+
# "/predict": {
|
|
265
|
+
# "parameters": [
|
|
266
|
+
# {"name": "num1", "required": true, "default": null, "type": {"type": "number"}},
|
|
267
|
+
# {"name": "operation", "required": true, "default": null, "type": {"enum": ["add", "subtract", "multiply", "divide"], "type": "string"}},
|
|
268
|
+
# {"name": "num2", "required": true, "default": null, "type": {"type": "number"}}
|
|
269
|
+
# ],
|
|
270
|
+
# "returns": [{"name": "output", "type": {"type": "number"}}],
|
|
271
|
+
# "description": ""
|
|
272
|
+
# }
|
|
273
|
+
# }
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
File-type parameters show `"type": "filepath"` with instructions to include `"meta": {"_type": "gradio.FileData"}` — this signals the file will be uploaded to the remote server.
|
|
277
|
+
|
|
278
|
+
### `gradio predict` — Send predictions
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
gradio predict <space_id_or_url> <endpoint> <json_payload>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Returns a JSON object with named output keys.
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# Simple numeric prediction
|
|
288
|
+
gradio predict gradio/calculator /predict '{"num1": 5, "operation": "multiply", "num2": 3}'
|
|
289
|
+
# {"output": 15}
|
|
290
|
+
|
|
291
|
+
# Image generation
|
|
292
|
+
gradio predict black-forest-labs/FLUX.2-dev /infer '{"prompt": "A majestic dragon"}'
|
|
293
|
+
# {"Result": "/tmp/gradio/.../image.webp", "Seed": 1117868604}
|
|
294
|
+
|
|
295
|
+
# File upload (must include meta key)
|
|
296
|
+
gradio predict gradio/image_mod /predict '{"image": {"path": "/path/to/image.png", "meta": {"_type": "gradio.FileData"}}}'
|
|
297
|
+
# {"output": "/tmp/gradio/.../output.png"}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Both commands accept `--token` for accessing private Spaces.
|
|
301
|
+
|
|
302
|
+
## Additional Reference
|
|
303
|
+
|
|
304
|
+
- [End-to-End Examples](examples.md) — complete working apps
|