SuperAPI AI 工具集

huggingface-webhooks

测试与质量

查看项目

更新于 10-16 05:52

技能介绍

用途:帮助开发者搭建 Hugging Face Webhook 处理器,校验密钥并响应仓库、内容与讨论相关事件。适用于在 Hub 上构建讨论或 Pull Request 机器人、在数据集更新时自动重训模型等场景。

主要能力:提供密钥校验逻辑(Hugging Face 不使用 HMAC 签名,而是在 X-Webhook-Secret 头或 ?secret= 查询参数中明文发送配置的密钥,需用定时安全比较),并给出 Express、Next.js 与 FastAPI 的完整示例。事件由 event.scope 与 event.action 标识:repo 支持 create/update/delete/move;repo.content 与 repo.config 的 action 固定为 update;discussion 支持 create/update/delete;discussion.comment 支持 create/update。discussion.isPullRequest 为 true 时即 Pull Request。对未知的细分 scope(如 repo.config.dois)应按更宽 scope 的 update 处理以保持前向兼容。

使用方式:在处理器中优先读取 X-Webhook-Secret,回退到 ?secret= 查询参数;Express 需使用 express.json()。示例代码见 examples/express/、examples/nextjs/、examples/fastapi/。环境变量为 HUGGINGFACE_WEBHOOK_SECRET。本地开发可用 npx hookdeck-cli listen 3000 huggingface --path /webhooks/huggingface。生成文件需附注:// Generated with: huggingface-webhooks skill 与 https://github.com/hookdeck/webhook-skills。建议配合 webhook-handler-patterns 技能处理幂等与重试。

限制:每个 Webhook 每 24 小时最多触发 1000 次;repo.headSha 仅在 repo.* scope 发送;updatedRefs[].oldSha 对新引用为 null,newSha 对删除引用为 null;评论 hidden 为 true 时 content 为 undefined。收费与价格暂未提供。