From 825dd2e130fecdfef108eab765d35119464b4b50 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 6 Sep 2026 10:23:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(llm):=20=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E5=88=AB=E5=90=8D=E5=BD=92=E4=B8=80=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E4=B8=BA=E4=B8=89=E6=95=B0=E7=BB=84=E5=A5=91=E7=BA=A6?= =?UTF-8?q?=E2=80=94=E2=80=94xxx=5Ffile/xxx=5Furl=E2=86=92xxx=5Ffiles,medi?= =?UTF-8?q?a=E6=95=B0=E7=BB=84=E6=8C=89type=E5=88=86=E7=BB=84=E8=BF=9Bimag?= =?UTF-8?q?e=5Ffiles/video=5Ffiles/audio=5Ffiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_llm/inference.py | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/pipeline_llm/inference.py b/pipeline_llm/inference.py index 1470738..a7f2b7b 100644 --- a/pipeline_llm/inference.py +++ b/pipeline_llm/inference.py @@ -92,15 +92,42 @@ def _media_ns_extra(): def _normalize_media_aliases(upstream): - """同类接口对外契约统一(2026-09-05 用户规则):上传媒体一律 xxx_file 命名。 + """同类接口对外契约统一(2026-09-06 用户定夺,对齐 sage/llmage): + 上传媒体一律三数组参数 image_files / audio_files / video_files, + 值为字符串或数组均可(模板 Jinja 动态判断两种形态)。 - 旧别名 xxx_url 归一到 xxx_file——同能力模板写法一致(如 i2v 统一 - image_file 进 → video 出),模板不用为同一类能力写多套参数名。 + 旧别名归一:xxx_file / xxx_url(单值)→ xxx_files(数组); + DashScope 形态的 media 数组([{"type": "reference_image", "url": ...}] + 或纯 URL 列表)→ 按 type 分组进三数组(r2v 实测调用方直接传 media)。 """ for media in ('image', 'video', 'audio'): - fk, uk = media + '_file', media + '_url' - if not upstream.get(fk) and upstream.get(uk): - upstream[fk] = upstream.get(uk) + files_k = media + '_files' + if not upstream.get(files_k): + for alt in (media + '_file', media + '_url'): + v = upstream.get(alt) + if v: + upstream[files_k] = [v] if isinstance(v, str) else list(v) + break + m = upstream.get('media') + if m and not any(upstream.get(x + '_files') for x in ('image', 'video', 'audio')): + groups = {'image': [], 'video': [], 'audio': []} + items = m if isinstance(m, list) else [m] + for it in items: + if isinstance(it, str) and it.strip(): + groups['image'].append(it) + elif isinstance(it, dict): + url = next((v for v in it.values() + if isinstance(v, str) and v.strip().lower().startswith( + ('http://', 'https://', 'data:', 'asset://', '/'))), '') + if not url: + continue + t = str(it.get('type') or '').lower() + g = 'video' if 'video' in t else ('audio' if 'audio' in t else 'image') + groups[g].append(url) + for media, lst in groups.items(): + if lst: + upstream[media + '_files'] = lst + upstream.pop('media', None) def _texts_len(messages):