Zum Hauptinhalt springen
S

dsh-llm-compat-healer

semidia/dsh-llm-compat-healer

LLM compatibility auto-healer: detects 400 errors from incorrectly declared model capabilities (thinking/reasoning) on transit/gateway providers, then idempotently patches `llm-pi-ai` config and suppresses thinking on the next request — no restart needed. Full settings UI for every pi-ai compat field.

Installation

dsh plugin --profile web add github:semidia/dsh-llm-compat-healer

README

dsh-llm-compat-healer

LLM 兼容自愈插件:自动检测并修复「中转/网关未正确声明模型能力」导致的请求失败(thinking/reasoning 兼容),并为 llm-pi-ai 配置提供完整的设置页 UI。

解决的问题

使用中转/聚合 API(如某公益中转、某聚合网关)时,如果 provider 的模型列表没有正确声明 reasoningEfforts / compat(如 thinkingFormat: deepseek),DeepSeek 官方 API 会返回:

{"message":"The reasoning_content in the thinking mode must be passed back to the API.","type":"invalid_request_error"}

(400 错误)。本插件自动检测该错误并修复配置,无需手动编辑 settings.yaml

三层机制

  1. agent/request-error 监听(自愈):命中规则表 → 标记问题 provider + 异步幂等补全 llm-pi-ai 配置(只增不改不删); 未命中 → 记录到「未匹配错误」队列供 UI 查看(学习机制)。
  2. agent/request 拦截(当前会话立即恢复):对问题 provider 的请求,在发出前把 thinking 关掉——模型声明了 off 档位则设 reasoningEffort: 'off',否则删除该字段。无需重启。
  3. RPC + 设置页 UI:读写 llm-pi-ai 全部字段、一键补全、扫描全部补齐、查看错误日志。

功能

  • 设置页新增「LLM 兼容」分区(settings.section,id=llm-compat-healer
  • 每个 provider 卡片:
    • thinkingFormat / reasoning 下拉
    • compat 开关组(openai-completions 14 项、responses、anthropic、bedrock 全部字段)
    • 模型行 reasoningEfforts JSON 编辑 + 一键补全
  • 顶部:「扫描全部补齐」「刷新」按钮
  • 「未匹配错误」面板:显示插件检测到但不知如何修复的错误,一键复制

安装

  1. 克隆到 插件开发\dsh-llm-compat-healer\(或任意目录)
  2. 在 profile 的 node_modules 下建 junction:
    New-Item -ItemType Junction -Path "C:\Users\<USER>\.dsh\profiles\web\node_modules\dsh-llm-compat-healer" -Target "D:\plugins\dsh-llm-compat-healer"
    
  3. cordis.patch.yml 追加 insert 条目:
    - id: dsh-llm-compat-healer
      name: dsh-llm-compat-healer
    
  4. 重启 dsh web

开发

node test-unit.mjs    # 28 项单元测试(规则匹配、补全幂等、深合并语义)

验证

  • shot-lch.cjs:页面验收(UI 渲染、无 JS 错误)
  • shot-lch-scan.cjs:scan-fix 功能验收(points 扫描全部补齐,settings.yaml 实际变化)

安全

  • 事件监听器绝不原位修改 payload(经验库十七)
  • settings.update 幂等补全:只增不改不删,不覆盖用户已有配置
  • 未匹配错误只做记录,不做任何修改

License

MIT

Ähnliche Plugins