dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
多模型路由 — DSH multi-model routing plugin: scene-aware model+provider selection, cost-first/speed-first auto-routing, cross-provider failover, two-level menu with favorites. Compatible with dsh-our-free-model.
多模型路由 DeepSeek Harness 插件:场景感知的模型 + 提供商选择, 费用优先 / 速率优先自动路由,跨提供商故障转移,两级套餐·档位菜单。
A DeepSeek Harness plugin for scene-aware multi-model routing with cost-first / speed-first auto-routing, cross-provider failover, and a two-level package·tier selection menu.
纯 META-适配器:注册 mmr 路由,暴露虚拟模型(mmr/coding、mmr/cost:gpt-4o、mmr/speed:deepseek-chat),
其 stream() 解析虚拟模型为真实提供商 + 模型后委托 ctx.llm.stream() 派发。
不持有 API 密钥、不发出任何出站 HTTP 请求。
mmr/<场景>)即委托给最佳可用候选,在首个正文增量前故障转移。mmr/cost:<基础模型> 按费用从低到高自动路由。内置 30+ 热门模型价格表;
未知模型按最贵处理(排在最后,绝不归零)。纯本地,无出站 HTTP。mmr/speed:<基础模型> 按速度从快到慢自动路由。内置最小速度探针
(TTFT + tok/s,防假:排除未流出的推理 token)。TTL 缓存 5 分钟。dsh-our-free-model 路由。connection.admit(与 /api 同级),缺失时回退到回环 + 同源检查。┌─────────────────────────────────────────────────┐
│ index.js (Host 入口) │
│ apply(ctx, config) → registerAdapter(['mmr']) │
│ + webServer /api/mmr/* + emitTopology │
├─────────────────────────────────────────────────┤
│ src/adapter.js — META-适配器 (鸭子类型) │
│ src/router.js — resolveVirtualModel + │
│ orderCandidates + enumerate │
│ src/scenes.js — 场景/虚拟模型定义 │
│ src/failover.js — 链路遍历 + 缓冲+前进 │
│ src/health.js — 分级冷却 + 健康排序 │
│ src/pricing.js — 价格表 + sortByCost │
│ src/speed.js — 探针 + tok/s + sortBySpeed │
│ src/repair.js — 工具配对修复 │
│ src/trust.js — 信任围栏 (admit/loopback) │
│ src/chunk.js — StreamChunk 谓词 │
│ src/store.js — 原子 JSON 存储 (0600) │
│ src/api.js — CRUD HTTP 接口 │
├─────────────────────────────────────────────────┤
│ client.js (Web 半身) │
│ settings.section → "模型路由" 设置页 │
│ conversation.input.right → 快捷选择按钮 │
└─────────────────────────────────────────────────┘
路由器是 META-适配器:它注册在 mmr 路由下,暴露虚拟模型
(mmr/coding、mmr/cost:gpt-4o、mmr/speed:deepseek-chat)。
其 stream() 将虚拟模型解析为真实提供商 + 模型,通过 ctx.llm.stream({provider, model, ...}) 委托派发。
递归安全:解析出的提供商始终是真实路由(deepseek、our-free-model …),绝不是 mmr。
在 DSH 设置 → 插件市场中搜索 dsh-multi-model-router,或粘贴 GitHub 地址安装:
https://github.com/LiyinAlpaca/dsh-multi-model-router
dsh plugin --profile <profile> add github:LiyinAlpaca/dsh-multi-model-router
安装后重启 DSH 一次。--profile 填实际使用的 profile 名称。
⚠️ 不要在 profile 目录运行
npm install。 DSH profile 是 pnpm-only 环境,npm install会无视nodeLinker: hoisted布局并自动安装 peerDependencies, 导致核心运行时包重复注册、对话不可用。请只通过插件市场或dsh plugin命令安装。
@deepseek-ai/cordis、@deepseek-ai/dsh-llm、@deepseek-ai/schemastery 可用。打开 设置 → 模型路由:
| 场景 | ID | 主模型 | 候选链 |
|---|---|---|---|
| 编程 | coding | deepseek/deepseek-chat | deepseek/deepseek-chat, our-free-model/deepseek-v4.1-flash |
| 翻译 | translation | deepseek/deepseek-chat | deepseek/deepseek-chat, gpt-4o-mini |
| 搜索 | search | gpt-4o-mini | gpt-4o-mini, deepseek/deepseek-chat |
| 通用 | general | deepseek/deepseek-chat | deepseek/deepseek-chat, gpt-4o, claude-3-5-sonnet |
enumerateReal() 包含除 mmr 外的所有提供商,
因此 our-free-model 路由是可选候选。无冲突(不同提供商路由)。node test/failover.test.mjs # 45 tests — 链路遍历、缓冲+前进、失败分类
node test/health.test.mjs # 23 tests — 分级冷却、健康分、排序
node test/pricing.test.mjs # 25 tests — 价格表、token 估算、sortByCost
node test/speed.test.mjs # 26 tests — 探针、tok/s、decodeWindow、sortBySpeed
node test/repair.test.mjs # 13 tests — 工具配对修复
node test/api.test.mjs # 26 tests — CRUD、信任围栏、404
node test/smoke.test.mjs # 21 tests — apply() + 适配器契约 + 委托
# Total: 179 tests, 0 failures
全部离线执行,不出网、不消耗任何模型额度。
DSH_HOME/multi-model-router/settings.json(权限 0600),不上传至任何位置。ctx.llm.stream。/api/mmr/*)带信任围栏:优先使用 composition 的 connection.admit(与内核 /api 同级),
缺失时回退到结构化围栏(回环 Host + 同源 Origin 检查)。MIT,见 LICENSE。
本项目为独立插件,与任何模型提供方无隶属、认可或赞助关系。