fix: 修复ComfyUI V2模板创建参数解析问题并重构工作流创建
主要修改: 1. **扩展ComfyUI SDK参数类型支持** - 在ParameterType枚举中添加Integer、Float、Image、Audio、Video类型 - 在ParameterSchema中添加节点映射和媒体文件相关字段 - 添加step、accept、maxSize、width、height、duration、node_mapping字段 - 为新字段添加serde默认值支持 2. **修复参数解析问题** - 解决comfyui_v2_create_template命令缺少type字段的错误 - 确保前端传递的参数类型与后端ParameterType枚举匹配 - 修复r#enum字段的正确使用(用于JSON Schema兼容性) 3. **重构工作流模板创建方式** - 将ai_model_face_hair_fix.rs中的create_workflow函数重构为create_workflow_from_json - 改为从JSON字符串解析ComfyUIWorkflow,而非手动构建HashMap - 提高可维护性和与实际使用场景的一致性 4. **更新相关测试和验证代码** - 修复validation.rs中的测试用例,添加新字段的默认值 - 确保所有ParameterSchema创建都包含完整字段 5. **添加测试数据** - 创建test_template_creation.json用于测试参数格式 这些修改解决了前端传递的参数格式与后端期望格式不匹配的问题, 使工作流模板创建功能能够正常工作。
This commit is contained in:
94
test_template_creation.json
Normal file
94
test_template_creation.json
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"request": {
|
||||
"name": "AI模型头发修复细节",
|
||||
"category": "",
|
||||
"description": "",
|
||||
"template_data": {
|
||||
"metadata": {
|
||||
"id": "ai-001",
|
||||
"name": "AI模型头发修复细节",
|
||||
"description": "",
|
||||
"version": "1.0.0",
|
||||
"author": "",
|
||||
"tags": [],
|
||||
"category": ""
|
||||
},
|
||||
"workflow": {
|
||||
"30": {
|
||||
"inputs": {
|
||||
"image": "{{input_image}}"
|
||||
},
|
||||
"class_type": "LoadImage",
|
||||
"_meta": {
|
||||
"title": "加载图像"
|
||||
}
|
||||
},
|
||||
"71": {
|
||||
"inputs": {
|
||||
"Number": "{{prompt_strage}}"
|
||||
},
|
||||
"class_type": "Float",
|
||||
"_meta": {
|
||||
"title": "Float"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": {
|
||||
"input_image": {
|
||||
"param_type": "image",
|
||||
"required": false,
|
||||
"description": "支持的图片格式:JPG, PNG, WebP, BMP, TIFF",
|
||||
"default": "",
|
||||
"node_mapping": {
|
||||
"node_id": "30",
|
||||
"input_field": "image"
|
||||
},
|
||||
"accept": ".jpg,.jpeg,.png,.webp,.bmp,.tiff",
|
||||
"maxSize": 10485760
|
||||
},
|
||||
"prompt_strage": {
|
||||
"param_type": "float",
|
||||
"required": false,
|
||||
"description": "",
|
||||
"default": 0.3,
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"step": 0.01,
|
||||
"node_mapping": {
|
||||
"node_id": "71",
|
||||
"input_field": "Number"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameter_schema": {
|
||||
"input_image": {
|
||||
"param_type": "image",
|
||||
"required": false,
|
||||
"description": "支持的图片格式:JPG, PNG, WebP, BMP, TIFF",
|
||||
"default": "",
|
||||
"node_mapping": {
|
||||
"node_id": "30",
|
||||
"input_field": "image"
|
||||
},
|
||||
"accept": ".jpg,.jpeg,.png,.webp,.bmp,.tiff",
|
||||
"maxSize": 10485760
|
||||
},
|
||||
"prompt_strage": {
|
||||
"param_type": "float",
|
||||
"required": false,
|
||||
"description": "",
|
||||
"default": 0.3,
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"step": 0.01,
|
||||
"node_mapping": {
|
||||
"node_id": "71",
|
||||
"input_field": "Number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [],
|
||||
"author": ""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user