diff --git a/app/(protected)/project/[project_id]/datasets/dataset/[dataset_id]/evaluations/page-client.tsx b/app/(protected)/project/[project_id]/datasets/dataset/[dataset_id]/evaluations/page-client.tsx index f0e4698f..c143caa2 100644 --- a/app/(protected)/project/[project_id]/datasets/dataset/[dataset_id]/evaluations/page-client.tsx +++ b/app/(protected)/project/[project_id]/datasets/dataset/[dataset_id]/evaluations/page-client.tsx @@ -40,6 +40,7 @@ import { ClipboardIcon, FlaskConical, RefreshCwIcon, + TrashIcon, } from "lucide-react"; import Link from "next/link"; import { useParams, useRouter } from "next/navigation"; @@ -121,7 +122,7 @@ export default function Evaluations() { }); const fetchExperiments = useQuery({ - queryKey: ["fetch-experiments-query"], + queryKey: ["fetch-experiments-query", projectId, datasetId, page], queryFn: async () => { const response = await fetch( `/api/run?projectId=${projectId}&datasetId=${datasetId}&page=${page}&pageSize=25` @@ -167,6 +168,36 @@ export default function Evaluations() { refetchOnWindowFocus: false, }); + const handleDeleteSelectedRuns = async () => { + if (comparisonRunIds.length === 0) return; + + try { + const response = await fetch("/api/run", { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + runIds: comparisonRunIds, + projectId, + }), + }); + + if (!response.ok) { + const error = await response.json(); + throw new Error(error?.message || "Failed to delete evaluations"); + } + + setComparisonRunIds([]); + await fetchExperiments.refetch(); + toast.success("Selected evaluations deleted successfully."); + } catch (error) { + toast.error("Failed to delete evaluations", { + description: error instanceof Error ? error.message : String(error), + }); + } + }; + const columns: ColumnDef[] = [ { size: 50, @@ -438,6 +469,16 @@ export default function Evaluations() { {viewMetrics ? "Hide Metrics" : "View Metrics"} + + {comparisonRunIds.length > 0 && ( + + )}
diff --git a/app/api/run/route.ts b/app/api/run/route.ts index 4820247c..0d4c6412 100644 --- a/app/api/run/route.ts +++ b/app/api/run/route.ts @@ -194,11 +194,14 @@ export async function DELETE(req: NextRequest) { } const data = await req.json(); - const { id } = data; + const { runIds, projectId } = data; - await prisma.run.delete({ + await prisma.run.deleteMany({ where: { - id, + runId: { + in: runIds, + }, + projectId: projectId, }, });