import { markBenchItem } from "@/lib/bench"; export const dynamic = "force-dynamic"; // MARK A DISAGREEMENT (release 29 V1): the operator's Right / Wrong on one // model's answer that is not the ruling — was the MODEL right? — kept beside // the run (umtool's own file, lib/bench-marks.mjs); marked precision is read // from them on /tools/bench. // POST {run, model, key, verdict: "right" | "wrong" | null} -> {mark} // 400 a bad body or not a disagreement; 404 no such run, item or answer; // 409 a marks file that does not read export async function POST(request: Request) { const headers = { "cache-control": "no-store" }; try { const b = (await request.json().catch(() => null)) as Record | null; if (!b || typeof b.run !== "string" || typeof b.model !== "string" || typeof b.key !== "string") { return Response.json({ error: 'send {"run", "model", "key", "verdict": "right" | "wrong" | null}' }, { status: 400, headers }); } const verdict = b.verdict === "right" || b.verdict === "wrong" ? b.verdict : b.verdict === null ? null : undefined; if (verdict === undefined) return Response.json({ error: '"verdict" is "right", "wrong" or null' }, { status: 400, headers }); return Response.json(await markBenchItem(b.run, b.model, b.key, verdict), { headers }); } catch (e) { const status = (e as { status?: number })?.status ?? 500; return Response.json({ error: (e as Error)?.message ?? String(e) }, { status, headers }); } }