fix(inference): 同步路径注入prompt便利变量——两路径模板命名空间一致(2026-09-08实测根因)
提取生成器为DashScope生成类模型产的request_template用{{ prompt }}(messages末条
文本),此前只异步路径_build_async_body注入;同步生成路径复用_build_upstream_body
时StrictUndefined渲染崩"Object of type Undefined"(qwen-image-plus实测0.1s失败)。
This commit is contained in:
parent
eb6ca2f4bb
commit
fba76a0cdc
@ -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 '',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user