fix(uapi): response template follows Sage async task spec — SUCCEEDED/FAILED branches with usage
This commit is contained in:
parent
01e0187dba
commit
e538584360
@ -1,75 +1,25 @@
|
|||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- MiniMax-H3 — uapiio + uapi (data/response Jinja2 templates)
|
-- MiniMax-H3 — 完整 uapi + uapiio 部署 SQL
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
|
|
||||||
-- === uapiio ===
|
-- === 1. uapiio ===
|
||||||
INSERT IGNORE INTO uapiio (id, name, description, input_fields) VALUES (
|
INSERT IGNORE INTO uapiio (id, name, description, input_fields) VALUES (
|
||||||
'm_h3_video_gen_io',
|
'm_h3_video_gen_io',
|
||||||
'MiniMax-H3 视频生成',
|
'MiniMax-H3 视频生成',
|
||||||
'MiniMax-H3 视频生成v2接口。支持文生视频、图生视频(首帧/尾帧)。',
|
'MiniMax-H3 视频生成v2接口。支持文生视频、图生视频(首帧)。',
|
||||||
'[
|
'[
|
||||||
{
|
{"name":"model","label":"模型","uitype":"text","defaultvalue":"MiniMax-H3","hidden":true},
|
||||||
"name": "model",
|
{"name":"prompt","label":"提示词","required":true,"uitype":"text"},
|
||||||
"label": "模型",
|
{"name":"image_files","label":"参考图片(首帧)","uitype":"image"},
|
||||||
"uitype": "text",
|
{"name":"resolution","label":"分辨率","uitype":"code","data":[{"value":"768P","text":"768P"},{"value":"2K","text":"2K"}],"defaultvalue":"768P"},
|
||||||
"defaultvalue": "MiniMax-H3",
|
{"name":"duration","label":"视频时长","uitype":"code","data":[{"value":4,"text":"4秒"},{"value":5,"text":"5秒"},{"value":6,"text":"6秒"},{"value":8,"text":"8秒"},{"value":10,"text":"10秒"},{"value":12,"text":"12秒"},{"value":15,"text":"15秒"}],"defaultvalue":5},
|
||||||
"hidden": true
|
{"name":"ratio","label":"宽高比","uitype":"code","data":[{"value":"adaptive","text":"自适应"},{"value":"21:9","text":"21:9"},{"value":"16:9","text":"16:9"},{"value":"4:3","text":"4:3"},{"value":"1:1","text":"1:1"},{"value":"3:4","text":"3:4"},{"value":"9:16","text":"9:16"}],"defaultvalue":"adaptive"}
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "prompt",
|
|
||||||
"label": "提示词",
|
|
||||||
"required": true,
|
|
||||||
"uitype": "text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "image_files",
|
|
||||||
"label": "参考图片(首帧)",
|
|
||||||
"uitype": "image"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "resolution",
|
|
||||||
"label": "分辨率",
|
|
||||||
"uitype": "code",
|
|
||||||
"data": [
|
|
||||||
{"value": "768P", "text": "768P"},
|
|
||||||
{"value": "2K", "text": "2K"}
|
|
||||||
],
|
|
||||||
"defaultvalue": "768P"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "duration",
|
|
||||||
"label": "视频时长",
|
|
||||||
"uitype": "code",
|
|
||||||
"data": [
|
|
||||||
{"value": 4, "text": "4秒"},
|
|
||||||
{"value": 5, "text": "5秒"},
|
|
||||||
{"value": 6, "text": "6秒"},
|
|
||||||
{"value": 8, "text": "8秒"},
|
|
||||||
{"value": 10, "text": "10秒"},
|
|
||||||
{"value": 12, "text": "12秒"},
|
|
||||||
{"value": 15, "text": "15秒"}
|
|
||||||
],
|
|
||||||
"defaultvalue": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ratio",
|
|
||||||
"label": "宽高比",
|
|
||||||
"uitype": "code",
|
|
||||||
"data": [
|
|
||||||
{"value": "adaptive", "text": "自适应"},
|
|
||||||
{"value": "21:9", "text": "21:9"},
|
|
||||||
{"value": "16:9", "text": "16:9"},
|
|
||||||
{"value": "4:3", "text": "4:3"},
|
|
||||||
{"value": "1:1", "text": "1:1"},
|
|
||||||
{"value": "3:4", "text": "3:4"},
|
|
||||||
{"value": "9:16", "text": "9:16"}
|
|
||||||
],
|
|
||||||
"defaultvalue": "adaptive"
|
|
||||||
}
|
|
||||||
]'
|
]'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- === uapi: 创建视频任务 ===
|
-- === 2. uapi: 创建任务 (async) ===
|
||||||
|
-- data: bricks字段 → MiniMax content数组格式
|
||||||
|
-- response: {{response}} 透传,由 chunk_match='task_id' 提取task_id
|
||||||
INSERT IGNORE INTO uapi (id, upappid, name, title, description, need_auth, stream, path, httpmethod, chunk_match, headers, params, data, response, ioid) VALUES (
|
INSERT IGNORE INTO uapi (id, upappid, name, title, description, need_auth, stream, path, httpmethod, chunk_match, headers, params, data, response, ioid) VALUES (
|
||||||
'm_h3_create_task',
|
'm_h3_create_task',
|
||||||
'minimax',
|
'minimax',
|
||||||
@ -84,28 +34,13 @@ INSERT IGNORE INTO uapi (id, upappid, name, title, description, need_auth, strea
|
|||||||
'{"Content-Type": "application/json", "Authorization": "Bearer {{apikey}}"}',
|
'{"Content-Type": "application/json", "Authorization": "Bearer {{apikey}}"}',
|
||||||
NULL,
|
NULL,
|
||||||
'{
|
'{
|
||||||
"model": "{{model or "MiniMax-H3"}}",
|
"model": "{{model or ''MiniMax-H3''}}",
|
||||||
"content": [
|
"content": [
|
||||||
{% if image_files %}
|
{% if image_files %}{% if isinstance(image_files, str) %}{% set image_files = [image_files] %}{% endif %}{% for img in image_files %}
|
||||||
{% if isinstance(image_files, str) %}
|
{"type": "image_url", "image_url": {"url": "{{b64media2url(request, img)}}"}, "role": "first_frame"}{% if not loop.last or prompt %},{% endif %}{% endfor %}{% endif %}{% if prompt %}
|
||||||
{% set image_files = [image_files] %}
|
{"type": "text", "text": {{json.dumps(prompt)}}}{% endif %}
|
||||||
{% endif %}
|
|
||||||
{% for img in image_files %}
|
|
||||||
{
|
|
||||||
"type": "image_url",
|
|
||||||
"image_url": {"url": "{{b64media2url(request, img)}}"},
|
|
||||||
"role": "first_frame"
|
|
||||||
}{% if not loop.last or prompt %},{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% if prompt %}
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"text": {{json.dumps(prompt)}}
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
],
|
],
|
||||||
"resolution": "{{resolution or "768P"}}",
|
"resolution": "{{resolution or ''768P''}}",
|
||||||
"duration": {{duration or 5}}{% if ratio %},
|
"duration": {{duration or 5}}{% if ratio %},
|
||||||
"ratio": "{{ratio}}"{% endif %}
|
"ratio": "{{ratio}}"{% endif %}
|
||||||
}',
|
}',
|
||||||
@ -113,7 +48,9 @@ INSERT IGNORE INTO uapi (id, upappid, name, title, description, need_auth, strea
|
|||||||
'm_h3_video_gen_io'
|
'm_h3_video_gen_io'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- === uapi: 查询视频任务 ===
|
-- === 3. uapi: 查询任务 (sync) ===
|
||||||
|
-- response: 按Sage async task规范转换
|
||||||
|
-- output.task_status: SUCCEEDED → video+usage, FAILED → error
|
||||||
INSERT IGNORE INTO uapi (id, upappid, name, title, description, need_auth, stream, path, httpmethod, chunk_match, headers, params, data, response, ioid) VALUES (
|
INSERT IGNORE INTO uapi (id, upappid, name, title, description, need_auth, stream, path, httpmethod, chunk_match, headers, params, data, response, ioid) VALUES (
|
||||||
'm_h3_query_task',
|
'm_h3_query_task',
|
||||||
'minimax',
|
'minimax',
|
||||||
@ -129,22 +66,24 @@ INSERT IGNORE INTO uapi (id, upappid, name, title, description, need_auth, strea
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
'{
|
'{
|
||||||
"task_id": "{{response.task.id}}",
|
{% if output.task_status == ''SUCCEEDED'' %}
|
||||||
"status": "{{response.task.status}}",
|
"video": "{{downloadfile2url(request, output.video_url)}}",
|
||||||
"video_url": "{{response.task.content.url}}",
|
"usage": {{json.dumps(output.usage)}},
|
||||||
"resolution": "{{response.task.resolution}}",
|
{% elif output.task_status == ''FAILED'' %}
|
||||||
"duration": {{response.task.duration}},
|
"error": "{{output.code}}:{{output.message}}",
|
||||||
"ratio": "{{response.task.ratio}}"
|
{% endif %}
|
||||||
}',
|
"status": "{{output.task_status}}"
|
||||||
|
}',
|
||||||
'm_h3_video_gen_io'
|
'm_h3_video_gen_io'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- === upapp ===
|
-- === 4. upapp ===
|
||||||
INSERT IGNORE INTO upapp (id, name, baseurl, myappid, ownerid, description) VALUES (
|
INSERT IGNORE INTO upapp (id, name, baseurl, myappid, ownerid, description) VALUES (
|
||||||
'minimax',
|
'minimax', 'minimax', 'https://api.minimax.chat', 'minimax', 'platform',
|
||||||
'minimax',
|
|
||||||
'https://api.minimax.chat',
|
|
||||||
'minimax',
|
|
||||||
'platform',
|
|
||||||
'MiniMax 视频生成平台。提供 H3 视频生成模型。'
|
'MiniMax 视频生成平台。提供 H3 视频生成模型。'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- === 5. upappkey (请替换真实 API Key) ===
|
||||||
|
-- INSERT IGNORE INTO upappkey (id, upappid, orgid, apikey, enabled_date, expired_date) VALUES (
|
||||||
|
-- 'mk_minimax_default', 'minimax', 'platform', '<RC4_ENCODED_KEY>', '2025-01-01', '9999-12-31'
|
||||||
|
-- );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user