feat(config): 模型新增 reasoning_ack_field——历史轮思维链按配置字段名回传(逐模型 opt-in,纯配置闸门)
This commit is contained in:
@@ -223,6 +223,10 @@ function normalizePlatforms(rawPlatforms, profileNames) {
|
||||
extra_params: (m.extra_params && typeof m.extra_params === 'object' && !Array.isArray(m.extra_params)) ? m.extra_params : {},
|
||||
// 选填:前端启用「深度思考」时合并进 body。可覆盖 extra_params 的同名键。
|
||||
thinking_params: (m.thinking_params && typeof m.thinking_params === 'object' && !Array.isArray(m.thinking_params)) ? m.thinking_params : {},
|
||||
// 选填:思维链回传字段名(如 reasoning_content——DeepSeek 系平台要求历史轮把思考链喂回)。
|
||||
// 非空时发请求前给历史 assistant 行挂该字段;空(缺省)= 不回传。纯发送侧旋钮,
|
||||
// 与接收解析无关(接收早已兼容 reasoning/reasoning_content 双名)。
|
||||
reasoning_ack_field: typeof m.reasoning_ack_field === 'string' ? m.reasoning_ack_field.trim() : '',
|
||||
profile,
|
||||
});
|
||||
}
|
||||
@@ -270,6 +274,7 @@ function parseAndValidate(rawText, configPath) {
|
||||
id: p.name + '/' + m.id, mid: m.id,
|
||||
display_name: m.display_name, vision: m.vision, enable: m.enable,
|
||||
extra_params: m.extra_params, thinking_params: m.thinking_params,
|
||||
reasoning_ack_field: m.reasoning_ack_field,
|
||||
profile: m.profile,
|
||||
url: p.url, api_key: k.api_key, platform: p.name, type: p.type, concurrency: k.concurrency,
|
||||
platform_index: pi, key_index: ki, model_index: mi,
|
||||
|
||||
@@ -249,6 +249,9 @@ function buildMessages(session, language, mintUrl, profile, withProfile, trimOn)
|
||||
return;
|
||||
}
|
||||
const m = { role: 'assistant', content: row.content || '' };
|
||||
// 思维链回传原料:存库 reasoning 随原样带给 callModel(中性内部键,按模型
|
||||
// reasoning_ack_field 改名注入后此键必被剥除,不会泄往上游)。
|
||||
if (row.reasoning) m.__reasoning = row.reasoning;
|
||||
if (row.tool_calls) {
|
||||
m.tool_calls = JSON.parse(row.tool_calls);
|
||||
if (trimActive && TRIM.writeRounds > 0) trimWriteCalls(m.tool_calls, roundsAfter.get(row.id) || 0);
|
||||
@@ -518,6 +521,19 @@ async function callModel(cfg, modelId, messages, tools, options) {
|
||||
if (opts.deepThink && modelCfg.thinking_params && Object.keys(modelCfg.thinking_params).length) {
|
||||
deepMergeInto(body, modelCfg.thinking_params);
|
||||
}
|
||||
// 思维链回传(逐模型 opt-in,纯配置闸门不看 tools):reasoning_ack_field 非空时,把
|
||||
// buildMessages 挂的内部键 __reasoning 按该字段名写回 assistant 行(对话/压缩/标题回合同规则;
|
||||
// 没配/无思考的行零变化)。无论配与否都剥一遍 __reasoning,内部键不出仓库。
|
||||
if (body.messages && body.messages.length) {
|
||||
const ack = modelCfg.reasoning_ack_field;
|
||||
body.messages = body.messages.map(mm => {
|
||||
if (!mm || !mm.__reasoning) return mm;
|
||||
const c = Object.assign({}, mm);
|
||||
if (ack) c[ack] = c.__reasoning;
|
||||
delete c.__reasoning;
|
||||
return c;
|
||||
});
|
||||
}
|
||||
|
||||
const headers = { 'Content-Type': 'application/json' };
|
||||
if (modelCfg.api_key) headers.Authorization = 'Bearer ' + modelCfg.api_key;
|
||||
|
||||
Reference in New Issue
Block a user