- Notifications
You must be signed in to change notification settings - Fork920
feat: add the /aitasks/prompts endpoint#18464
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
a03b14b
to16dd56a
Compareaa79b8d
toe9e6341
Comparee9e6341
toe4abd39
Comparee4abd39
tod80c61a
Compareid, err := uuid.Parse(strings.TrimSpace(idStr)) | ||
if err != nil { | ||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ | ||
Message: "Invalid build ID format", |
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.
Let's include the ID that failed
return | ||
} | ||
promptsByBuildID := make(map[string]string) |
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.
promptsByBuildID:=make(map[string]string) | |
promptsByBuildID:=make(map[string]string,len(buildIDs)) |
t.Run("EmptyBuildIDs",func(t*testing.T) { | ||
t.Parallel() | ||
client:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerDaemon:true}) |
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.
I don't think we need this, do we?
client:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerDaemon:true}) | |
client:=coderdtest.New(t,&coderdtest.Options{}) |
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.
We do. coderdtest.CreateWorkspace spawns provisioner jobs under the hood. We wait for them to complete with coderdtest.AwaitWorkspaceBuildJobCompleted.
DefaultValue:"default1", | ||
}, | ||
{ | ||
Name:codersdk.AITaskPromptParameterName, |
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.
The provider exposes this, let's rather use that please.
https://github.com/coder/terraform-provider-coder/blob/main/provider/ai_task.go#L22
// Test parameters endpoint as member | ||
prompts,err:=memberClient.AITaskPrompts(ctx,allBuildIDs) | ||
require.NoError(t,err) | ||
require.Len(t,prompts.Prompts,2) |
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.
Please explain why only 2 are expected here.
// @Security CoderSessionToken | ||
// @Produce json | ||
// @Tags AITasks | ||
// @Param build_ids query string true "Comma-separated workspace build IDs" |
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.
// @Param build_ids query string true "Comma-separated workspace build IDs" | |
// @Param build_ids query string true "Comma-separated workspace build IDs" format(uuid) |
See
coder/coderd/workspacebuilds.go
Line 109 inf126931
// @Param workspace path string true "Workspace ID" format(uuid) |
@@ -1494,6 +1494,10 @@ func New(options *Options) *API { | |||
r.Use(apiKeyMiddleware) | |||
r.Get("/",api.tailnetRPCConn) | |||
}) | |||
r.Route("/aitasks",func(r chi.Router) { |
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.
Blocker: we need to finalize whether this will be a v2 endpoint or experimental.
} | ||
} | ||
filteredParameters := make([]database.WorkspaceBuildParameter, 0) |
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.
Curious about the 0 length here; what's your intent?
Uh oh!
There was an error while loading.Please reload this page.
Add an endpoint to fetch AI task prompts for multiple workspace builds at the same time. A prompt is the value of the "AI Prompt" workspace build parameter. On main, the only way our API allows fetching workspace build parameters is by using the
/workspacebuilds/$build_id/parameters
endpoint, requiring a separate API call for every build.The Tasks dashboard fetches Task workspaces in order to show them in a list, and then needs to fetch the value of the
AI Prompt
parameter for every task workspace (using its latest build id), requiring an additional API call for each list item. This endpoint will allow the dashboard to make just 2 calls to render the list: one to fetch task workspaces, the other to fetch prompts.Related tocoder/internal#660.