sulfide2085/dsh-llm-wechat ↗★ 3
@deepseek-ai/dsh-llm-wechat
DeepSeek-compatible adapter for the WeChat (chatapi.weixin.qq.com) gateway, with think-tag translation for the DeepSeek Harness LLM seam
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:sulfide2085/dsh-llm-wechat说明文档
阅读完整 README ↗@deepseek-ai/dsh-llm-wechat
中文 | English
独立公开仓库:本插件从项目内独立维护,源码位于
dsh-llm-wechat仓库。
DeepSeek Harness 的微信网关适配插件:让 DSH 把微信小程序「Coding Plan」的 Deepseek-v4-flash(chatapi.weixin.qq.com)当作官方 DeepSeek 使用——思考进思考块、工具调用正常、正文无标签。
复用官方 dsh-llm-deepseek 的 DeepSeekAdapter(请求序列化、错误映射、模型解析、重试策略全部继承),只在响应侧加了一层流式转译。不修改任何 DSH / pi-ai 源码。
为什么需要这个插件
微信网关的返回有三个官方 DeepSeek 没有的怪癖,DSH 原生解析器无法处理:
| 微信的怪癖 | 插件处理 |
|---|---|
思考内容不放 reasoning_content,而是连同 `` 标签整个塞进 content | 流式拦截器把 `` 之前的文本剥离并重排进 reasoning_content,正文只留纯净答案 |
工具调用流式 delta 的后续片段显式发 id: null / name: null,覆盖首个 delta 的正确值 | 只接受非空字符串更新 id/name |
DSH 的工具结果以 tool-result 块存放,序列化时需展开为 role: tool 消息 | 对齐官方完整版(含 (no output) 兜底) |
工作原理
微信流: "We need answer... final. 141.3717" (思考+标签全在 content)
│
▼ WechatAdapter.request(拦截器:parseSse 与 translate 之间)
DSH 流: reasoning_content: "We need answer... final."
content: "141.3717" (标准格式,DSH 上层无感)
- 请求侧:微信端点协议与官方 DeepSeek 完全一致(OpenAI 兼容),原样透传,仅映射思考档位
off/high/max→thinking: {type}+reasoning_effort。 - 响应侧:
translate前插入ThinkTagSplitter状态机(处理标签跨 chunk 被切开、思考含尖括号、思考未闭合兜底等边界)。 - system 增强:微信模型对"工具只能通过 run_code 调用"的遵循较弱,插件在 system 末尾追加一段强约束(仅 wechat 通道生效)。
安装
方式一:dsh plugin(推荐,官方规范)
# 在包含 dsh-llm-wechat 目录的位置执行
dsh plugin --profile web add ./dsh-llm-wechat
dsh plugin add 会把包以 link: 方式装进 profile,并把 dsh.bundle 声明的 patch 层(cordis.patch.yml)追加到 dsh.profile.bundles——无需手动改任何文件。
发布到 npm 后(待发布):
dsh plugin --profile web add @deepseek-ai/dsh-llm-wechat