diff --git a/packages/builder/src/pages/builder/portal/settings/ai/AIConfigTile.svelte b/packages/builder/src/pages/builder/portal/settings/ai/AIConfigTile.svelte index d4d5279d3e..693fbe7431 100644 --- a/packages/builder/src/pages/builder/portal/settings/ai/AIConfigTile.svelte +++ b/packages/builder/src/pages/builder/portal/settings/ai/AIConfigTile.svelte @@ -6,6 +6,13 @@ import TogetherAILogo from "./logos/TogetherAI.svelte" import { Providers } from "./constants" + const logos = { + ["Budibase AI"]: BudibaseLogo, + [Providers.OpenAI.name]: OpenAILogo, + [Providers.Anthropic.name]: AnthropicLogo, + [Providers.TogetherAI.name]: TogetherAILogo, + } + export let config export let disabled @@ -17,15 +24,7 @@
- {#if config.name === "Budibase AI"} - - {:else if config.provider === Providers.OpenAI.name} - - {:else if config.provider === Providers.Anthropic.name} - - {:else if config.provider === Providers.TogetherAI.name} - - {/if} +
{config.provider} diff --git a/packages/builder/src/pages/builder/portal/settings/ai/index.svelte b/packages/builder/src/pages/builder/portal/settings/ai/index.svelte index c4403e5045..2ac1609e7c 100644 --- a/packages/builder/src/pages/builder/portal/settings/ai/index.svelte +++ b/packages/builder/src/pages/builder/portal/settings/ai/index.svelte @@ -69,13 +69,14 @@ try { await API.saveConfig(fullAIConfig) notifications.success(`Successfully saved and activated AI Configuration`) - await fetchAIConfig() } catch (error) { notifications.error( `Failed to save AI Configuration, reason: ${ error?.message || "Unknown" }` ) + } finally { + await fetchAIConfig() } } @@ -88,11 +89,12 @@ try { await API.saveConfig(fullAIConfig) notifications.success(`Deleted config`) - await fetchAIConfig() } catch (error) { notifications.error( `Failed to delete config, reason: ${error?.message || "Unknown"}` ) + } finally { + await fetchAIConfig() } } diff --git a/packages/worker/src/api/controllers/global/configs.ts b/packages/worker/src/api/controllers/global/configs.ts index ffe7a1c717..95e0ba471f 100644 --- a/packages/worker/src/api/controllers/global/configs.ts +++ b/packages/worker/src/api/controllers/global/configs.ts @@ -211,10 +211,8 @@ async function verifyOIDCConfig(config: OIDCConfigs) { export async function verifyAIConfig( config: AIConfig, - existingConfig?: AIConfig + existingConfig: AIConfig ) { - if (!existingConfig) return - // ensure that the redacted API keys are not overwritten in the DB for (let uuid in existingConfig.config) { if (config[uuid]?.apiKey === PASSWORD_REPLACEMENT) { @@ -251,7 +249,9 @@ export async function save(ctx: UserCtx) { await verifyOIDCConfig(config) break case ConfigType.AI: - await verifyAIConfig(config, existingConfig) + if (existingConfig) { + await verifyAIConfig(config, existingConfig) + } break } } catch (err: any) { diff --git a/packages/worker/src/api/controllers/global/tests/configs.spec.ts b/packages/worker/src/api/controllers/global/tests/configs.spec.ts index 4bb3d598a6..8b859dcb89 100644 --- a/packages/worker/src/api/controllers/global/tests/configs.spec.ts +++ b/packages/worker/src/api/controllers/global/tests/configs.spec.ts @@ -45,7 +45,7 @@ describe("Global configs controller", () => { }) it("Should return the default BB AI config when the feature is turned on", async () => { - pro.features.isBudibaseAIEnabled = jest.fn(() => true) + jest.spyOn(pro.features, "isBudibaseAIEnabled").mockImplementation(() => true) configs.getConfig.mockResolvedValue({ config: { ai: { @@ -81,7 +81,7 @@ describe("Global configs controller", () => { }) it("Should not not return the default Budibase AI config when on self host", async () => { - pro.features.isBudibaseAIEnabled = jest.fn(() => false) + jest.spyOn(pro.features, "isBudibaseAIEnabled").mockImplementation(() => false) configs.getConfig.mockResolvedValue({ config: { ai: {