yingclaw 2.5.14 → 2.5.18
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/bin/cli.js +34 -8
- package/lib/config.js +1 -0
- package/lib/gateway.js +4 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -32,6 +32,7 @@ const {
|
|
|
32
32
|
checkDesktopGatewayStatus,
|
|
33
33
|
createGatewayServer,
|
|
34
34
|
ensureDesktopGatewayConfig,
|
|
35
|
+
isDesktopChatModel,
|
|
35
36
|
} = require('../lib/gateway');
|
|
36
37
|
const { runDoctorChecks, summarize, STATUS_OK, STATUS_FAIL, STATUS_WARN, STATUS_INFO } = require('../lib/doctor');
|
|
37
38
|
|
|
@@ -151,6 +152,15 @@ async function promptModelFromChoices({ chalk, choices, message, backLabel = '
|
|
|
151
152
|
}).then(v => v.trim());
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
function getChatModelChoices(models) {
|
|
156
|
+
return models.filter(isDesktopChatModel).map(id => ({ name: id, value: id }));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function formatFetchedModelCount(chalk, total, chatCount) {
|
|
160
|
+
if (total === chatCount) return chalk.green(`已获取 ${chatCount} 个可用聊天模型`);
|
|
161
|
+
return chalk.green(`已获取 ${total} 个模型,其中 ${chatCount} 个可用于 Claude/桌面聊天`);
|
|
162
|
+
}
|
|
163
|
+
|
|
154
164
|
async function promptManualModel(chalk, message, defaultValue) {
|
|
155
165
|
return input({
|
|
156
166
|
message: chalk.cyan(message),
|
|
@@ -185,8 +195,12 @@ async function configureCustomProvider({ chalk, ora, existingConfig }) {
|
|
|
185
195
|
const onlineResult = await fetchModelsFromBaseUrl('custom', apiKey, baseUrl);
|
|
186
196
|
if (onlineResult) {
|
|
187
197
|
modelsUrl = onlineResult.modelsUrl;
|
|
188
|
-
|
|
189
|
-
modelChoices
|
|
198
|
+
modelChoices = getChatModelChoices(onlineResult.models);
|
|
199
|
+
if (modelChoices.length > 0) {
|
|
200
|
+
fetchSpinner.succeed(formatFetchedModelCount(chalk, onlineResult.models.length, modelChoices.length));
|
|
201
|
+
} else {
|
|
202
|
+
fetchSpinner.warn(chalk.yellow(`已获取 ${onlineResult.models.length} 个模型,但没有可用于 Claude/桌面聊天的模型`));
|
|
203
|
+
}
|
|
190
204
|
} else {
|
|
191
205
|
fetchSpinner.warn(chalk.yellow('无法自动获取模型列表,改为手动输入模型'));
|
|
192
206
|
}
|
|
@@ -338,9 +352,15 @@ async function runConfigFlow({ writeCodeEnv = false } = {}) {
|
|
|
338
352
|
const onlineModels = await fetchModels(providerKey, apiKey);
|
|
339
353
|
let modelChoices;
|
|
340
354
|
if (onlineModels && onlineModels.length > 0) {
|
|
341
|
-
|
|
342
|
-
modelChoices
|
|
343
|
-
|
|
355
|
+
modelChoices = getChatModelChoices(onlineModels);
|
|
356
|
+
if (modelChoices.length > 0) {
|
|
357
|
+
fetchSpinner.succeed(formatFetchedModelCount(chalk, onlineModels.length, modelChoices.length));
|
|
358
|
+
availableModels = onlineModels;
|
|
359
|
+
} else {
|
|
360
|
+
fetchSpinner.warn(chalk.yellow(`已获取 ${onlineModels.length} 个模型,但没有可用于 Claude/桌面聊天的模型,使用内置默认列表`));
|
|
361
|
+
modelChoices = provider.models;
|
|
362
|
+
availableModels = provider.models.map(m => m.value);
|
|
363
|
+
}
|
|
344
364
|
} else {
|
|
345
365
|
fetchSpinner.warn(chalk.yellow('无法获取在线列表,使用内置默认列表'));
|
|
346
366
|
modelChoices = provider.models;
|
|
@@ -644,9 +664,15 @@ program
|
|
|
644
664
|
let modelChoices;
|
|
645
665
|
let availableModels;
|
|
646
666
|
if (onlineModels && onlineModels.length > 0) {
|
|
647
|
-
|
|
648
|
-
modelChoices
|
|
649
|
-
|
|
667
|
+
modelChoices = getChatModelChoices(onlineModels);
|
|
668
|
+
if (modelChoices.length > 0) {
|
|
669
|
+
fetchSpinner.succeed(formatFetchedModelCount(chalk, onlineModels.length, modelChoices.length));
|
|
670
|
+
availableModels = onlineModels;
|
|
671
|
+
} else {
|
|
672
|
+
fetchSpinner.warn(chalk.yellow(`已获取 ${onlineModels.length} 个模型,但没有可用于 Claude/桌面聊天的模型,使用内置默认列表`));
|
|
673
|
+
modelChoices = provider.models;
|
|
674
|
+
availableModels = provider.models.map(m => m.value);
|
|
675
|
+
}
|
|
650
676
|
} else {
|
|
651
677
|
fetchSpinner.warn(chalk.yellow('无法获取在线列表,使用内置默认列表'));
|
|
652
678
|
modelChoices = provider.models;
|
package/lib/config.js
CHANGED
|
@@ -327,6 +327,7 @@ async function validateKey(config, options = {}) {
|
|
|
327
327
|
'content-type': 'application/json',
|
|
328
328
|
authorization: `Bearer ${config.apiKey}`,
|
|
329
329
|
'x-api-key': config.apiKey,
|
|
330
|
+
'api-key': config.apiKey,
|
|
330
331
|
'anthropic-version': '2023-06-01',
|
|
331
332
|
},
|
|
332
333
|
body: JSON.stringify({
|
package/lib/gateway.js
CHANGED
|
@@ -59,8 +59,9 @@ function desktopRouteLabel(routeId) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function isDesktopChatModel(model) {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
const value = String(model || '');
|
|
63
|
+
return !/(^|[-_])(tts|voice|voiceclone|voicedesign|speech|audio|image|video|embedding|embed|rerank|moderation)([-_]|$)/i.test(value)
|
|
64
|
+
&& !/(cogview|cogvideo|wanx|flux|sdxl|stable-diffusion)/i.test(value);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
function buildDesktopGatewayRoutes(config) {
|
|
@@ -209,6 +210,7 @@ async function proxyMessages(req, res, config) {
|
|
|
209
210
|
accept: body.stream ? 'text/event-stream' : 'application/json',
|
|
210
211
|
authorization: `Bearer ${config.apiKey}`,
|
|
211
212
|
'x-api-key': config.apiKey,
|
|
213
|
+
'api-key': config.apiKey,
|
|
212
214
|
'anthropic-version': '2023-06-01',
|
|
213
215
|
},
|
|
214
216
|
body: JSON.stringify(body),
|