1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-28 19:06:12 +01:00

chore: add OpenAI API key configuration (#8400)

https://linear.app/unleash/issue/2-2787/add-openai-api-key-to-our-configuration

Adds the OpenAI API key to our configuration and exposes a new
`unleashAIAvailable` boolean in our UI config to let our frontend know
that we have configured this. This can be used together with our flag to
decide whether we should enable our experiment for our users.
This commit is contained in:
Nuno Góis 2024-10-10 09:43:14 +01:00 committed by GitHub
parent 3a2206d228
commit d00873c357
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 0 deletions

View File

@ -32,6 +32,7 @@ export interface IUiConfig {
resourceLimits: ResourceLimitsSchema;
oidcConfiguredThroughEnv?: boolean;
samlConfiguredThroughEnv?: boolean;
unleashAIAvailable?: boolean;
}
export interface IProclamationToast {

View File

@ -94,6 +94,7 @@ exports[`should create default config 1`] = `
"frontendMetricsMaxPerMinute": 6000,
"frontendRegisterMaxPerMinute": 6000,
},
"openAIAPIKey": undefined,
"preHook": undefined,
"preRouterHook": undefined,
"prometheusApi": undefined,

View File

@ -711,6 +711,8 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
),
};
const openAIAPIKey = process.env.OPENAI_API_KEY;
return {
db,
session,
@ -749,6 +751,7 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
rateLimiting,
feedbackUriPath,
dailyMetricsStorageDays,
openAIAPIKey,
};
}

View File

@ -180,6 +180,11 @@ export const uiConfigSchema = {
'Whether the SAML configuration is set through environment variables or not.',
example: false,
},
unleashAIAvailable: {
type: 'boolean',
description: 'Whether Unleash AI is available.',
example: false,
},
},
components: {
schemas: {

View File

@ -152,6 +152,7 @@ class ConfigController extends Controller {
disablePasswordAuth,
maintenanceMode,
feedbackUriPath: this.config.feedbackUriPath,
unleashAIAvailable: this.config.openAIAPIKey !== undefined,
};
this.openApiService.respondWithValidation(

View File

@ -273,4 +273,5 @@ export interface IUnleashConfig {
isEnterprise: boolean;
rateLimiting: IRateLimiting;
feedbackUriPath?: string;
openAIAPIKey?: string;
}