dsh-router-core 0.3.9 → 0.3.10
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 +1 -1
- package/lib/client-registry.js +58 -6
- package/lib/client.js +58 -6
- package/lib/index.js +98 -9
- package/lib/suppliers/nvidia.js +6 -1
- package/lib/suppliers/opencode.js +6 -1
- package/lib/suppliers/openrouter.js +6 -1
- package/lib/types/llm/adapter.d.ts +2 -5
- package/lib/types/router/types.d.ts +3 -1
- package/lib/types/supplier-config.d.ts +6 -0
- package/lib/types/suppliers/contract.d.ts +5 -1
- package/package.json +1 -1
- package/src/client/SupplierDetail.tsx +55 -2
- package/src/client/router.css +14 -0
- package/src/index.ts +23 -3
- package/src/llm/adapter.test.ts +17 -0
- package/src/llm/adapter.ts +26 -0
- package/src/router/index.ts +2 -2
- package/src/router/models-cache.test.ts +1 -1
- package/src/router/precise-dispatch.test.ts +2 -2
- package/src/router/types.ts +3 -1
- package/src/router/usage.test.ts +2 -2
- package/src/supplier-config.test.ts +15 -0
- package/src/supplier-config.ts +37 -1
- package/src/suppliers/contract.ts +5 -1
- package/src/suppliers/loader.ts +7 -2
- package/src/suppliers/nvidia/plugin.ts +6 -1
- package/src/suppliers/opencode/plugin.ts +6 -1
- package/src/suppliers/openrouter/plugin.ts +6 -1
|
@@ -82,7 +82,7 @@ export default function factory(env: SupplierEnv): SupplierModule {
|
|
|
82
82
|
listModels: (force?: boolean): Promise<ModelInfo[]> => allModels(!!force),
|
|
83
83
|
// testModel 由 dsh-router 核心统一走 chatOnce 路径(无账号,无需回退)
|
|
84
84
|
/** 无账号供应商:uid 恒为空,只认 free 模型。 */
|
|
85
|
-
async chatOnce(_uid: string, req: ChatRequest): Promise<ChatOnceResult> {
|
|
85
|
+
async chatOnce(_uid: string, lv: string, req: ChatRequest): Promise<ChatOnceResult> {
|
|
86
86
|
// 只认 free 模型,其他模型交给别的供应商
|
|
87
87
|
if (!isFreeModel(req.model)) {
|
|
88
88
|
const msg = `unknown free model ${JSON.stringify(req.model)}`
|
|
@@ -93,6 +93,11 @@ export default function factory(env: SupplierEnv): SupplierModule {
|
|
|
93
93
|
try {
|
|
94
94
|
const obj = JSON.parse(body) as Record<string, unknown>
|
|
95
95
|
obj.model = stripAlias(String(obj.model ?? req.model), currentAlias())
|
|
96
|
+
if (lv !== 'auto' && lv !== '' && lv !== 'none' && lv !== 'off') obj.reasoning_effort = lv
|
|
97
|
+
else if (lv === 'none' || lv === 'off') {
|
|
98
|
+
delete obj.reasoning_effort
|
|
99
|
+
delete obj.reasoning_summary
|
|
100
|
+
}
|
|
96
101
|
body = JSON.stringify(obj)
|
|
97
102
|
} catch {
|
|
98
103
|
// 保持原样
|
|
@@ -150,7 +150,7 @@ export default function factory(env: SupplierEnv): SupplierModule {
|
|
|
150
150
|
return true
|
|
151
151
|
},
|
|
152
152
|
/** 对单个 key 调一次上游。选号/冷却/换号是核心的活,这里只报结果。 */
|
|
153
|
-
async chatOnce(uid: string, req: ChatRequest): Promise<ChatOnceResult> {
|
|
153
|
+
async chatOnce(uid: string, lv: string, req: ChatRequest): Promise<ChatOnceResult> {
|
|
154
154
|
const base = stripAlias(req.model, currentAlias())
|
|
155
155
|
if (!freeIds.has(base) && !(await allModels(false)).some((m) => m.id === base)) {
|
|
156
156
|
const msg = `unknown free model ${JSON.stringify(req.model)}`
|
|
@@ -166,6 +166,11 @@ export default function factory(env: SupplierEnv): SupplierModule {
|
|
|
166
166
|
try {
|
|
167
167
|
const obj = JSON.parse(body) as Record<string, unknown>
|
|
168
168
|
obj.model = base
|
|
169
|
+
if (lv !== 'auto' && lv !== '' && lv !== 'none' && lv !== 'off') obj.reasoning_effort = lv
|
|
170
|
+
else if (lv === 'none' || lv === 'off') {
|
|
171
|
+
delete obj.reasoning_effort
|
|
172
|
+
delete obj.reasoning_summary
|
|
173
|
+
}
|
|
169
174
|
body = JSON.stringify(obj)
|
|
170
175
|
} catch {
|
|
171
176
|
// 保持原样
|