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:
27
apps/web/src/app/api/insights/eval-sets/route.ts
Normal file
27
apps/web/src/app/api/insights/eval-sets/route.ts
Normal 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
Reference in New Issue
Block a user