Skip to content

Commit 95fbe97

Browse files
committed
Update validate function for ConfigUseEnvVar on existing providers
Signed-off-by: Geoff Wilson <[email protected]>
1 parent 2391628 commit 95fbe97

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

webview-ui/src/utils/validate.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ export function validateApiConfiguration(
3939
function validateModelsAndKeysProvided(apiConfiguration: ProviderSettings): string | undefined {
4040
switch (apiConfiguration.apiProvider) {
4141
case "openrouter":
42-
if (!apiConfiguration.openRouterApiKey) {
42+
if (!(apiConfiguration.openRouterApiKey || apiConfiguration.openRouterConfigUseEnvVars)) {
4343
return i18next.t("settings:validation.apiKey")
4444
}
4545
break
4646
case "glama":
47-
if (!apiConfiguration.glamaApiKey) {
47+
if (!(apiConfiguration.glamaApiKey || apiConfiguration.glamaConfigUseEnvVars)) {
4848
return i18next.t("settings:validation.apiKey")
4949
}
5050
break
5151
case "unbound":
52-
if (!apiConfiguration.unboundApiKey) {
52+
if (!(apiConfiguration.unboundApiKey || apiConfiguration.unboundConfigUseEnvVars)) {
5353
return i18next.t("settings:validation.apiKey")
5454
}
5555
break
5656
case "requesty":
57-
if (!apiConfiguration.requestyApiKey) {
57+
if (!(apiConfiguration.requestyApiKey || apiConfiguration.requestyConfigUseEnvVars)) {
5858
return i18next.t("settings:validation.apiKey")
5959
}
6060
break
@@ -64,7 +64,7 @@ function validateModelsAndKeysProvided(apiConfiguration: ProviderSettings): stri
6464
}
6565
break
6666
case "litellm":
67-
if (!apiConfiguration.litellmApiKey) {
67+
if (!(apiConfiguration.litellmApiKey || apiConfiguration.litellmConfigUseEnvVars)) {
6868
return i18next.t("settings:validation.apiKey")
6969
}
7070
break
@@ -84,22 +84,24 @@ function validateModelsAndKeysProvided(apiConfiguration: ProviderSettings): stri
8484
}
8585
break
8686
case "gemini":
87-
if (!apiConfiguration.geminiApiKey) {
87+
if (!(apiConfiguration.geminiApiKey || apiConfiguration.geminiConfigUseEnvVars)) {
8888
return i18next.t("settings:validation.apiKey")
8989
}
9090
break
9191
case "openai-native":
92-
if (!apiConfiguration.openAiNativeApiKey) {
92+
if (!(apiConfiguration.openAiNativeApiKey || apiConfiguration.openAiNativeConfigUseEnvVars)) {
9393
return i18next.t("settings:validation.apiKey")
9494
}
9595
break
9696
case "mistral":
97-
if (!apiConfiguration.mistralApiKey) {
97+
if (!(apiConfiguration.mistralApiKey || apiConfiguration.mistralConfigUseEnvVars)) {
9898
return i18next.t("settings:validation.apiKey")
9999
}
100100
break
101101
case "openai":
102-
if (!apiConfiguration.openAiBaseUrl || !apiConfiguration.openAiApiKey || !apiConfiguration.openAiModelId) {
102+
if (!apiConfiguration.openAiBaseUrl
103+
|| !(apiConfiguration.openAiApiKey || apiConfiguration.openAiConfigUseEnvVars)
104+
|| !apiConfiguration.openAiModelId) {
103105
return i18next.t("settings:validation.openAi")
104106
}
105107
break

0 commit comments

Comments
 (0)