feat(eval): POST /api/insights/eval-sets thin wrapper (create + optional run)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Semih
2026-05-14 06:15:39 +00:00
parent b635b529e2
commit b83d28c119
2 changed files with 28 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
import { NextResponse } from "next/server";
import { createEvalSet, triggerEvalRun } from "@/app/insights/_actions";
export const dynamic = "force-dynamic";
// POST { promptTag, name, description?, cases } -> create + optionally run
export async function POST(req: Request) {
const body = await req.json().catch(() => null);
if (!body || !body.promptTag || !body.name || !Array.isArray(body.cases)) {
return NextResponse.json({ ok: false, error: "bad_body" }, { status: 400 });
}
try {
const created = await createEvalSet({
promptTag: body.promptTag,
name: body.name,
description: body.description,
casesJson: JSON.stringify(body.cases),
});
if (body.run) {
const job = await triggerEvalRun(created.id);
return NextResponse.json({ ok: true, evalSetId: created.id, jobId: job.jobId });
}
return NextResponse.json({ ok: true, evalSetId: created.id });
} catch (e) {
return NextResponse.json({ ok: false, error: (e as Error).message }, { status: 500 });
}
}

File diff suppressed because one or more lines are too long