Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI class refactor #15760

Merged
merged 13 commits into from
Mar 24, 2025
Merged

AI class refactor #15760

merged 13 commits into from
Mar 24, 2025

Conversation

samwho
Copy link
Collaborator

@samwho samwho commented Mar 18, 2025

Description

This change is mostly the set of companion changes required for the corresponding pro PR. The details of the changes are on that PR.

Pro PR: https://github.com/Budibase/budibase-pro/pull/364

Copy link

qa-wolf bot commented Mar 18, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@github-actions github-actions bot added firestorm Data/Infra/Revenue Team size/xs labels Mar 18, 2025
@github-actions github-actions bot added size/s and removed size/xs labels Mar 18, 2025
@github-actions github-actions bot added size/m and removed size/s labels Mar 24, 2025
@samwho samwho changed the title License auth AI class refactor Mar 24, 2025
@samwho samwho marked this pull request as ready for review March 24, 2025 14:23
@samwho samwho requested a review from a team as a code owner March 24, 2025 14:23
@samwho samwho requested review from mike12345567 and removed request for a team March 24, 2025 14:23

response = llmWrapper?.llm
? await llmWrapper.run(inputs.prompt)
const llm = await pro.ai.getLLM(inputs.model)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLLM performs the pro features checks that were previously being performed here. getLLM is designed to return an LLM if the user has access to one, and nothing if they don't.

@@ -79,59 +60,4 @@ describe("rowProcessor utility", () => {
expect(fixAutoColumnSubType(schema)).toEqual(schema)
})
})

describe("processAIColumns", () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was being tested here is covered by more realistic tests of AI columns in `row.spec.ts.

)
if (rows && llmWrapper.llm) {
const llm = await pro.ai.getLLM()
if (rows && llm) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nicer here now that we don't have to reach into the returned class and check that a property of it is not null (llmWrapper.llm from old diff) before we can use it.

export type AIProvider =
| "OpenAI"
| "Anthropic"
| "AzureOpenAI"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"AzureOpenAI" was missing from this list, it is referenced in several places outside this file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the ts not complain about this missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the typing in this area is a bit loose. This PR tightens it up a little, but there's likely still more we could do.

export interface ProviderConfig {
provider: AIProvider
isDefault: boolean
isBudibaseAI?: boolean
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is new, and much more explicitly labels a config as Budibase AI. We were previously inferring this from other fields. Budibase AI config is always enriched at runtime, so this won't be stored anywhere.

@@ -17,4 +17,5 @@ export interface License {
plan: PurchasedPlan
billing?: Billing
testClockId?: string
tenantId?: string
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export type AIProvider =
| "OpenAI"
| "Anthropic"
| "AzureOpenAI"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the ts not complain about this missing?

@adrinr
Copy link
Collaborator

adrinr commented Mar 24, 2025

Thanks for the detailed comments!

@samwho samwho enabled auto-merge March 24, 2025 16:11
@samwho samwho merged commit 8327fbe into master Mar 24, 2025
22 checks passed
@samwho samwho deleted the license-auth branch March 24, 2025 16:13
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
firestorm Data/Infra/Revenue Team size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants