← Back to Skills Marketplace
ivangdavila

Gradio

by Iván · GitHub ↗ · v1.0.0
linuxdarwinwin32 ✓ Security Clean
942
Downloads
2
Stars
3
Active Installs
1
Versions
Install in OpenClaw
/install gradio
Description
Build and deploy ML demo interfaces with proper state management, queuing, and production patterns.
README (SKILL.md)

Gradio Patterns

Interface vs Blocks

  • gr.Interface is for single-function demos — use gr.Blocks for anything with multiple steps, conditional UI, or custom layout
  • Blocks gives you .click(), .change(), .submit() event handlers — Interface only has one function
  • Mixing Interface inside Blocks works but creates confusing state — pick one pattern per app

State Management

  • gr.State() creates per-session state — it resets when the user refreshes the page
  • State values must be JSON-serializable or Gradio silently drops them — no custom classes without serialization
  • Pass State as both input AND output to persist changes: fn(state) -> state — forgetting the output loses updates
  • Global variables shared across users cause race conditions — always use gr.State() for user-specific data

Queuing and Concurrency

  • Without .queue(), long-running functions block all other users — always call demo.queue() before .launch()
  • concurrency_limit=1 on a function serializes calls — use for GPU-bound inference that can't parallelize
  • max_size in queue limits waiting users — without it, memory grows unbounded under load
  • Generator functions with yield enable streaming — but they hold a queue slot until complete

File Handling

  • Uploaded files are temp paths that get deleted after the request — copy them if you need persistence
  • gr.File(type="binary") returns bytes, type="filepath" returns a string path — mismatching causes silent failures
  • Return gr.File(value="path/to/file") for downloads, not raw bytes — the component handles content-disposition headers
  • File uploads have a default 200MB limit — set max_file_size in launch() to change it

Component Traps

  • gr.Dropdown(value=None) with allow_custom_value=False crashes if the user submits nothing — set a default or make it optional
  • gr.Image(type="pil") returns a PIL Image, type="numpy" returns an array, type="filepath" returns a path — inconsistent inputs break functions
  • gr.Chatbot expects list of tuples [(user, bot), ...] — returning just strings doesn't render
  • visible=False components still run their functions — use gr.update(interactive=False) to disable without hiding

Authentication

  • auth=("user", "pass") is plaintext in code — use auth=auth_function for production with proper credential checking
  • Auth applies to the whole app — there's no per-route or per-component auth without custom middleware
  • share=True with auth still exposes auth to Gradio's servers — use your own tunnel for sensitive apps

Deployment

  • share=True creates a 72-hour public URL through Gradio's servers — not for production, just demos
  • Environment variables in local dev don't exist in Hugging Face Spaces — use Spaces secrets or the Settings UI
  • server_name="0.0.0.0" to accept external connections — default 127.0.0.1 only allows localhost
  • Behind a reverse proxy, set root_path="/subpath" or assets and API routes break

Events and Updates

  • Return gr.update(value=x, visible=True) to modify component properties — returning just the value only changes value
  • Chain events with .then() for sequential operations — parallel .click() handlers race
  • every=5 on a function polls every 5 seconds — but it holds connections open, scale carefully
  • trigger_mode="once" prevents double-clicks from firing twice — default allows rapid duplicate submissions

Performance

  • cache_examples=True pre-computes example outputs at startup — speeds up demos but increases load time
  • Large model loading in the function runs per-request — load in global scope or use gr.State with initialization
  • batch=True with max_batch_size=N groups concurrent requests — essential for GPU throughput
Usage Guidance
This skill is a documentation/reference skill for Gradio patterns and appears internally consistent. Before using it: 1) Remember it only provides guidance; it doesn't install code or include runnable scripts — you'll implement these patterns in your own codebase. 2) Follow its own cautions: avoid share=True for sensitive apps, don't store plaintext auth in code, and handle uploaded files carefully (copy if you need persistence). 3) Because it requires python3 at runtime, any agent action that actually runs code will execute in your environment — review any generated code before running it. 4) If you plan to deploy to a hosted service (e.g., Spaces or a reverse proxy), verify the platform-specific settings (secrets, root_path, server_name) yourself. Overall, there are no incoherent or suspicious requests in this skill, but security depends on how you implement the recommendations it contains.
Capability Analysis
Type: OpenClaw Skill Name: gradio Version: 1.0.0 The skill bundle contains standard metadata in `_meta.json` and a comprehensive guide on Gradio best practices and common pitfalls in `SKILL.md`. The markdown content is purely informational and educational, describing various Gradio features, deployment considerations, and security warnings (e.g., plaintext auth, `share=True` risks). There are no instructions for the AI agent to perform malicious actions, exfiltrate data, establish persistence, or execute arbitrary commands. The content does not exhibit any characteristics of prompt injection or other malicious intent.
Capability Assessment
Purpose & Capability
Name and description (Gradio demos, state, queuing, deployment patterns) match the SKILL.md content. The only runtime requirement declared is python3, which is appropriate for Gradio guidance.
Instruction Scope
SKILL.md is a set of implementation patterns and warnings for Gradio (state, queuing, file handling, auth, deployment). It does not instruct the agent to read unrelated system files, exfiltrate data, or call external endpoints beyond describing Gradio features. It does note security-relevant considerations (e.g., don't use share=True for sensitive apps, don't put plaintext credentials in code).
Install Mechanism
No install spec and no code files — instruction-only. This is the lowest-risk install posture; nothing is downloaded or written to disk by the skill itself.
Credentials
The skill declares no environment variables, credentials, or config paths. The guidance mentions environment variables and deployment services as relevant operating details, but the skill does not request access to secrets or unrelated services.
Persistence & Privilege
always is false and the skill does not request persistent presence or modify other skills or system-wide settings. It is user-invocable and can be autonomously invoked by the agent (platform default), which is reasonable for a patterns/reference skill.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install gradio
  3. After installation, invoke the skill by name or use /gradio
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release
Metadata
Slug gradio
Version 1.0.0
License
All-time Installs 3
Active Installs 3
Total Versions 1
Frequently Asked Questions

What is Gradio?

Build and deploy ML demo interfaces with proper state management, queuing, and production patterns. It is an AI Agent Skill for Claude Code / OpenClaw, with 942 downloads so far.

How do I install Gradio?

Run "/install gradio" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Gradio free?

Yes, Gradio is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Gradio support?

Gradio is cross-platform and runs anywhere OpenClaw / Claude Code is available (linux, darwin, win32).

Who created Gradio?

It is built and maintained by Iván (@ivangdavila); the current version is v1.0.0.

💬 Comments