额度耗尽/池空要干净失败给用户可读拒因,而非含糊的「生成失败」。该失败因是跨契约
共享枚举(FailureReasonEnum 头注禁单边扩展),contract-first 同一批落三处保持一致:
- FailureReasonEnum 加 QUOTA_EXHAUSTED("quota_exhausted","生成额度已用完");
- contracts/api-schemas/aigc.yaml FailureReason.enum;
- contracts/dify-workflow-io.json output.failureReason.enum。
落库列 game_aigc_task.failure_reason(varchar(32)) 容得下(15 字符)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56 lines
3.0 KiB
JSON
56 lines
3.0 KiB
JSON
{
|
||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||
"$id": "https://wanxiang.ai/contracts/dify-workflow-io.json",
|
||
"title": "DifyWorkflowIO",
|
||
"description": "契约 #6 Dify workflow 输入/输出(owner=WS2)。aigc Java 壳 ↔ Dify 的对接面。Dify 6 节点:安全检测→意图解析→模板匹配→GameConfig生成+Schema校验→调OpenGame/ComfyUI→质量评估。LLM 节点 prompt 用 {{registry:id@ver}} 引用 Prompt Registry(契约#8)。",
|
||
"type": "object",
|
||
"required": ["input", "output"],
|
||
"additionalProperties": false,
|
||
"properties": {
|
||
"input": {
|
||
"description": "Java 壳 → Dify 的工作流输入",
|
||
"type": "object",
|
||
"required": ["prompt", "traceId"],
|
||
"additionalProperties": false,
|
||
"properties": {
|
||
"prompt": { "description": "创作者自然语言 Prompt", "type": "string", "minLength": 1 },
|
||
"templateId": { "description": "指定模板 ID(可空,空则由意图解析+模板匹配节点决定)", "type": "string" },
|
||
"userId": { "description": "创作者 ID(限频/审计)", "type": "string" },
|
||
"traceId": { "description": "贯穿全链路 trace_id", "type": "string" },
|
||
"attachments": {
|
||
"description": "附件驱动创作上下文(图片/参考,可空)",
|
||
"type": "array",
|
||
"items": { "type": "object", "properties": { "type": { "type": "string" }, "url": { "type": "string", "format": "uri" } } }
|
||
}
|
||
}
|
||
},
|
||
"output": {
|
||
"description": "Dify → Java 壳 的工作流输出。status 驱动 aigc 生成任务状态机。",
|
||
"type": "object",
|
||
"required": ["status", "traceId"],
|
||
"additionalProperties": false,
|
||
"properties": {
|
||
"status": {
|
||
"description": "生成结果状态。succeeded 必带 gameConfig/assets;failed 必带 failureReason。",
|
||
"type": "string",
|
||
"enum": ["succeeded", "failed"]
|
||
},
|
||
"traceId": { "type": "string" },
|
||
"templateId": { "description": "最终匹配/使用的模板 ID", "type": "string" },
|
||
"gameConfig": { "description": "生成的可玩配置(注入 GamePackage.gameConfig,runtime 编译前 Schema 校验)", "type": "object" },
|
||
"assets": {
|
||
"description": "ComfyUI 等生成的资源引用(合入 GamePackage.assets)",
|
||
"type": "array",
|
||
"items": { "type": "object", "properties": { "type": { "type": "string" }, "url": { "type": "string", "format": "uri" } } }
|
||
},
|
||
"qualityScore": { "description": "质量评估节点输出(0-1,质量门禁参考)", "type": "number", "minimum": 0, "maximum": 1 },
|
||
"failureReason": {
|
||
"description": "失败原因分类(status=failed 必填,映射用户可读提示)",
|
||
"type": "string",
|
||
"enum": ["unsafe_prompt", "intent_unclear", "no_template_match", "config_invalid", "llm_error", "timeout", "asset_gen_failed", "quota_exhausted"]
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|