mirror of
https://git.openapi.site/https://github.com/desirecore/config-center.git
synced 2026-12-05 23:00:30 +08:00
feat: 定义 V2 媒体生成 Profile / Validate V2 media generation profiles
This commit is contained in:
1 parent
d7034f14df
commit
51e51406e5
2 files changed
+291
No files matched your search
@@ -16,6 +16,22 @@ test('canonical projections reproduce each V1 field including missing fields and
|
||||
for(const [file,data]of Object.entries(projectV1(catalog))) assert.equal(stableJson(data),stableJson(JSON.parse(fs.readFileSync(path.join(root,file),'utf8'))),file);
|
||||
});
|
||||
test('compiler is deterministic and does not depend on provider files',()=>assert.equal(stableJson(compileCatalog(catalog)),stableJson(compileCatalog(structuredClone(catalog)))));
|
||||
test('media profiles survive the typed V2 projection while V1 remains frozen', () => {
|
||||
const draft = structuredClone(catalog);
|
||||
const image = {kind:'image', protocol:'minimax-image', protocolVersion:'1', modes:['text-to-image','image-to-image'], capabilities:{maxForwardedReferenceImages:1}};
|
||||
const video = {kind:'video', protocol:'dashscope-video-async', protocolVersion:'1', modes:['text-to-video'], capabilities:{duration:{minimum:2,maximum:30,automaticValues:[-1]}}};
|
||||
const miniMax = draft.accesses.find(a => a.id === 'provider-minimax-001');
|
||||
const model = miniMax.models.find(m => m.apiModelId === 'image-01');
|
||||
const wan = draft.specs.find(s => s.modelRef === 'wan:wan3.0-video');
|
||||
model.request.constraints = {mediaGeneration:image};
|
||||
wan.facts.constraints = {mediaGeneration:video};
|
||||
const {output,projection} = compileCatalog(draft);
|
||||
assert.deepEqual(output.accesses.find(a => a.id === miniMax.id).models.find(m => m.apiModelId === model.apiModelId).request.constraints.mediaGeneration, image);
|
||||
assert.deepEqual(output.specs.find(s => s.modelRef === wan.modelRef).facts.constraints.mediaGeneration, video);
|
||||
assert.deepEqual(projection, projectV1(catalog));
|
||||
model.request.constraints.mediaGeneration = {...image, protocolVersion: 1};
|
||||
assert.throws(() => compileCatalog(draft), /Invalid V2 schema/);
|
||||
});
|
||||
test('candidate and invalid versions fail closed while budget/output remain independent',()=>{
|
||||
assert.ok(resolveEffectiveModel(spec,model,{...options,publicationState:'candidate'}).blockedReasons.includes('catalog-not-published'));
|
||||
assert.ok(resolveEffectiveModel(spec,model,{...options,clientVersion:'garbage'}).blockedReasons.includes('invalid-client-version'));
|
||||
|
||||
@@ -1417,6 +1417,281 @@
|
||||
"constraints": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mediaGeneration": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kind"
|
||||
],
|
||||
"if": {
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "image"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kind",
|
||||
"protocol",
|
||||
"protocolVersion",
|
||||
"modes"
|
||||
],
|
||||
"properties": {
|
||||
"protocol": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
|
||||
"description": "稳定的媒体请求与响应协议族。型号小版本、渠道名称和凭据变化不改变协议标识。"
|
||||
},
|
||||
"protocolVersion": {
|
||||
"type": "string",
|
||||
"pattern": "^[1-9][0-9]*$",
|
||||
"description": "协议的不兼容版本号。请求结构、响应或作业状态合同发生不兼容变更时递增。"
|
||||
},
|
||||
"kind": {
|
||||
"const": "image",
|
||||
"description": "同步图像生成服务。"
|
||||
},
|
||||
"modes": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"text-to-image",
|
||||
"image-to-image"
|
||||
]
|
||||
},
|
||||
"description": "已确认支持的图像生成模式。多图融合属于 image-to-image。"
|
||||
},
|
||||
"capabilities": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nativeTransparentBackground": {
|
||||
"type": "boolean",
|
||||
"description": "此协议与型号可接收原生透明背景请求。交付前仍需检查实际 alpha。"
|
||||
},
|
||||
"maxForwardedReferenceImages": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "适配器向上游转发的参考图数量上限。0 表示不转发。工具的本地输入上限由工具契约决定。"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "该媒体协议与型号已验证的图像能力。未声明的能力没有确认事实。"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"else": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kind",
|
||||
"protocol",
|
||||
"protocolVersion",
|
||||
"modes"
|
||||
],
|
||||
"properties": {
|
||||
"protocol": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
|
||||
"description": "稳定的媒体请求与响应协议族。型号小版本、渠道名称和凭据变化不改变协议标识。"
|
||||
},
|
||||
"protocolVersion": {
|
||||
"type": "string",
|
||||
"pattern": "^[1-9][0-9]*$",
|
||||
"description": "协议的不兼容版本号。请求结构、响应或作业状态合同发生不兼容变更时递增。"
|
||||
},
|
||||
"kind": {
|
||||
"const": "video",
|
||||
"description": "异步视频生成服务。"
|
||||
},
|
||||
"modes": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"text-to-video",
|
||||
"image-to-video",
|
||||
"reference-to-video"
|
||||
]
|
||||
},
|
||||
"description": "已确认支持的文生视频、首尾帧生视频或多素材参考生视频模式。"
|
||||
},
|
||||
"capabilities": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allowMediaOnly": {
|
||||
"type": "boolean",
|
||||
"description": "至少提供一种受支持的有效素材时是否允许省略 prompt。"
|
||||
},
|
||||
"lastFrame": {
|
||||
"type": "boolean",
|
||||
"description": "该协议与型号是否接受尾帧输入。"
|
||||
},
|
||||
"maxReferenceImages": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "本地接受的参考图数量上限。0 表示拒绝该类素材。"
|
||||
},
|
||||
"maxReferenceVideos": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "本地接受的参考视频数量上限。0 表示拒绝该类素材。"
|
||||
},
|
||||
"maxReferenceAudios": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "本地接受的参考音频数量上限。0 表示拒绝该类素材。"
|
||||
},
|
||||
"referenceFileSchemes": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"http",
|
||||
"https",
|
||||
"oss"
|
||||
]
|
||||
},
|
||||
"description": "参考文件接受的 URL scheme。省略表示未声明参考文件能力。"
|
||||
},
|
||||
"referenceLinkSchemes": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"http",
|
||||
"https"
|
||||
]
|
||||
},
|
||||
"description": "参考网页接受的 URL scheme。省略表示未声明参考网页能力。"
|
||||
},
|
||||
"incompatibleInputs": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"left": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"first_frame",
|
||||
"last_frame",
|
||||
"images",
|
||||
"reference_videos",
|
||||
"reference_audios",
|
||||
"reference_file",
|
||||
"reference_link"
|
||||
]
|
||||
},
|
||||
"description": "第一组素材参数。组内任何一项存在就参与互斥判断。"
|
||||
},
|
||||
"right": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"first_frame",
|
||||
"last_frame",
|
||||
"images",
|
||||
"reference_videos",
|
||||
"reference_audios",
|
||||
"reference_file",
|
||||
"reference_link"
|
||||
]
|
||||
},
|
||||
"description": "与第一组互斥的素材参数。"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "素材互斥规则。规则两侧各有至少一项素材时拒绝,组内素材仍可混用。"
|
||||
},
|
||||
"duration": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"minimum",
|
||||
"maximum"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"minimum": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "以秒为单位的最短普通时长,含边界。"
|
||||
},
|
||||
"maximum": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "以秒为单位的最长普通时长,含边界。"
|
||||
},
|
||||
"automaticValues": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"maximum": -1
|
||||
},
|
||||
"description": "可选的自动时长取值,例如 -1 由上游决定时长。"
|
||||
}
|
||||
},
|
||||
"description": "本地支持的整数时长规则。未声明时沿用该调用路径的现有时长处理。"
|
||||
},
|
||||
"seed": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"minimum",
|
||||
"maximum"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"minimum": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "随机种子的最小值,含边界。"
|
||||
},
|
||||
"maximum": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "随机种子的最大值,含边界。"
|
||||
}
|
||||
},
|
||||
"description": "模型原生接受的整数种子范围。"
|
||||
},
|
||||
"queryOriginalJob": {
|
||||
"type": "boolean",
|
||||
"description": "该接入的协议是否声明原视频作业查询能力。仅在本地适配器支持且原授权仍有效时可用。"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "该媒体协议与型号已验证的本地视频规则。未声明的规则不构成对上游能力的承诺。"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"description": "媒体生成的实际请求协议与型号能力。协议、版本和服务种类共同识别本地适配器。"
|
||||
},
|
||||
"thinkingOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user