oh-pi 0.1.43 → 0.1.44
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/dist/i18n.js +3 -0
- package/dist/tui/provider-setup.js +24 -2
- package/dist/utils/install.js +1 -0
- package/package.json +1 -1
package/dist/i18n.js
CHANGED
|
@@ -28,6 +28,7 @@ const messages = {
|
|
|
28
28
|
"provider.foundEnv": "Found {env} in environment. Use it?",
|
|
29
29
|
"provider.customEndpoint": "Custom endpoint for {label}? (proxy, Azure, etc.)",
|
|
30
30
|
"provider.baseUrl": "Base URL for {label}:",
|
|
31
|
+
"provider.useCustomUrl": "Use a custom endpoint for {label}? (proxy, self-hosted, etc.)",
|
|
31
32
|
"provider.baseUrlPlaceholder": "https://your-proxy.example.com",
|
|
32
33
|
"provider.baseUrlValidation": "Must be a valid URL",
|
|
33
34
|
"provider.configured": "{label} configured",
|
|
@@ -164,6 +165,7 @@ const messages = {
|
|
|
164
165
|
"provider.foundEnv": "在环境变量中找到 {env},是否使用?",
|
|
165
166
|
"provider.customEndpoint": "为 {label} 设置自定义端点?(代理、Azure 等)",
|
|
166
167
|
"provider.baseUrl": "{label} 的 Base URL:",
|
|
168
|
+
"provider.useCustomUrl": "是否使用自定义端点?(代理、自托管等)",
|
|
167
169
|
"provider.baseUrlPlaceholder": "https://your-proxy.example.com",
|
|
168
170
|
"provider.baseUrlValidation": "必须是有效的 URL",
|
|
169
171
|
"provider.configured": "{label} 配置完成",
|
|
@@ -292,6 +294,7 @@ const messages = {
|
|
|
292
294
|
"provider.foundEnv": "{env} trouvé dans l'environnement. L'utiliser ?",
|
|
293
295
|
"provider.customEndpoint": "Point d'accès personnalisé pour {label} ? (proxy, Azure, etc.)",
|
|
294
296
|
"provider.baseUrl": "URL de base pour {label} :",
|
|
297
|
+
"provider.useCustomUrl": "Utiliser un endpoint personnalisé pour {label} ? (proxy, auto-hébergé, etc.)",
|
|
295
298
|
"provider.baseUrlPlaceholder": "https://your-proxy.example.com",
|
|
296
299
|
"provider.baseUrlValidation": "Doit être une URL valide",
|
|
297
300
|
"provider.configured": "{label} configuré",
|
|
@@ -61,8 +61,30 @@ export async function setupProviders(env) {
|
|
|
61
61
|
}
|
|
62
62
|
const info = PROVIDERS[name];
|
|
63
63
|
const envVal = process.env[info.env];
|
|
64
|
+
// Ask if user wants a custom endpoint for this provider
|
|
65
|
+
const useCustomUrl = await p.confirm({
|
|
66
|
+
message: t("provider.useCustomUrl", { label: info.label }),
|
|
67
|
+
initialValue: false,
|
|
68
|
+
});
|
|
69
|
+
if (p.isCancel(useCustomUrl)) {
|
|
70
|
+
p.cancel(t("cancelled"));
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
let baseUrl;
|
|
74
|
+
if (useCustomUrl) {
|
|
75
|
+
const url = await p.text({
|
|
76
|
+
message: t("provider.baseUrl", { label: info.label }),
|
|
77
|
+
placeholder: "https://proxy.example.com",
|
|
78
|
+
validate: (v) => (!v || !v.startsWith("http")) ? t("provider.baseUrlValidation") : undefined,
|
|
79
|
+
});
|
|
80
|
+
if (p.isCancel(url)) {
|
|
81
|
+
p.cancel(t("cancelled"));
|
|
82
|
+
process.exit(0);
|
|
83
|
+
}
|
|
84
|
+
baseUrl = url;
|
|
85
|
+
}
|
|
64
86
|
let apiKey;
|
|
65
|
-
if (envVal) {
|
|
87
|
+
if (envVal && !baseUrl) {
|
|
66
88
|
const useEnv = await p.confirm({ message: t("provider.foundEnv", { env: chalk.cyan(info.env) }) });
|
|
67
89
|
if (p.isCancel(useEnv)) {
|
|
68
90
|
p.cancel(t("cancelled"));
|
|
@@ -75,7 +97,7 @@ export async function setupProviders(env) {
|
|
|
75
97
|
}
|
|
76
98
|
// Model selection — try dynamic fetch, fall back to static list
|
|
77
99
|
const defaultModel = await selectModel(info.label, info.models, undefined, apiKey);
|
|
78
|
-
configs.push({ name, apiKey, defaultModel });
|
|
100
|
+
configs.push({ name, apiKey, defaultModel, baseUrl });
|
|
79
101
|
p.log.success(t("provider.configured", { label: info.label }));
|
|
80
102
|
}
|
|
81
103
|
return configs;
|
package/dist/utils/install.js
CHANGED
|
@@ -107,6 +107,7 @@ export function applyConfig(config) {
|
|
|
107
107
|
name: cp.defaultModel,
|
|
108
108
|
reasoning: cp.reasoning ?? caps?.reasoning ?? false,
|
|
109
109
|
input: cp.multimodal ? ["text", "image"] : (caps?.input ?? ["text"]),
|
|
110
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
110
111
|
contextWindow: cp.contextWindow ?? caps?.contextWindow ?? 128000,
|
|
111
112
|
maxTokens: cp.maxTokens ?? caps?.maxTokens ?? 8192,
|
|
112
113
|
}];
|