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:
@@ -2661,27 +2661,6 @@ export type CreateTaskFeedbackRequest = {
|
||||
class ExperimentalApiMethods {
|
||||
constructor(protected readonly axios: AxiosInstance) {}
|
||||
|
||||
getAITasksPrompts = async (
|
||||
buildIds: TypesGen.WorkspaceBuild["id"][],
|
||||
): Promise<TypesGen.AITasksPromptsResponse> => {
|
||||
if (buildIds.length === 0) {
|
||||
return {
|
||||
prompts: {},
|
||||
};
|
||||
}
|
||||
|
||||
const response = await this.axios.get<TypesGen.AITasksPromptsResponse>(
|
||||
"/api/experimental/aitasks/prompts",
|
||||
{
|
||||
params: {
|
||||
build_ids: buildIds.join(","),
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
createTask = async (
|
||||
user: string,
|
||||
req: TypesGen.CreateTaskRequest,
|
||||
|
||||
Generated
+8
-14
@@ -108,23 +108,17 @@ export interface AIConfig {
|
||||
* 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.
|
||||
*/
|
||||
export const AITaskPromptParameterName = "AI Prompt";
|
||||
|
||||
// From codersdk/aitasks.go
|
||||
/**
|
||||
* AITasksPromptsResponse represents the response from the AITaskPrompts method.
|
||||
*
|
||||
* Experimental: This method is experimental and may change in the future.
|
||||
*/
|
||||
export interface AITasksPromptsResponse {
|
||||
/**
|
||||
* Prompts is a map of workspace build IDs to prompts.
|
||||
*/
|
||||
readonly prompts: Record<string, string>;
|
||||
}
|
||||
|
||||
// From codersdk/allowlist.go
|
||||
/**
|
||||
* APIAllowListTarget represents a single allow-list entry using the canonical
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
Template,
|
||||
TemplateVersionExternalAuth,
|
||||
} from "api/typesGenerated";
|
||||
import { AITaskPromptParameterName } from "api/typesGenerated";
|
||||
import { ErrorAlert } from "components/Alert/ErrorAlert";
|
||||
import { Button } from "components/Button/Button";
|
||||
import { ExternalImage } from "components/ExternalImage/ExternalImage";
|
||||
@@ -38,8 +39,6 @@ import { docs } from "utils/docs";
|
||||
import { PromptSelectTrigger } from "./PromptSelectTrigger";
|
||||
import { TemplateVersionSelect } from "./TemplateVersionSelect";
|
||||
|
||||
const AI_PROMPT_PARAMETER_NAME = "AI Prompt";
|
||||
|
||||
type TaskPromptProps = {
|
||||
templates: Template[] | undefined;
|
||||
error: unknown;
|
||||
@@ -168,7 +167,7 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
|
||||
|
||||
// Read-only prompt if defined in preset
|
||||
const presetPrompt = selectedPreset?.Parameters?.find(
|
||||
(param) => param.Name === AI_PROMPT_PARAMETER_NAME,
|
||||
(param) => param.Name === AITaskPromptParameterName,
|
||||
)?.Value;
|
||||
const isPromptReadOnly = !!presetPrompt;
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user