dsh-custom-provider-reasoning:给 DSH 自定义提供方补齐推理等级

前言

在 DSH 中,composer 的模型选择器需要依赖模型侧的推理元数据,才能显示可选的思考强度。对于自定义提供方,这类模型往往缺少 reasoningEfforts 声明,导致无法在界面中选择推理等级。

dsh-custom-provider-reasoning 是一个 DSH host 插件,用来补齐这一缺口:让自定义提供方的模型都能在模型选择器中选取思考强度(reasoning effort),并让选择真正发往线上。

这是什么

dsh-custom-provider-reasoning534119219 维护,许可证为 MIT。

它面向 DSH 的自定义提供方,解决三类问题:

  • 模型没有可选推理等级;
  • 手写路由缺少 maxTokenscontextWindow
  • 不同协议下需要手工维护路由级 compat

它依赖以下包:

  • @deepseek-ai/schemastery ^3.18.1
  • @earendil-works/pi-ai ^0.82.1

核心功能

下面介绍它已支持的能力。

  • 让自定义提供方的所有模型在 composer 模型选择器中选择思考强度,也就是推理等级。
  • 选择会经原厂适配器真正发往线上。
  • 自动为合格模型条目写入 reasoningEfforts,默认等级为 off / low / medium / high / xhigh / max
  • 自动补齐缺失的 maxTokenscontextWindow,默认值分别为 3840001000000
  • 感知协议类型并管理路由级 compat:在 openai-completions 下可为 deepseek 模型补 thinkingFormat: deepseek,并为 declared 路由补 supportsDeveloperRole: false
  • openai-completionsopenai-responsesanthropic-messages 协议之间切换时,自动剥离不适用的 thinkingFormat / supportsReasoningEffort
  • 支持通过 profile 的 cordis.patch.yml 或插件设置页配置 enabledscopeverifymaxTokenscontextWindowthinkingFormatdefaultEffortsupportsDeveloperRolelevels
  • 注入是幂等的:已有 reasoningEfforts,或手写的 maxTokens / contextWindow,不会被覆盖。

安装与启用

插件需要加入 web profile,默认路径是 ~/.dsh/profiles/web

先在 ~/.dsh/profiles/web/package.jsondependencies 中加入依赖:

"dsh-custom-provider-reasoning": "github:534119219/dsh-custom-provider-reasoning"

然后确认 dsh.profile.bundles 中包含插件名。实际写入时,请把该项追加到已有 bundles 列表末尾:

{
  "dsh": {
    "profile": {
      "bundles": [
        "dsh-custom-provider-reasoning"
      ]
    }
  }

在 profile 目录执行安装:

cd ~/.dsh/profiles/web
pnpm install

重启 DSH web:

dsh web

启动后,插件会自动把 reasoningEfforts 写入 ~/.dsh/settings.yaml 的自定义路由模型条目。

典型用法

启动后打开 composer,选择自定义提供方的模型,即可在模型选择器中查看推理等级,例如 Default / Off / Low / Medium / High

如果端点不认 reasoning_effort,可以在 settings.yaml 中将该模型的 reasoningEfforts 改成端点支持的拼写,也可以直接设为 false 关闭:

llm-pi-ai:
  providers:
    scnet:
      models:
        - id: DeepSeek-V4-Pro
          reasoningEfforts:
            off:
            low: low
            medium: medium
            high: high

这个示例只用于说明配置形态。具体字段名、模型 id 和端点能力,以你的 settings.yaml 和端点实际支持为准。

配置

插件可以通过 profile 的 cordis.patch.yml 或插件设置页配置:

- id: dsh-custom-provider-reasoning
  name: 'dsh-custom-provider-reasoning'
  config:
    enabled: true
    scope: declared
    verify: false
    maxTokens: 384000
    contextWindow: 1000000
    thinkingFormat: false
    defaultEffort: max
    supportsDeveloperRole: false
    levels:
      off:
      low: low
      medium: medium
      high: high
      xhigh: xhigh
      max: max

几个关键点:

  • enabled 是总开关,默认 true
  • maxTokenscontextWindow 只在对应字段缺失时回填;已有手写值不会被覆盖。
  • defaultEffort 管理路由级默认推理等级,默认 max;路由未声明时写入,已有值不覆盖;设 false 则关闭该管理。
  • supportsDeveloperRole 默认 false,即自动为 declared 路由补 compat.supportsDeveloperRole: false;设 true 则补 true
  • thinkingFormat 默认 false,不自动写 thinkingFormat;如果端点确实需要 DeepSeek 方言,可以改成 deepseek
  • levels 的键必须是 pi-ai 的思考等级,且除 off 外至少有一个等级,否则插件拒绝启动。

适用场景与注意

适合使用 DSH host、通过自定义提供方接入模型,并且希望在 composer 中直接选择推理等级的场景。

安装前注意:插件以当前 DSH 进程权限运行,建议先检查源码与许可证,再决定是否加入 profile。

还需要注意:

  • 默认按 OpenAI 兼容 reasoning_effort 词汇注入;如果端点不认 reasoning_effort,请求可能报错。
  • new-api / one-api 系网关会拒绝 developer 角色;插件会自动为 declared 路由补 compat.supportsDeveloperRole: false
  • maxTokens / contextWindow 只在字段缺失时回填,已有手写值不被覆盖。
  • 已有 reasoningEfforts 手写值始终权威;唯一例外是恰好等于内置默认字典的条目,会在 levels 变化时刷新。
  • 重启 GUI 用于加载插件本身;新增或编辑自定义提供方无需重启。

结尾

dsh-custom-provider-reasoning 的价值,是把自定义提供方缺少推理等级、缺 token/context 字段、以及协议切换时 compat 难维护这些问题,收敛到 DSH host 插件里统一处理。

仓库地址:https://github.com/534119219/dsh-custom-provider-reasoning

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜