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:
commit
ea749f18ce
|
@ -1 +1 @@
|
|||
Subproject commit 5b51c2280fdac90ce26f61cd8fb5ad70f8cfeecf
|
||||
Subproject commit 8bcb90edac3d44c48eaecf526cedc82418035438
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue