dsh-qwenwork-connect 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -103,8 +103,10 @@ npx dsh-qwenwork-connect logout
103
103
 
104
104
  ## 已知限制
105
105
 
106
- - 思考链关不掉。网关侧强制思考,`enable_thinking:false`、
107
- `reasoning_effort:"none"` 这类字段都不生效,只会在输出里多出 reasoning 通道。
106
+ - 思考固定开启,没有档位。网关侧强制思考,请求恒发 `parameters.enable_thinking:true`;
107
+ 上游目录的 `thinking_config` 为 `null`,没有声明任何 effort 档位,插件不提供
108
+ 开关,UI 也不显示推理等级。`enable_thinking:false`、`reasoning_effort:"none"`
109
+ 这类字段上游都不认。
108
110
  - 单次请求的图片预算按网关实测收紧到 6 MB / 32 张;超出时交给宿主的
109
111
  `dsh-compaction-image-offload` 把最旧的图片标成已卸载后重试。宿主没启用
110
112
  这个插件时,图片密集的长会话仍会失败。
package/lib/chat-shim.js CHANGED
@@ -487,8 +487,9 @@ export function resolveModelKey(body) {
487
487
  * 其中 `r` 是上游 catalog 返回的**逐模型**记录。插件不动态拉 catalog,等价物是
488
488
  * models.js 的静态目录(其注释注明取自 App `rawModels` 的 `is_vl` 等实测值):
489
489
  * - `is_vl` ← 目录的 `supportsImages`(App `rawModels.is_vl === true`)
490
- * - `is_reasoning` ← 目录的既有声明:models.js 的 `toPiModel()` 对全部模型
491
- * 置 `reasoning: true`(实测上游确实返回 `reasoning_content`)
490
+ * - `is_reasoning` ← 固定 true:思考始终开启,与 models.js 的 `reasoning:false`
491
+ * 不冲突(后者只是让 DSH 不生成推理等级菜单;pi-ai 仍会
492
+ * 解析上游的 `reasoning_content`,思考块照常显示)
492
493
  *
493
494
  * 目录里查不到的模型按 SDK 的兜底取 `false`——不凭空声明能力。注意
494
495
  * `is_reasoning` 还会被 SDK 按 `thinkingBudget === 0` / `reasoning_effort === "none"`
package/lib/models.js CHANGED
@@ -235,14 +235,23 @@ export function toPiModel(info, baseUrl, opts = {}) {
235
235
  baseUrl,
236
236
  input: supportsImages ? ['text', 'image'] : ['text'],
237
237
  /**
238
- * 上游确实返回思维链,置 true 让 pi-ai 把 `reasoning_content` 识别为
239
- * 独立的 thinking 块,而不是混进正文渲染。
238
+ * 上游确实返回思维链(`reasoning_content`),但 pi-ai 把它解析成独立
239
+ * thinking 块**不依赖这个标志**:openai-completions 的解析分支无条件读取
240
+ * `reasoning_content`(实测 reasoning:false 时 thinking 块照常产出)。
240
241
  *
241
- * 实测依据:glm-5.2 在 `choices[0].delta.reasoning_content` 里给出思维链
242
- * (见 research/probe-reasoning-vs-content.mjs)。此前置 false 时,思维链
243
- * 会被当作普通 text 输出,用户会在回答里看到模型的内心独白。
242
+ * 这里置 false 只有一个目的:让 DSH 不生成「推理等级」菜单。
243
+ *
244
+ * 原因:上游模型目录里所有模型的 `thinking_config` 都是 null,没有声明
245
+ * 任何 effort 档位。DSH 对 `reasoning:true` 且没有 `thinkingLevelMap`
246
+ * 的模型会自动补出 off/minimal/low/medium/high,但上游并不认这些档位,
247
+ * 属于假开关。置 false 后 DSH 的 `reasoningInfo` 返回空,UI 不再出现
248
+ * 推理等级;把 `thinkingLevelMap` 全设 null 反而会得到空 efforts,
249
+ * dsh-llm 会直接抛 `INVALID_MODEL_REASONING`。
250
+ *
251
+ * 思考本身固定开启:请求体 `parameters.enable_thinking` 恒为 true
252
+ * (见 signer-session.js 的 buildInferBody),不提供开关、不做回退。
244
253
  */
245
- reasoning: true,
254
+ reasoning: false,
246
255
  /**
247
256
  * 思考开关握手(QwenWork 网关不支持,2026-11-08 实测):
248
257
  *
@@ -256,7 +265,8 @@ export function toPiModel(info, baseUrl, opts = {}) {
256
265
  * probe-flash-thinking.mjs:flash 模型 3 变体):QwenWork 网关对
257
266
  * `enable_thinking:false`、`chat_template_kwargs.enable_thinking:false`、
258
267
  * `reasoning_effort:"none"`、`is_reasoning:false` 全部无视,思考照发。
259
- * 所以这里**刻意不声明** compat.thinkingLevelMap / thinkingFormat:发了
268
+ * 所以这里**刻意不声明** compat.thinkingLevelMap / thinkingFormat,并且把
269
+ * `reasoning` 置 false,避免 DSH 自动补出上游并不支持的通用档位:发了
260
270
  * 也是无效字段,反而让 pi-ai 以为关思考已生效。上游强制思考,
261
271
  * 宿主端的正确姿态是容忍 thinking 通道(pi-hermes-memory 的
262
272
  * thinking-channel recovery 那样从 thinking 块恢复答案)。
@@ -344,11 +344,13 @@ export function buildInferBody(params) {
344
344
  tools: Array.isArray(params.tools) ? params.tools : [],
345
345
  // ── §3.8 parameters ───────────────────────────────────────────────
346
346
  // 确定最小形态是 `{ max_tokens }`;`context_length` 是产品额外声明的窗口。
347
+ // `enable_thinking` 固定 true:千问办公网关强制思考,关不掉(2026-11-08
348
+ // 五变体实测),插件也不提供开关;显式发 true 比依赖上游默认更明确。
347
349
  //
348
350
  // ⚠️ context_length 的计量单位是 **Qwen 的 token**,与 DSH 用的 tokenizer
349
351
  // 不是同一套;不能拿 DSH 的 token 计数直接填。当前策略是固定 1M、按消息
350
352
  // 估算窗口的实现需要额外接 Qwen tokenizer,这里不做。
351
- parameters: { max_tokens: maxOutput, context_length: maxInput },
353
+ parameters: { enable_thinking: true, max_tokens: maxOutput, context_length: maxInput },
352
354
  // ── §3.13 business(**503 根因字段**)─────────────────────────────
353
355
  // SDK 的写法是条件展开 `...void 0!==m?{business:m}:{}`,但服务端要求它存在
354
356
  // 且含 `product`:缺失即 503(§1.1b.1 实测)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-qwenwork-connect",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "千问办公(QwenWork)的 DSH 模型提供方:device flow 登录、官方网关、支持工具调用",
5
5
  "license": "MIT",
6
6
  "author": "AaIchhe",