skillmkt 0.4.8 → 0.4.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/client/commands/init.js +11 -8
- package/package.json +1 -1
package/client/commands/init.js
CHANGED
|
@@ -94,8 +94,8 @@ export async function run(ctx) {
|
|
|
94
94
|
if (base_url && needKey) {
|
|
95
95
|
const ks = await choose(L('这个服务需要访问密钥,怎么提供?', 'This service needs an access key — how should it be provided?'), [
|
|
96
96
|
{ label: L('现在粘贴进来(只输一次,自动加密保存)', 'Paste it now (entered once, saved encrypted)'), v: 'paste' },
|
|
97
|
-
{ label: L('从环境变量 SKILLMKT_API_KEY
|
|
98
|
-
{ label: L('
|
|
97
|
+
{ label: L('从环境变量 SKILLMKT_API_KEY 读', 'Read env var SKILLMKT_API_KEY'), v: 'env:SKILLMKT_API_KEY' },
|
|
98
|
+
{ label: L('从别的环境变量读(自己填变量名)', 'Read another env var (type the name yourself)'), v: 'env-custom' },
|
|
99
99
|
{ label: L('不需要密钥', 'No key needed'), v: null },
|
|
100
100
|
]);
|
|
101
101
|
if (ks.v === 'paste') {
|
|
@@ -113,12 +113,15 @@ export async function run(ctx) {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
} else if (ks.v) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
const vn = ks.v === 'env-custom' ? (await ask(L(' 环境变量名 > ', ' Env var name > '))).trim() : ks.v.slice(4);
|
|
117
|
+
if (vn) {
|
|
118
|
+
api_key = `env:${vn}`;
|
|
119
|
+
keyPlain = process.env[vn] ?? '';
|
|
120
|
+
if (!keyPlain) warn(L(`环境变量 ${vn} 现在没设置——配置照存,export 之后就能用`, `env var ${vn} is not set — config saved anyway; works once you export it`));
|
|
121
|
+
else {
|
|
122
|
+
try { models = await listModels(base_url, keyPlain); }
|
|
123
|
+
catch (e) { warn(L(`用 ${vn} 验证失败(${e.message})——配置照存,模型手填`, `key in ${vn} failed verification (${e.message}) — config saved anyway, type the model manually`)); }
|
|
124
|
+
}
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
127
|
}
|