import { NextResponse } from "next/server"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { BENCH_VERDICTS_BODY_KEYS, enqueueVerdictBench } from "yt-dlp-transcript-common/controller/benchVerdicts"; import { jobResponse, ops } from "../_lib"; export const dynamic = "force-dynamic"; // POST { models, run?, reports?, window?, windowMode?, maxUsd?, limit?, itemsFrom?, dedupe? } // -> { ok: true, jobId, run } // // The verdict bench (release 28 M7), as a `bench-verdicts` job: every ruled // claim of the registry's fact-checks (or of `reports`) asked of each of // `models`, one claim per call, scored against the operator's rulings. On // `draft:local` when any model is local — every ollama call through the GPU // arbiter, ollama unloaded at the end — else `draft:api`. `maxUsd` caps the // whole run (default 5); an API run is refused past the day's cap. `run` // names a run to continue (its answered pairs are skipped). The results are // local-only: `.generation/bench/verdicts//` (umtool's /bench reads // them). Release 29 V1: `windowMode` ("turn": the cited speaker's turn), // a stratified `limit`, `itemsFrom` (an earlier run's exact items). Release 32 // R8: `dedupe: true` asks a repeated claim once (off by default). // `job cancel` stops it; the log ends `@@bench-verdicts {json}`. // // AN ADAPTER: the refusals are the controller's (controller/benchVerdicts.ts). export async function POST(request: Request) { return ops(request, BENCH_VERDICTS_BODY_KEYS, async (body) => { const out = await enqueueVerdictBench(body, { paths: getPaths() }); if (!out.result.ok || !("run" in out)) return jobResponse(out.result); void out.result.stream.cancel(); return NextResponse.json({ ok: true, jobId: out.result.jobId, run: out.run }); }); }