← 返回 Skills 市场
ivangdavila

Gradio

作者 Iván · GitHub ↗ · v1.0.0
linuxdarwinwin32 ✓ 安全检测通过
942
总下载
2
收藏
3
当前安装
1
版本数
在 OpenClaw 中安装
/install gradio
功能描述
Build and deploy ML demo interfaces with proper state management, queuing, and production patterns.
使用说明 (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
安全使用建议
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.
功能分析
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.
能力评估
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.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install gradio
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /gradio 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release
元数据
Slug gradio
版本 1.0.0
许可证
累计安装 3
当前安装数 3
历史版本数 1
常见问题

Gradio 是什么?

Build and deploy ML demo interfaces with proper state management, queuing, and production patterns. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 942 次。

如何安装 Gradio?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install gradio」即可一键安装,无需额外配置。

Gradio 是免费的吗?

是的,Gradio 完全免费(开源免费),可自由下载、安装和使用。

Gradio 支持哪些平台?

Gradio 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(linux, darwin, win32)。

谁开发了 Gradio?

由 Iván(@ivangdavila)开发并维护,当前版本 v1.0.0。

💬 留言讨论