duojie-helper 0.2.18 → 0.2.20
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 +7 -3
- package/package.json +1 -1
- package/src/index.js +5 -10
- package/src/tools/droid.js +2 -2
package/bin/cli.js
CHANGED
|
@@ -48,8 +48,9 @@ program
|
|
|
48
48
|
type: 'input',
|
|
49
49
|
name: 'apiKey',
|
|
50
50
|
message: '请输入你的 Duojie API Key (Ctrl+C 退出):',
|
|
51
|
+
filter: (input) => input.trim(),
|
|
51
52
|
validate: (input) => {
|
|
52
|
-
if (!input || input.
|
|
53
|
+
if (!input || input.length < 10) {
|
|
53
54
|
return 'API Key 不能为空且长度至少 10 位';
|
|
54
55
|
}
|
|
55
56
|
return true;
|
|
@@ -217,18 +218,21 @@ program
|
|
|
217
218
|
type: 'input',
|
|
218
219
|
name: 'apiKey',
|
|
219
220
|
message: '请输入你的 Duojie API Key:',
|
|
221
|
+
filter: (input) => input.trim(),
|
|
220
222
|
}
|
|
221
223
|
]);
|
|
222
224
|
apiKey = answer.apiKey;
|
|
225
|
+
} else {
|
|
226
|
+
apiKey = apiKey.trim();
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
// 获取模型列表
|
|
226
230
|
const spinner = ora('正在验证 API Key...').start();
|
|
227
|
-
await fetchModels(apiKey
|
|
231
|
+
await fetchModels(apiKey);
|
|
228
232
|
spinner.succeed('验证成功');
|
|
229
233
|
|
|
230
234
|
const configSpinner = ora(`正在配置 ${tool}...`).start();
|
|
231
|
-
const result = await configureTool(tool, apiKey
|
|
235
|
+
const result = await configureTool(tool, apiKey);
|
|
232
236
|
|
|
233
237
|
if (result.success) {
|
|
234
238
|
configSpinner.succeed(result.message);
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -105,12 +105,14 @@ export async function fetchModels(apiKey) {
|
|
|
105
105
|
const id = model.id;
|
|
106
106
|
// 跳过未在 pricing 页面公开的隐藏模型
|
|
107
107
|
if (publicIds && !publicIds.has(id)) continue;
|
|
108
|
+
// 跳过含 image 的模型(图像生成类,不支持对话)
|
|
109
|
+
if (id.toLowerCase().includes('image')) continue;
|
|
108
110
|
const endpoints = model.supported_endpoint_types || [];
|
|
109
111
|
|
|
110
|
-
//
|
|
111
|
-
let api = '
|
|
112
|
+
// 判断最佳协议:GPT 用 openai,其余统一用 anthropic-messages
|
|
113
|
+
let api = 'anthropic-messages'; // 默认
|
|
112
114
|
if (id.startsWith('gpt')) {
|
|
113
|
-
// GPT 模型优先用 openai-
|
|
115
|
+
// GPT 模型优先用 openai-responses,否则 openai-completions
|
|
114
116
|
if (endpoints.includes('openai-response')) {
|
|
115
117
|
api = 'openai-responses';
|
|
116
118
|
} else {
|
|
@@ -118,19 +120,12 @@ export async function fetchModels(apiKey) {
|
|
|
118
120
|
}
|
|
119
121
|
models.gpt.push({ id, name: id, api, endpoints });
|
|
120
122
|
} else if (id.startsWith('claude')) {
|
|
121
|
-
// Claude 模型用 anthropic
|
|
122
|
-
api = 'anthropic-messages';
|
|
123
123
|
models.claude.push({ id, name: id, api, endpoints });
|
|
124
124
|
} else if (id.startsWith('gemini')) {
|
|
125
|
-
// Gemini 模型
|
|
126
|
-
api = endpoints.includes('anthropic') ? 'anthropic-messages' : 'openai-completions';
|
|
127
125
|
models.gemini.push({ id, name: id, api, endpoints });
|
|
128
126
|
} else if (id.startsWith('glm')) {
|
|
129
|
-
// GLM 模型
|
|
130
|
-
api = 'openai-completions';
|
|
131
127
|
models.other.push({ id, name: id, api, endpoints });
|
|
132
128
|
} else {
|
|
133
|
-
api = endpoints.includes('anthropic') ? 'anthropic-messages' : 'openai-completions';
|
|
134
129
|
models.other.push({ id, name: id, api, endpoints });
|
|
135
130
|
}
|
|
136
131
|
}
|
package/src/tools/droid.js
CHANGED
|
@@ -70,8 +70,8 @@ function generateDisplayName(modelId) {
|
|
|
70
70
|
* @returns {string} provider 名称
|
|
71
71
|
*/
|
|
72
72
|
function determineProvider(modelId, endpoints = []) {
|
|
73
|
-
if (modelId.startsWith('
|
|
74
|
-
return '
|
|
73
|
+
if (modelId.startsWith('gpt')) return 'openai';
|
|
74
|
+
return 'anthropic';
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|