58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import request from "./request";
|
|
import type { GenerationPoint } from "../types";
|
|
|
|
export async function listGenerationPoints(template_id: string) {
|
|
const { data } = await request.get<GenerationPoint[]>("/generation-points", {
|
|
params: { template_id },
|
|
});
|
|
return data;
|
|
}
|
|
|
|
export async function createGenerationPoint(body: {
|
|
template_id: string;
|
|
position: string;
|
|
prompt: string;
|
|
model_id?: string;
|
|
order?: number;
|
|
selected_text?: string;
|
|
need_ref_file?: boolean;
|
|
remark?: string;
|
|
ref_file?: File;
|
|
}) {
|
|
const formData = new FormData();
|
|
formData.append("template_id", body.template_id);
|
|
formData.append("position", body.position);
|
|
formData.append("prompt", body.prompt);
|
|
if (body.model_id) formData.append("model_id", body.model_id);
|
|
if (body.order !== undefined) formData.append("order", String(body.order));
|
|
if (body.selected_text) formData.append("selected_text", body.selected_text);
|
|
if (body.need_ref_file) formData.append("need_ref_file", "true");
|
|
if (body.remark) formData.append("remark", body.remark);
|
|
if (body.ref_file) formData.append("ref_file", body.ref_file);
|
|
const { data } = await request.post<GenerationPoint>("/generation-points", formData);
|
|
return data;
|
|
}
|
|
|
|
export async function updateGenerationPoint(
|
|
id: string,
|
|
body: Partial<GenerationPoint>
|
|
) {
|
|
const { data } = await request.put<GenerationPoint>(`/generation-points/${id}`, body);
|
|
return data;
|
|
}
|
|
|
|
export async function deleteGenerationPoint(id: string) {
|
|
await request.delete(`/generation-points/${id}`);
|
|
}
|
|
|
|
export async function batchUpdateOrder(points: { id: string; order: number }[]) {
|
|
await request.post("/generation-points/batch-order", { points });
|
|
}
|
|
|
|
export async function testGenerationPoint(pointId: string) {
|
|
const { data } = await request.post<{ result: string }>(
|
|
`/generation-points/${pointId}/test`
|
|
);
|
|
return data.result;
|
|
}
|