fix(platform): r2v示例无参考媒体时按DashScope家族契约合成input.media三数组(reference_image/video/audio自由组合,官方API参考确证)——纯文本示例不再只报警,用户填参考媒体即可发出
This commit is contained in:
parent
5086609e49
commit
62bc591f80
@ -1226,8 +1226,36 @@ def _gen_templates(protocol: str, capability: str, spec: dict) -> dict:
|
||||
if rnote:
|
||||
notes.append(rnote)
|
||||
if not media_params and capability in _MEDIA_INPUT_CAPS:
|
||||
notes.append("能力 %s 通常需要输入媒体,但文档示例未见上传字段——"
|
||||
"模板未生成媒体参数,请核对文档" % capability)
|
||||
if capability == 'r2v' and (example or {}).get('input') is not None:
|
||||
# 页面示例是纯文本最简形态(SPA 懒加载抓不到完整示例,wan3.0-video-prime
|
||||
# 实测:概述明写"四模态全能参考"、示例只有 input.prompt)——r2v 必有
|
||||
# 参考媒体,DashScope 家族契约是 input.media 数组 [{type,url}],
|
||||
# 类型集 image→reference_image / video→reference_video / audio→reference_audio。
|
||||
# 复用 _media_array_expr(e2e 验证过的 namespace 混合类型写法)按契约
|
||||
# 合成三数组,比只报警更有用:用户填了参考媒体就能发出去。
|
||||
# 如实注明合成来源,不假装是文档确证。
|
||||
try:
|
||||
import re as _re
|
||||
synth = [{'type': 'reference_image', 'url': 'https://synth.invalid/ref.jpg'},
|
||||
{'type': 'reference_video', 'url': 'https://synth.invalid/ref.mp4'},
|
||||
{'type': 'reference_audio', 'url': 'https://synth.invalid/ref.mp3'}]
|
||||
expr, mps = _media_array_expr(synth)
|
||||
m = _re.search(r'("input"\s*:\s*\{)', req)
|
||||
if expr and m:
|
||||
pos = m.end()
|
||||
req = req[:pos] + '"media": %s, ' % expr + req[pos:]
|
||||
for mp in mps:
|
||||
if mp not in media_params:
|
||||
media_params.append(mp)
|
||||
notes.append("示例未见参考媒体(页面示例为纯文本最简形态),"
|
||||
"r2v 契约合成 input.media 数组(reference_image/"
|
||||
"video/audio 三类,DashScope 家族契约)——"
|
||||
"建议对照供应商 API 参考页人工核对")
|
||||
except Exception as _e:
|
||||
notes.append("r2v 媒体合成失败(%s),示例未见上传字段,请人工核对" % str(_e)[:80])
|
||||
else:
|
||||
notes.append("能力 %s 通常需要输入媒体,但文档示例未见上传字段——"
|
||||
"模板未生成媒体参数,请核对文档" % capability)
|
||||
else:
|
||||
resp = json.dumps({"content": "{{ text }}"}, ensure_ascii=False)
|
||||
# field_enums:文档参数说明表里的可选值(提取层逐字照抄),驱动 code 下拉
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user