@goodandready/dsh-model-sync 0.3.1 → 0.3.3
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/lib/adapter-registry.js +25 -11
- package/package.json +1 -1
package/lib/adapter-registry.js
CHANGED
|
@@ -33,6 +33,8 @@ const PROVIDER_ADAPTERS = Object.freeze({
|
|
|
33
33
|
'xiaomi-token-plan-sgp': { endpoint: 'https://token-plan-sgp.xiaomimimo.com/v1/models', auth: 'bearer' },
|
|
34
34
|
zai: { endpoint: 'https://api.z.ai/api/coding/paas/v4/models', auth: 'bearer' },
|
|
35
35
|
'zai-coding-cn': { endpoint: 'https://open.bigmodel.cn/api/coding/paas/v4/models', auth: 'bearer' },
|
|
36
|
+
'kimi-coding': { endpoint: 'https://api.kimi.com/coding/v1/models', auth: 'bearer', defaultModels: ['kimi-k2.6', 'kimi-k2.5', 'kimi-k2.7-code', 'kimi-k3'] },
|
|
37
|
+
minimax: { endpoint: 'https://api.minimax.io/v1/models', auth: 'bearer' },
|
|
36
38
|
})
|
|
37
39
|
|
|
38
40
|
function pathValue(value, path) {
|
|
@@ -139,20 +141,32 @@ async function requestSpecific(profile, descriptor, { resolveCredential, fetchIm
|
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
async function fetchSpecific(profile, descriptor, options) {
|
|
142
|
-
const response = await requestSpecific(profile, descriptor, options)
|
|
143
|
-
const text = await response.text()
|
|
144
|
-
if (Buffer.byteLength(text, 'utf8') > MAX_RESPONSE_BYTES) {
|
|
145
|
-
const error = new Error('model catalog response is too large')
|
|
146
|
-
error.adapterCode = 'schema'
|
|
147
|
-
throw error
|
|
148
|
-
}
|
|
149
144
|
let payload
|
|
150
|
-
try {
|
|
151
|
-
const
|
|
152
|
-
|
|
145
|
+
try {
|
|
146
|
+
const response = await requestSpecific(profile, descriptor, options)
|
|
147
|
+
const text = await response.text()
|
|
148
|
+
if (Buffer.byteLength(text, 'utf8') > MAX_RESPONSE_BYTES) {
|
|
149
|
+
const error = new Error('model catalog response is too large')
|
|
150
|
+
error.adapterCode = 'schema'
|
|
151
|
+
throw error
|
|
152
|
+
}
|
|
153
|
+
try { payload = JSON.parse(text) } catch {
|
|
154
|
+
const error = new Error('model catalog response is not valid JSON')
|
|
155
|
+
error.adapterCode = 'schema'
|
|
156
|
+
throw error
|
|
157
|
+
}
|
|
158
|
+
const rows = parseRows(profile.provider, payload, descriptor)
|
|
159
|
+
if (Array.isArray(rows) && rows.length > 0) return rows
|
|
160
|
+
} catch (error) {
|
|
161
|
+
if (descriptor.defaultModels && Array.isArray(descriptor.defaultModels) && descriptor.defaultModels.length > 0) {
|
|
162
|
+
return normalizeModels(profile.provider, descriptor.defaultModels.map((id) => ({ id })))
|
|
163
|
+
}
|
|
153
164
|
throw error
|
|
154
165
|
}
|
|
155
|
-
|
|
166
|
+
if (descriptor.defaultModels && Array.isArray(descriptor.defaultModels) && descriptor.defaultModels.length > 0) {
|
|
167
|
+
return normalizeModels(profile.provider, descriptor.defaultModels.map((id) => ({ id })))
|
|
168
|
+
}
|
|
169
|
+
return []
|
|
156
170
|
}
|
|
157
171
|
|
|
158
172
|
async function probeSpecific(profile, descriptor, options) {
|