Skip to content

希望把「关闭」思考档拆成「默认」和「显式关闭」两档 #66

Description

@nameless-name

What do you want? (你想要什么?)

现在自定义模型开启「思考」后,思考等级里只有一档「关闭(off)」,选它之后其实是「什么都不发」,让服务端自己决定——很多服务端默认还会思考,根本关不掉。

希望把这一档拆成两个:

  • 默认(不发送):不传任何思考相关参数,跟随服务端默认行为;
  • 显式关闭:明确告诉服务端「这轮不要思考」。

这样想「真正强制关掉思考」的用户就有得选,想「让服务端自己定」的用户也保留现状。

Why? (为什么?)

我翻了下源码,现在的「关闭」确实等于「不发送」:

  1. openai-completions.ts 内,streamSimple 里直接把 off 转成 undefined
    const reasoningEffort = clampedReasoning === "off" ? undefined : clampedReasoning;
  2. 请求参数构建时,只有 thinkingLevelMap.off 是字符串才会发字段,否则整段省略:
    } else if (!options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) {
      const offValue = model.thinkingLevelMap?.off;
      if (typeof offValue === "string") (params as any).reasoning_effort = offValue;
    }
  3. 而自定义模型 toModel 根本没设 thinkingLevelMap,所以 off 时不发字段。

问题在于:DeepSeek 官方文档写明 Thinking 默认开启、默认 effort high,要关闭必须显式传 thinking:{type:"disabled"};Ollama 也有一模一样的问题(不传 reasoning_effort 就自动开启思考)。所以现在的「关闭」对这类服务端等于「没关」。

How? (怎么做? — 可选)

看内置模型那块源码(openai-completions.ts),各模型的「关闭」写法其实各不相同:

  • DeepSeek:thinking:{type:"disabled"}
  • OpenRouter:reasoning:{effort:"none"}
  • Qwen:enable_thinking:false
  • Together:reasoning:{enabled:false}
  • 标准 OpenAI:reasoning_effort(而且没有 off 值,标准只有 minimal/low/medium/high)

所以「显式关闭」没法一个值通吃,得按端点区分,实现上可能稍微麻烦一点;也可能得让用户在自定义模型里自己配一个「关闭时发送的值」。具体方案请作者定夺。

Alternatives considered (考虑过的替代方案 — 可选)

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions