-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Initial scaffolding for using LLMs to generate JS in Budibase. #15711
base: master
Are you sure you want to change the base?
Conversation
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR introduces scaffolding to enable AI-generated JavaScript within Budibase behind a feature flag.
- Adds a new API endpoint (/api/ai/js) to proxy requests to an LLM service.
- Implements a controller to interface with OpenAI for generating JavaScript code.
- Extends type definitions and integrates the new endpoint into the frontend API.
Reviewed Changes
File | Description |
---|---|
packages/server/src/api/routes/ai.ts | Defines the new API route for AI JS generation |
packages/server/src/api/controllers/ai.ts | Implements the controller logic that invokes OpenAI for code generation |
packages/types/src/api/web/ai.ts | Adds request/response interfaces for the new endpoint |
packages/frontend-core/src/api/ai.ts | Integrates the new endpoint into the frontend API client |
packages/types/src/api/web/index.ts | Re-exports new type definitions |
packages/types/src/sdk/featureFlag.ts | Adds the new feature flag for AI JS generation |
packages/server/src/api/routes/index.ts | Updates route imports to include the new/renamed AI routes |
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR introduces the initial scaffolding for AI-generated JavaScript in Budibase, enabling backend processing via an endpoint and updating frontend API interfaces.
- Added a new endpoint (POST /api/ai/js) in the server controller to handle AI JS generation.
- Updated routing and types across server and frontend to support the AI functionality.
- Extended feature flags to include an "AI_JS_GENERATION" flag to toggle the feature.
Reviewed Changes
File | Description |
---|---|
packages/server/src/api/controllers/ai.ts | Introduces the endpoint logic, including API key and prompt handling. |
packages/server/src/api/routes/ai.ts | Adds a new route for the AI JS generation endpoint. |
packages/types/src/api/web/ai.ts | Defines request and response types for the AI endpoint. |
packages/frontend-core/src/api/ai.ts | Adds the client function to call the new AI JS generation endpoint. |
packages/types/src/api/web/index.ts | Updates exports to include the new AI API types. |
packages/types/src/sdk/featureFlag.ts | Incorporates the new AI_JS_GENERATION feature flag. |
packages/server/src/api/routes/index.ts | Updates main routes to include the new AI route under the pro namespace. |
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
packages/builder/src/components/common/CodeEditor/CodeEditor.svelte
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -5,30 +5,39 @@ | |||
|
|||
export let value: string | undefined = undefined | |||
export let label: string | undefined = undefined | |||
export let labelPosition: string = "above" | |||
export let labelPosition = "above" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be using the position enum, instead?
}) | ||
suggestedCode = code | ||
popoverWidth = 100 | ||
promptLoading = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be wrapped in a try/finally? Otherwise it will be stuck to loading forever
@@ -428,6 +477,50 @@ | |||
<div tabindex="-1" bind:this={textarea} /> | |||
</div> | |||
|
|||
{#if aiGenEnabled} | |||
<button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason on why not using bbui buttons? Are the designs not matching?
} | ||
|
||
if (!env.OPENAI_API_KEY) { | ||
ctx.throw(400, "OpenAI API key is not set") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 400 look strange to me. None of them is "bad request", both of them are due server conditions, no because of the request
|
||
const router: Router = new Router() | ||
|
||
router.post("/api/ai/js", auth.builderOrAdmin, controller.generateJs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be builder only?
Description
This feature is behind a feature flag while in development, so this PR won't be releasing anything to users.
What's in here:
POST /api/ai/js
that the frontend talks to as a proxy to whatever LLM we use.