diff --git a/skills/huggingface-gradio/SKILL.md b/skills/huggingface-gradio/SKILL.md index eaa6732e..9e95f9fb 100644 --- a/skills/huggingface-gradio/SKILL.md +++ b/skills/huggingface-gradio/SKILL.md @@ -103,7 +103,7 @@ Creates a button that can be assigned arbitrary .click() events. ### `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)` Used to render arbitrary Markdown output. -### `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, props: Any)` +### `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)` Creates a component with arbitrary HTML. @@ -240,6 +240,59 @@ Supported events per component: - **UploadButton**: click, upload - **Video**: change, clear, start_recording, stop_recording, stop, play, pause, end, upload, input +## Prediction CLI + +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. + +### `gradio info` — Discover endpoints and parameters + +```bash +gradio info +``` + +Returns a JSON payload describing all endpoints, their parameters (with types and defaults), and return values. + +```bash +gradio info gradio/calculator +# { +# "/predict": { +# "parameters": [ +# {"name": "num1", "required": true, "default": null, "type": {"type": "number"}}, +# {"name": "operation", "required": true, "default": null, "type": {"enum": ["add", "subtract", "multiply", "divide"], "type": "string"}}, +# {"name": "num2", "required": true, "default": null, "type": {"type": "number"}} +# ], +# "returns": [{"name": "output", "type": {"type": "number"}}], +# "description": "" +# } +# } +``` + +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. + +### `gradio predict` — Send predictions + +```bash +gradio predict +``` + +Returns a JSON object with named output keys. + +```bash +# Simple numeric prediction +gradio predict gradio/calculator /predict '{"num1": 5, "operation": "multiply", "num2": 3}' +# {"output": 15} + +# Image generation +gradio predict black-forest-labs/FLUX.2-dev /infer '{"prompt": "A majestic dragon"}' +# {"Result": "/tmp/gradio/.../image.webp", "Seed": 1117868604} + +# File upload (must include meta key) +gradio predict gradio/image_mod /predict '{"image": {"path": "/path/to/image.png", "meta": {"_type": "gradio.FileData"}}}' +# {"output": "/tmp/gradio/.../output.png"} +``` + +Both commands accept `--token` for accessing private Spaces. + ## Additional Reference - [End-to-End Examples](examples.md) — complete working apps