Skip to content

Commit 2ae80bd

Browse files
mishig25claude
andcommitted
Add huggingface-spaces skill
Leverages the new `hf spaces search` CLI and the per-Space `/agents.md` endpoint (see huggingface#122) so agents can discover Gradio Spaces and call their APIs without manual setup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 061ab49 commit 2ae80bd

4 files changed

Lines changed: 88 additions & 0 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
"source": "./skills/huggingface-vision-trainer",
7474
"skills": "./",
7575
"description": "Train and fine-tune object detection models (RTDETRv2, YOLOS, DETR and others) and image classification models (timm and transformers models — MobileNetV3, MobileViT, ResNet, ViT/DINOv3) using Transformers Trainer API on Hugging Face Jobs infrastructure or locally. Includes COCO dataset format support, Albumentations augmentation, mAP/mAR metrics, trackio tracking, hardware selection, and Hub persistence."
76+
},
77+
{
78+
"name": "huggingface-spaces",
79+
"source": "./skills/huggingface-spaces",
80+
"skills": "./",
81+
"description": "Find and call Hugging Face Spaces to generate AI artifacts (images, audio, 3D models, etc). Uses semantic search to discover Spaces, then calls their Gradio APIs."
7682
}
7783
]
7884
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ This repository contains a few skills to get you started. You can also contribut
9797
| `huggingface-llm-trainer` | Train or fine-tune language models using TRL on Hugging Face Jobs infrastructure. Covers SFT, DPO, GRPO and reward modeling training methods, plus GGUF conversion for local deployment. Includes hardware selection, cost estimation, Trackio monitoring, and Hub persistence. | [SKILL.md](skills/huggingface-llm-trainer/SKILL.md) |
9898
| `huggingface-paper-publisher` | Publish and manage research papers on Hugging Face Hub. Supports creating paper pages, linking papers to models/datasets, claiming authorship, and generating professional markdown-based research articles. | [SKILL.md](skills/huggingface-paper-publisher/SKILL.md) |
9999
| `huggingface-papers` | Look up and read Hugging Face paper pages in markdown, and use the papers API for structured metadata like authors, linked models, datasets, Spaces, and media URLs when needed. | [SKILL.md](skills/huggingface-papers/SKILL.md) |
100+
| `huggingface-spaces` | Find and call Hugging Face Spaces to generate AI artifacts (images, audio, 3D models, etc). Uses semantic search to discover Spaces, then calls their Gradio APIs. | [SKILL.md](skills/huggingface-spaces/SKILL.md) |
100101
| `huggingface-tool-builder` | Build reusable scripts for Hugging Face Hub and API workflows. Useful for chaining API calls, enriching Hub metadata, or automating repeated tasks. | [SKILL.md](skills/huggingface-tool-builder/SKILL.md) |
101102
| `huggingface-trackio` | Track and visualize ML training experiments with Trackio. Log metrics via Python API and retrieve them via CLI. Supports real-time dashboards synced to HF Spaces. | [SKILL.md](skills/huggingface-trackio/SKILL.md) |
102103
| `huggingface-vision-trainer` | Train and fine-tune object detection models (RTDETRv2, YOLOS, DETR and others) and image classification models (timm and transformers models — MobileNetV3, MobileViT, ResNet, ViT/DINOv3) using Transformers Trainer API on Hugging Face Jobs infrastructure or locally. Includes COCO dataset format support, Albumentations augmentation, mAP/mAR metrics, trackio tracking, hardware selection, and Hub persistence. | [SKILL.md](skills/huggingface-vision-trainer/SKILL.md) |

agents/AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ These skills are:
1010
- huggingface-llm-trainer -> "skills/huggingface-llm-trainer/SKILL.md"
1111
- huggingface-paper-publisher -> "skills/huggingface-paper-publisher/SKILL.md"
1212
- huggingface-papers -> "skills/huggingface-papers/SKILL.md"
13+
- huggingface-spaces -> "skills/huggingface-spaces/SKILL.md"
1314
- huggingface-tool-builder -> "skills/huggingface-tool-builder/SKILL.md"
1415
- huggingface-trackio -> "skills/huggingface-trackio/SKILL.md"
1516
- huggingface-vision-trainer -> "skills/huggingface-vision-trainer/SKILL.md"
@@ -26,6 +27,7 @@ huggingface-gradio: `Build Gradio web UIs and demos in Python. Use when creating
2627
huggingface-llm-trainer: `Train or fine-tune language and vision models using TRL (Transformer Reinforcement Learning) or Unsloth with Hugging Face Jobs infrastructure. Covers SFT, DPO, GRPO and reward modeling training methods, plus GGUF conversion for local deployment. Includes guidance on the TRL Jobs package, UV scripts with PEP 723 format, dataset preparation and validation, hardware selection, cost estimation, Trackio monitoring, Hub authentication, model selection/leaderboards and model persistence. Use for tasks involving cloud GPU training, GGUF conversion, or when users mention training on Hugging Face Jobs without local GPU setup.`
2728
huggingface-paper-publisher: `Publish and manage research papers on Hugging Face Hub. Supports creating paper pages, linking papers to models/datasets, claiming authorship, and generating professional markdown-based research articles.`
2829
huggingface-papers: `Look up and read Hugging Face paper pages in markdown, and use the papers API for structured metadata such as authors, linked models/datasets/spaces, Github repo and project page. Use when the user shares a Hugging Face paper page URL, an arXiv URL or ID, or asks to summarize, explain, or analyze an AI research paper.`
30+
huggingface-spaces: `Find and call Hugging Face Spaces to generate AI artifacts (images, audio, 3D models, etc). Uses semantic search to discover Spaces, then calls their Gradio APIs.`
2931
huggingface-tool-builder: `Use this skill when the user wants to build tool/scripts or achieve a task where using data from the Hugging Face API would help. This is especially useful when chaining or combining API calls or the task will be repeated/automated. This Skill creates a reusable script to fetch, enrich or process data.`
3032
huggingface-trackio: `Track and visualize ML training experiments with Trackio. Use when logging metrics during training (Python API), firing alerts for training diagnostics, or retrieving/analyzing logged metrics (CLI). Supports real-time dashboard visualization, alerts with webhooks, HF Space syncing, and JSON output for automation.`
3133
huggingface-vision-trainer: `Trains and fine-tunes vision models for object detection (D-FINE, RT-DETR v2, DETR, YOLOS), image classification (timm models — MobileNetV3, MobileViT, ResNet, ViT/DINOv3 — plus any Transformers classifier), and SAM/SAM2 segmentation using Hugging Face Transformers on Hugging Face Jobs cloud GPUs. Covers COCO-format dataset preparation, Albumentations augmentation, mAP/mAR evaluation, accuracy metrics, SAM segmentation with bbox/point prompts, DiceCE loss, hardware selection, cost estimation, Trackio monitoring, and Hub persistence. Use when users mention training object detection, image classification, SAM, SAM2, segmentation, image matting, DETR, D-FINE, RT-DETR, ViT, timm, MobileNet, ResNet, bounding box models, or fine-tuning vision models on Hugging Face Jobs.`

skills/huggingface-spaces/SKILL.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
name: huggingface-spaces
3+
description: Find and call Hugging Face Spaces to generate AI artifacts (images, audio, 3D models, etc). Uses semantic search to discover Spaces, then calls their Gradio APIs.
4+
user-invocable: true
5+
allowed-tools: Bash WebFetch Read Write
6+
argument-hint: <prompt describing what to generate>
7+
---
8+
9+
# Hugging Face Spaces Tool
10+
11+
You have access to thousands of AI apps hosted on Hugging Face Spaces. Use them to generate artifacts like images, audio, 3D models, videos, text, and more.
12+
13+
## Authentication
14+
15+
Install the latest `hf` CLI and log in:
16+
17+
```bash
18+
curl -LsSf https://hf.co/cli/install.sh | bash
19+
hf auth login
20+
```
21+
22+
Always include the user's HF token in API requests:
23+
- **REST calls**: `Authorization: Bearer $(hf auth token)`
24+
- **Python client**: `Client("space-url", hf_token=subprocess.check_output(["hf", "auth", "token"]).decode().strip())`
25+
26+
## Workflow
27+
28+
### Step 1: Find the right Space
29+
30+
Use the `hf` CLI to search for a Space matching the user's request:
31+
32+
```bash
33+
hf spaces search --sdk gradio "<search query>"
34+
```
35+
36+
- Always filter by `--sdk gradio` (only Gradio spaces have callable APIs)
37+
- The output lists Space IDs sorted by relevance with descriptions
38+
- Prefer spaces that are running and have high trending scores
39+
- The space domain is derived from the `id`: `owner-spacename.hf.space` (replace `/` with `-`, lowercase)
40+
41+
### Step 2: Call the Space
42+
43+
Fetch the Space's `agents.md` and follow its instructions to call the Space:
44+
45+
```bash
46+
curl https://huggingface.co/spaces/<owner>/<spacename>/agents.md
47+
```
48+
49+
This returns a Markdown document with everything needed to call the Space: available endpoints, parameters, input/output types, and usage examples — purpose-built for agents like this one.
50+
51+
### Step 3: Handle the output
52+
53+
- **Files (images, audio, 3D models)**: Download from the returned URL and save locally
54+
- **Open/play the result**: Use `open <file>` (macOS) or `afplay <file>` (audio)
55+
- File URLs from Gradio look like: `https://<space>.hf.space/gradio_api/file=<path>`
56+
57+
## Tips
58+
59+
- Read `agents.md` carefully — it often documents exact parameter names, accepted values, and example calls
60+
- For the Python client, use `handle_file("/path/to/file")` or `handle_file("https://url")` for file/image inputs
61+
- ZeroGPU spaces have usage quotas — if you get "GPU quota exceeded", wait or try another space
62+
- Multi-step pipelines (e.g., image-to-3D) often require session state — use the Python client
63+
- If a user provides a specific Space URL, skip the search step and use it directly
64+
65+
## Examples
66+
67+
**User says**: "generate an image of a sunset"
68+
1. Search: `hf spaces search --sdk gradio "text to image generation"`
69+
2. Pick a top result (e.g., `mrfakename/Z-Image-Turbo`)
70+
3. Fetch `agents.md`, follow its instructions, download and open the result
71+
72+
**User says**: "convert this image to 3D"
73+
1. Search: `hf spaces search --sdk gradio "image to 3d model"`
74+
2. Pick a result (e.g., a Trellis space)
75+
3. Fetch `agents.md` and follow its instructions
76+
77+
**User says**: "say hello world in speech"
78+
1. Search: `hf spaces search --sdk gradio "text to speech"`
79+
2. Pick a TTS space, call the generate endpoint, download and play the audio

0 commit comments

Comments
 (0)