From fba76a0cdcc42fd6fd42bbafe301d2544591d53d Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 8 Sep 2026 13:38:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(inference):=20=E5=90=8C=E6=AD=A5=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E6=B3=A8=E5=85=A5prompt=E4=BE=BF=E5=88=A9=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E2=80=94=E2=80=94=E4=B8=A4=E8=B7=AF=E5=BE=84=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4=E4=B8=80=E8=87=B4?= =?UTF-8?q?(2026-09-08=E5=AE=9E=E6=B5=8B=E6=A0=B9=E5=9B=A0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提取生成器为DashScope生成类模型产的request_template用{{ prompt }}(messages末条 文本),此前只异步路径_build_async_body注入;同步生成路径复用_build_upstream_body 时StrictUndefined渲染崩"Object of type Undefined"(qwen-image-plus实测0.1s失败)。 --- pipeline_llm/inference.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pipeline_llm/inference.py b/pipeline_llm/inference.py index f436351..b988d4e 100644 --- a/pipeline_llm/inference.py +++ b/pipeline_llm/inference.py @@ -350,8 +350,13 @@ async def _build_upstream_body(ctx, payload): 合并顺序:模型 default_params 打底 → 调用方显式参数覆盖 → 模板渲染。 模板取 profile.request_template,缺省内置 openai-chat 模板。 - 模板命名空间:model / messages / extra(白名单透传参数) / params(全部) / - api_key / org_id。 + 模板命名空间:model / messages / prompt / extra(白名单透传参数) / + params(全部) / api_key / org_id。 + ⚠️ prompt 便利变量必须注入(2026-09-08 实测根因):提取生成器为 + DashScope 生成类模型产的 request_template 用 {{ prompt }}(messages + 末条文本),此前只有异步路径 _build_async_body 注入——同步生成路径 + 复用本函数时 StrictUndefined 渲染崩「Object of type Undefined」。 + 两路径命名空间必须一致。 """ profile = ctx.get('profile') or {} tmpl = (profile.get('request_template') or '').strip() or _BUILTIN_REQUEST_TMPL @@ -365,6 +370,7 @@ async def _build_upstream_body(ctx, payload): extra = {k: upstream[k] for k in upstream if k in _PASSTHROUGH_FIELDS} ns = { 'model': model, 'messages': messages, 'extra': extra, + 'prompt': _last_prompt_text(messages), 'params': upstream, 'api_key': ctx.get('api_key') or '', 'org_id': ctx.get('org_id') or '',