| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- """将 runcomfy_workflow_builder 注册到 Tool Agent Registry (PostgreSQL)
- 运行: python tools/local/runcomfy_workflow_builder/register.py
- """
- import sys
- from pathlib import Path
- # 确保能 import tool_agent
- sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "src"))
- from tool_agent.tool.tool_store import PostgreSQLToolStore
- TOOL_ID = "runcomfy_workflow_builder"
- TOOL_DATA = {
- "id": TOOL_ID,
- "name": "RunComfy Workflow Builder",
- "version": "1.0.0",
- "introduction": (
- "ComfyUI 工作流构建辅助工具。提供模型查询、节点 Schema 检索、示例工作流浏览/加载、工作流验证等能力。"
- "⚠️ 首次使用请先调用 action=read_skill 获取完整使用指南,了解 API JSON 格式规则和架构差异后再构建工作流。"
- ),
- "tutorial": (
- "调用方式: POST /run_tool {tool_id: 'runcomfy_workflow_builder', params: {action: '...', ...}}\n"
- "\n"
- "支持的 action:\n"
- " read_skill - 【首次必读】返回 skill.md 使用指南\n"
- " search_models - 查询环境中可用的 checkpoint/lora/vae/controlnet\n"
- " get_node_schema - 获取 ComfyUI 节点的参数定义\n"
- " list_examples - 浏览/搜索示例工作流库 (70+)\n"
- " load_example - 加载具体示例 JSON 作为参考模板\n"
- " verify_workflow - 验证手写 API JSON 的合法性\n"
- "\n"
- "推荐流程: read_skill → list_examples → load_example → search_models → 修改 → verify_workflow → 交给 executor"
- ),
- "input": {
- "type": "object",
- "properties": {
- "action": {
- "type": "string",
- "description": "要执行的操作。⚠️ 首次使用请先调用 read_skill 了解完整规则。",
- "enum": ["read_skill", "search_models", "get_node_schema", "list_examples", "load_example", "verify_workflow"]
- },
- "category": {
- "type": "string",
- "description": "模型分类(checkpoints/loras/vaes/controlnets) 或示例分类(flux/controlnet/inpaint/...)"
- },
- "keyword": {
- "type": "string",
- "description": "搜索关键词(大小写不敏感)"
- },
- "class_type": {
- "type": "string",
- "description": "ComfyUI 节点类型名 (get_node_schema 用),如 KSampler、ControlNetApplySD3"
- },
- "name": {
- "type": "string",
- "description": "示例工作流名称 (load_example 用),支持 stem/路径/部分关键词"
- },
- "workflow": {
- "type": "object",
- "description": "待验证的 ComfyUI API JSON 字典 (verify_workflow 用)"
- }
- },
- "required": ["action"]
- },
- "output": {
- "type": "object",
- "description": "根据 action 不同返回不同结构,均包含 action 字段标识操作类型"
- },
- "updated_time": 0,
- "status": "已接入",
- }
- if __name__ == "__main__":
- print(f"Registering tool: {TOOL_ID}")
- store = PostgreSQLToolStore()
- store.insert_or_update(TOOL_DATA)
- store.close()
- print(f"✅ Tool '{TOOL_ID}' registered successfully.")
- print(f" Description: {TOOL_DATA['introduction'][:80]}...")
- print(f" Actions: {TOOL_DATA['input']['properties']['action']['enum']}")
|