v1.4 禁用推理模式

This commit is contained in:
2026-11-23 23:46:40 +08:00
parent 007b9896e3
commit f47f1838db
9 changed files with 139 additions and 44 deletions
+19
View File
@@ -57,6 +57,18 @@ export const REQUEST_TIMEOUT = 300000
*/
export const STREAM_IDLE_TIMEOUT = 60000
/**
* 必须关闭 thinking 的模型名(小写子串匹配)。
*
* 这些模型开 thinking 后,`max_tokens` 被 reasoning_content 吃光、content 反而为空
* (DeepSeek 实测:low 档 reasoning 可吐 8192,content 为 0)⇒ 功能性饿死,不是钱的问题。
* 只发 `thinking:{type:'disabled'}`,不发 `reasoning_effort`(它最低 low,关不掉)。
*
* 黑名单机制:只有命中的模型改行为,agnes 及未知模型保持「不带 thinking 字段」的
* 现状。将来挂新模型若需开 thinking,再连同 SSE 解析回传一并调试。
*/
const NO_THINKING_MODELS = ['deepseek']
/** 流式空闲看门狗。 */
export interface StreamWatchdog {
/** 空闲超时或外部 signal 中止时 abort。 */
@@ -251,6 +263,13 @@ function createRequestPayload(config: AppConfig, messages: OpenAIMessage[], tool
stream: config.stream,
}
// 关掉 thinking:黑名单命中才写;agnes / 未知模型不带此字段,行为与现状一致。
// 裸 fetch 没有 SDK 的 extra_body 平铺层,字段必须放顶层才被 one-api 识别。
const lower = config.model?.toLowerCase() ?? ''
if (NO_THINKING_MODELS.some((m) => lower.includes(m))) {
payload.thinking = { type: 'disabled' }
}
// ⚠️ 只在真的带了工具时才写这两个字段。
// 写 `tools: []` 会被部分网关当成「有工具但没有可选」,行为与「不带工具」不同。
if (toolOptions?.tools?.length) {