mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: deprecate codersdk.AITaskPromptParameterName and reduce usage (#20501)
Depends on coder/sqlc#1 Fixes coder/internal#979 Updates coder/internal#973
This commit is contained in:
+8
-38
@@ -17,46 +17,16 @@ import (
|
||||
// AITaskPromptParameterName is the name of the parameter used to pass prompts
|
||||
// to AI tasks.
|
||||
//
|
||||
// Experimental: This value is experimental and may change in the future.
|
||||
// Deprecated: This constant is deprecated and maintained only for backwards
|
||||
// compatibility with older templates. Task prompts are now stored directly
|
||||
// in the tasks.prompt database column. New code should access prompts via
|
||||
// the Task.InitialPrompt field returned from task endpoints.
|
||||
//
|
||||
// This constant will be removed in a future major version. Templates should
|
||||
// not rely on this parameter name, as the backend will continue to create it
|
||||
// automatically for compatibility but reads from tasks.prompt.
|
||||
const AITaskPromptParameterName = provider.TaskPromptParameterName
|
||||
|
||||
// AITasksPromptsResponse represents the response from the AITaskPrompts method.
|
||||
//
|
||||
// Experimental: This method is experimental and may change in the future.
|
||||
type AITasksPromptsResponse struct {
|
||||
// Prompts is a map of workspace build IDs to prompts.
|
||||
Prompts map[string]string `json:"prompts"`
|
||||
}
|
||||
|
||||
// AITaskPrompts returns prompts for multiple workspace builds by their IDs.
|
||||
//
|
||||
// Experimental: This method is experimental and may change in the future.
|
||||
func (c *ExperimentalClient) AITaskPrompts(ctx context.Context, buildIDs []uuid.UUID) (AITasksPromptsResponse, error) {
|
||||
if len(buildIDs) == 0 {
|
||||
return AITasksPromptsResponse{
|
||||
Prompts: make(map[string]string),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Convert UUIDs to strings and join them
|
||||
buildIDStrings := make([]string, len(buildIDs))
|
||||
for i, id := range buildIDs {
|
||||
buildIDStrings[i] = id.String()
|
||||
}
|
||||
buildIDsParam := strings.Join(buildIDStrings, ",")
|
||||
|
||||
res, err := c.Request(ctx, http.MethodGet, "/api/experimental/aitasks/prompts", nil, WithQueryParam("build_ids", buildIDsParam))
|
||||
if err != nil {
|
||||
return AITasksPromptsResponse{}, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return AITasksPromptsResponse{}, ReadBodyAsError(res)
|
||||
}
|
||||
var prompts AITasksPromptsResponse
|
||||
return prompts, json.NewDecoder(res.Body).Decode(&prompts)
|
||||
}
|
||||
|
||||
// CreateTaskRequest represents the request to create a new task.
|
||||
//
|
||||
// Experimental: This type is experimental and may change in the future.
|
||||
|
||||
Reference in New Issue
Block a user