Changesets · Branches · Tags · Compare
| Changeset | c1fda47286faa64e2de04dc0d8ec36351f1389cb115ffe8cdc84ebde0519260d |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-07-07 19:26 -07:00 |
| Committer | Dallin Romney <dallinromney@gmail.com> · 2025-07-07 19:26 -07:00 |
| Parents | ec79a4d62a4e |
9 files changed
modified core/config/load.ts +1 −0
| @@ -650,6 +650,7 @@ | ||
| 650 | 650 | roles: llm.roles, |
| 651 | 651 | configurationStatus: llm.getConfigurationStatus(), |
| 652 | 652 | apiKeyLocation: llm.apiKeyLocation, |
| 653 | + envSecretLocations: llm.envSecretLocations, | |
| 653 | 654 | }; |
| 654 | 655 | } |
| 655 | 656 |
modified core/index.d.ts +2 −0
| @@ -583,6 +583,7 @@ | ||
| 583 | 583 | |
| 584 | 584 | // continueProperties |
| 585 | 585 | apiKeyLocation?: string; |
| 586 | + envSecretLocations?: Record<string, string>; | |
| 586 | 587 | apiBase?: string; |
| 587 | 588 | orgScopeId?: string | null; |
| 588 | 589 | |
| @@ -1084,6 +1085,7 @@ | ||
| 1084 | 1085 | |
| 1085 | 1086 | apiBase?: string; |
| 1086 | 1087 | apiKeyLocation?: string; |
| 1088 | + envSecretLocations?: Record<string, string>; | |
| 1087 | 1089 | orgScopeId?: string | null; |
| 1088 | 1090 | |
| 1089 | 1091 | onPremProxyUrl?: string | null; |
modified core/llm/constants.ts +1 −0
| @@ -15,6 +15,7 @@ | ||
| 15 | 15 | export enum LLMConfigurationStatuses { |
| 16 | 16 | VALID = "valid", |
| 17 | 17 | MISSING_API_KEY = "missing-api-key", |
| 18 | + MISSING_ENV_SECRET = "missing-env-secret", | |
| 18 | 19 | } |
| 19 | 20 | |
| 20 | 21 | export { |
modified core/llm/index.ts +2 −0
| @@ -155,6 +155,7 @@ | ||
| 155 | 155 | |
| 156 | 156 | // continueProperties |
| 157 | 157 | apiKeyLocation?: string; |
| 158 | + envSecretLocations?: Record<string, string>; | |
| 158 | 159 | apiBase?: string; |
| 159 | 160 | orgScopeId?: string | null; |
| 160 | 161 | |
| @@ -248,6 +249,7 @@ | ||
| 248 | 249 | |
| 249 | 250 | // continueProperties |
| 250 | 251 | this.apiKeyLocation = options.apiKeyLocation; |
| 252 | + this.envSecretLocations = options.envSecretLocations; | |
| 251 | 253 | this.orgScopeId = options.orgScopeId; |
| 252 | 254 | this.apiBase = options.apiBase; |
| 253 | 255 |
modified core/llm/llms/stubs/ContinueProxy.ts +17 −4
| @@ -40,6 +40,7 @@ | ||
| 40 | 40 | this.apiType = undefined; |
| 41 | 41 | this.actualApiBase = options.apiBase; |
| 42 | 42 | this.apiKeyLocation = options.apiKeyLocation; |
| 43 | + this.envSecretLocations = options.envSecretLocations; | |
| 43 | 44 | this.orgScopeId = options.orgScopeId; |
| 44 | 45 | this.onPremProxyUrl = options.onPremProxyUrl; |
| 45 | 46 | if (this.onPremProxyUrl) { |
| @@ -60,6 +61,7 @@ | ||
| 60 | 61 | protected extraBodyProperties(): Record<string, any> { |
| 61 | 62 | const continueProperties: ContinueProperties = { |
| 62 | 63 | apiKeyLocation: this.apiKeyLocation, |
| 64 | + envSecretLocations: this.envSecretLocations, | |
| 63 | 65 | apiBase: this.actualApiBase, |
| 64 | 66 | orgScopeId: this.orgScopeId ?? null, |
| 65 | 67 | env: this.configEnv, |
| @@ -70,13 +72,24 @@ | ||
| 70 | 72 | } |
| 71 | 73 | |
| 72 | 74 | getConfigurationStatus() { |
| 73 | - if (!this.apiKeyLocation) { | |
| 75 | + if (!this.apiKeyLocation && !this.envSecretLocations) { | |
| 74 | 76 | return LLMConfigurationStatuses.VALID; |
| 75 | 77 | } |
| 76 | 78 | |
| 77 | - const secretLocation = decodeSecretLocation(this.apiKeyLocation); | |
| 78 | - if (secretLocation.secretType === SecretType.NotFound) { | |
| 79 | - return LLMConfigurationStatuses.MISSING_API_KEY; | |
| 79 | + if (this.apiKeyLocation) { | |
| 80 | + const secretLocation = decodeSecretLocation(this.apiKeyLocation); | |
| 81 | + if (secretLocation.secretType === SecretType.NotFound) { | |
| 82 | + return LLMConfigurationStatuses.MISSING_API_KEY; | |
| 83 | + } | |
| 84 | + } | |
| 85 | + | |
| 86 | + if (this.envSecretLocations) { | |
| 87 | + for (const secretLocation of Object.values(this.envSecretLocations)) { | |
| 88 | + const decoded = decodeSecretLocation(secretLocation); | |
| 89 | + if (decoded.secretType === SecretType.NotFound) { | |
| 90 | + return LLMConfigurationStatuses.MISSING_ENV_SECRET; | |
| 91 | + } | |
| 92 | + } | |
| 80 | 93 | } |
| 81 | 94 | |
| 82 | 95 | return LLMConfigurationStatuses.VALID; |
modified gui/src/pages/config/ModelRoleSelector.tsx +19 −6
| @@ -119,19 +119,32 @@ | ||
| 119 | 119 | {[...models] |
| 120 | 120 | .sort((a, b) => a.title.localeCompare(b.title)) |
| 121 | 121 | .map((option, idx) => { |
| 122 | - const showMissingApiKeyMsg = | |
| 122 | + const isConfigInvalid = | |
| 123 | + option.configurationStatus !== | |
| 124 | + LLMConfigurationStatuses.VALID; | |
| 125 | + let invalidMessage = "(Invalid config)"; | |
| 126 | + if ( | |
| 123 | 127 | option.configurationStatus === |
| 124 | - LLMConfigurationStatuses.MISSING_API_KEY; | |
| 128 | + LLMConfigurationStatuses.MISSING_ENV_SECRET | |
| 129 | + ) { | |
| 130 | + invalidMessage = "(Missing env secret)"; | |
| 131 | + } | |
| 132 | + if ( | |
| 133 | + option.configurationStatus === | |
| 134 | + LLMConfigurationStatuses.MISSING_API_KEY | |
| 135 | + ) { | |
| 136 | + invalidMessage = "(Missing API Key)"; | |
| 137 | + } | |
| 125 | 138 | |
| 126 | 139 | return ( |
| 127 | 140 | <ListboxOption |
| 128 | 141 | key={idx} |
| 129 | 142 | value={option.title} |
| 130 | - disabled={showMissingApiKeyMsg} | |
| 143 | + disabled={isConfigInvalid} | |
| 131 | 144 | onMouseEnter={() => setHoveredIdx(idx)} |
| 132 | 145 | onMouseLeave={() => setHoveredIdx(null)} |
| 133 | 146 | onClick={(e: any) => |
| 134 | - handleOptionClick(showMissingApiKeyMsg, e) | |
| 147 | + handleOptionClick(isConfigInvalid, e) | |
| 135 | 148 | } |
| 136 | 149 | className="" |
| 137 | 150 | > |
| @@ -144,9 +157,9 @@ | ||
| 144 | 157 | style={{ fontSize: fontSize(-3) }} |
| 145 | 158 | > |
| 146 | 159 | {option.title} |
| 147 | - {showMissingApiKeyMsg && ( | |
| 160 | + {isConfigInvalid && ( | |
| 148 | 161 | <span className="ml-2 text-[10px] italic"> |
| 149 | - (Missing API key) | |
| 162 | + {invalidMessage} | |
| 150 | 163 | </span> |
| 151 | 164 | )} |
| 152 | 165 | </span> |
modified packages/config-yaml/src/load/clientRender.ts +24 −2
| @@ -133,7 +133,27 @@ | ||
| 133 | 133 | const apiKeyLocation = getUnrenderedSecretLocation( |
| 134 | 134 | config.models[i]?.apiKey, |
| 135 | 135 | ); |
| 136 | - if (apiKeyLocation) { | |
| 136 | + const encodedApiKeyLocation = apiKeyLocation | |
| 137 | + ? encodeSecretLocation(apiKeyLocation) | |
| 138 | + : undefined; | |
| 139 | + | |
| 140 | + let encodedEnvSecretLocations: Record<string, string> | undefined = | |
| 141 | + undefined; | |
| 142 | + if (config.models[i]?.env) { | |
| 143 | + Object.entries(config.models[i]?.env!).forEach(([key, value]) => { | |
| 144 | + if (typeof value === "string") { | |
| 145 | + const secretLocation = getUnrenderedSecretLocation(value); | |
| 146 | + if (secretLocation) { | |
| 147 | + encodedEnvSecretLocations = { | |
| 148 | + ...encodedEnvSecretLocations, | |
| 149 | + [key]: encodeSecretLocation(secretLocation), | |
| 150 | + }; | |
| 151 | + } | |
| 152 | + } | |
| 153 | + }); | |
| 154 | + } | |
| 155 | + | |
| 156 | + if (encodedApiKeyLocation || encodedEnvSecretLocations) { | |
| 137 | 157 | config.models[i] = { |
| 138 | 158 | ...config.models[i], |
| 139 | 159 | name: config.models[i]?.name ?? "", |
| @@ -143,7 +163,8 @@ | ||
| 143 | 163 | config.models[i]?.provider ?? "", |
| 144 | 164 | config.models[i]?.model ?? "", |
| 145 | 165 | ), |
| 146 | - apiKeyLocation: encodeSecretLocation(apiKeyLocation), | |
| 166 | + apiKeyLocation: encodedApiKeyLocation, | |
| 167 | + envSecretLocations: encodedEnvSecretLocations, | |
| 147 | 168 | orgScopeId, |
| 148 | 169 | onPremProxyUrl, |
| 149 | 170 | apiKey: undefined, |
| @@ -158,6 +179,7 @@ | ||
| 158 | 179 | /** The additional properties that are added to the otherwise OpenAI-compatible body when requesting a Continue proxy */ |
| 159 | 180 | export const continuePropertiesSchema = z.object({ |
| 160 | 181 | apiKeyLocation: z.string().optional(), |
| 182 | + envSecretLocations: z.record(z.string(), z.string()).optional(), | |
| 161 | 183 | apiBase: z.string().optional(), |
| 162 | 184 | orgScopeId: z.string().nullable(), |
| 163 | 185 | env: z.record(z.string(), z.any()).optional(), |
modified packages/config-yaml/src/schemas/models.ts +4 −2
| @@ -154,7 +154,8 @@ | ||
| 154 | 154 | z.object({ |
| 155 | 155 | ...baseModelFields, |
| 156 | 156 | provider: z.literal("continue-proxy"), |
| 157 | - apiKeyLocation: z.string(), | |
| 157 | + apiKeyLocation: z.string().optional(), | |
| 158 | + envSecretLocations: z.record(z.string(), z.string()).optional(), | |
| 158 | 159 | orgScopeId: z.string().nullable(), |
| 159 | 160 | onPremProxyUrl: z.string().nullable(), |
| 160 | 161 | }), |
| @@ -169,7 +170,8 @@ | ||
| 169 | 170 | .object({ |
| 170 | 171 | ...baseModelFields, |
| 171 | 172 | provider: z.literal("continue-proxy"), |
| 172 | - apiKeyLocation: z.string(), | |
| 173 | + apiKeyLocation: z.string().optional(), | |
| 174 | + envSecretLocations: z.record(z.string(), z.string()).optional(), | |
| 173 | 175 | }) |
| 174 | 176 | .partial(), |
| 175 | 177 | z |
modified packages/continue-sdk/typescript/src/createOpenAIClient.ts +1 −0
| @@ -79,6 +79,7 @@ | ||
| 79 | 79 | |
| 80 | 80 | const continueProperties: ContinueProperties = { |
| 81 | 81 | apiKeyLocation: modelConfig.apiKeyLocation, |
| 82 | + envSecretLocations: modelConfig.envSecretLocations, | |
| 82 | 83 | orgScopeId: organizationId ?? null, |
| 83 | 84 | }; |
| 84 | 85 |