Merge pull request #15953 from Budibase/budi-9244-expose-current-llm-provider-in-apiself

Expose LLM provider config via /api/global/self.
This commit is contained in:
Sam Rose 2025-04-14 12:43:48 +01:00 committed by GitHub
commit ea749f18ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 3 deletions

@ -1 +1 @@
Subproject commit 5b51c2280fdac90ce26f61cd8fb5ad70f8cfeecf
Subproject commit 8bcb90edac3d44c48eaecf526cedc82418035438

View File

@ -1,4 +1,4 @@
import { License } from "../../../sdk"
import { License, LLMProviderConfig } from "../../../sdk"
import { Account, DevInfo, User } from "../../../documents"
import { FeatureFlags } from "@budibase/types"
@ -11,6 +11,7 @@ export interface FetchAPIKeyResponse extends DevInfo {}
export interface GetGlobalSelfResponse extends User {
flags?: FeatureFlags
llm?: Omit<LLMProviderConfig, "apiKey">
account?: Account
license: License
budibaseAccess: boolean

View File

@ -1,3 +1,5 @@
import { AIProvider } from "../documents"
export enum AIOperationEnum {
SUMMARISE_TEXT = "SUMMARISE_TEXT",
CLEAN_DATA = "CLEAN_DATA",
@ -89,3 +91,13 @@ export type AIColumnSchema =
| SentimentAnalysisSchema
| PromptSchema
| SearchWebSchema
export interface LLMConfigOptions {
model: string
apiKey: string
measureUsage: boolean
}
export interface LLMProviderConfig extends LLMConfigOptions {
provider: AIProvider
}

View File

@ -8,7 +8,7 @@ import {
auth as authCore,
} from "@budibase/backend-core"
import env from "../../../environment"
import { groups } from "@budibase/pro"
import { ai, groups } from "@budibase/pro"
import {
DevInfo,
FetchAPIKeyResponse,
@ -115,11 +115,20 @@ export async function getSelf(ctx: UserCtx<void, GetGlobalSelfResponse>) {
// add the feature flags for this tenant
const flags = await features.flags.fetch()
const llmConfig = await ai.getLLMConfig()
const sanitisedLLMConfig = llmConfig
? {
provider: llmConfig.provider,
model: llmConfig.model,
measureUsage: llmConfig.measureUsage,
}
: undefined
ctx.body = {
...enrichedUser,
...sessionAttributes,
flags,
llm: sanitisedLLMConfig,
}
}