Imzl-zl/dsh-model-router--packages-dsh-model-router ↗★ 1

dsh-model-router

为DSH Agent主请求提供跨服务商的无感容灾切换 适合需要高可用模型调用、在主模型失效时自动切换备用候选模型的任务。

套件
dsh-model-router
相容性
待驗證
Harness 依賴範圍
^0.2.0-rc.2
Cordis 依賴範圍
^4.0.4
版本
0.1.0
授權
MIT
最近更新
2026年10月13日

同名套件的其他儲存庫

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Imzl-zl/dsh-model-router#a73dc8b1bfaf62f37ceaff6521ad978376c58eb8&path:packages/dsh-model-router

Configuration

enabled: true                 # master switch
profiles:                     # matched by exact provider/model
  - id: coding-main
    when: { provider: deepseek-official, model: deepseek-v4-flash }
    candidates:               # [0] is pinned to the when model
      - { provider: deepseek-official, model: deepseek-v4-flash, maxAttempts: 2 }
      - { provider: pi-ai-gpt, model: gpt-5, maxAttempts: 1, needs: { images: true } }
      - { provider: pi-ai-claude, model: claude-sonnet-5, maxAttempts: 1, needs: { minContextTokens: 120000 } }
    switchOn: { rateLimit: true, server: true, timeout: true, transport: true, emptyResponse: false, invalidRequest: false }
    maxTotalAttempts: 6
default:                      # pure fallback pool for unconfigured models
  enabled: false
  candidates:
    - { provider: deepseek-official, model: deepseek-chat, maxAttempts: 1 }
  switchOn: { rateLimit: true, server: true, timeout: true, transport: true, emptyResponse: false, invalidRequest: false }
  maxTotalAttempts: 3
  • candidates[0] of a matched profile must be the when model — your own selection always attempts first, so a switch never happens without a failure.
  • The default pool is pure fallback: the model you picked is always the first hop, with one attempt.
  • Backoff is not configurable: it belongs to llm-retry. Each switch is preceded by one backoff wait (about 0.5–10 s with the default policy).
  • Unchecked switchOn codes never move the chain; DSH still retries the same route per its own default policy (up to 5 times for the default retryable codes) before the request terminates.