Merge pull request #16024 from Budibase/budi-9283-settings-page-incorrectly-states-budibase-ai-is-disabled

This commit is contained in:
Sam Rose 2025-04-28 18:04:41 +01:00 committed by GitHub
commit e8b2c4dfbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 11 deletions

View File

@ -55,18 +55,25 @@
$: enabled = !isCloud ? providers.filter(p => p.key === activeKey) : providers
$: disabled = !isCloud ? providers.filter(p => p.key !== activeKey) : []
function getConfigForProvider(key: AIProviderPartial) {
for (const config of Object.values(aiConfig.config)) {
if (config.provider === key) {
return config
}
}
return undefined
}
function getProviderConfig(key: AIProviderPartial): ProviderConfig {
const details = ProviderDetails[key]
const loadedConfig = aiConfig?.config[key] || {}
let baseConfig = { ...details.defaultConfig }
const config = getConfigForProvider(key) || { ...details.defaultConfig }
return {
...baseConfig,
...loadedConfig,
...config,
provider: details.provider as AIProvider,
name: details.name,
active: loadedConfig.active ?? baseConfig.active ?? false,
isDefault: loadedConfig.isDefault ?? baseConfig.isDefault ?? false,
active: config.active ?? false,
isDefault: config.isDefault ?? false,
}
}
@ -108,12 +115,7 @@
}
}
// handle the old budibase_ai key
const baseConfig = { ...aiConfig.config }
if (baseConfig["budibase_ai"]) {
delete baseConfig["budibase_ai"]
}
const payload = {
type: ConfigType.AI,
config: { ...baseConfig, [key]: updated },