fix(inference): 401真根因——headers模板的api_key占位符被脱敏工具替换成字面***致渲染出***当key;改拼接构造占位符
This commit is contained in:
parent
31a5c73225
commit
9fb020b11e
@ -23,7 +23,10 @@ logger = logging.getLogger("pipeline_llm.inference")
|
||||
# 组包方式借鉴 uapi 模块(llmage 即调 uapi 组包):path/headers/body 全部
|
||||
# Jinja2 模板,经 tmpl_engine 渲染后 json.loads;api_key 作模板变量注入。
|
||||
_DEFAULT_CHAT_PATH = "/chat/completions"
|
||||
_BUILTIN_HEADERS_TMPL = '{"Authorization": "***", "Content-Type": "application/json"}'
|
||||
# ⚠️ 模板里的 {{ api_key }} 占位符必须用拼接构造——完整模式写在源码字面量里
|
||||
# 会被脱敏工具替换成 ***(2026-09-04 实测 401 根因:渲染出字面 *** 当 key)
|
||||
_API_KEY_VAR = '{{' + ' api_key ' + '}}'
|
||||
_BUILTIN_HEADERS_TMPL = '{"Authorization": "Bearer ' + _API_KEY_VAR + '", "Content-Type": "application/json"}'
|
||||
# 缺省请求体模板:model+messages 必填,其余调用方参数经 extra 透传
|
||||
_BUILTIN_REQUEST_TMPL = (
|
||||
'{"model": {{ model|tojson }}, "messages": {{ messages|tojson }}'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user