import { viewQueryOf } from "yt-dlp-transcript-common/lib/llm/callLogView"; import { ModelLogError, readModelLogView, sourceOf } from "@/lib/model-log"; import { fail, ok } from "../research/_respond"; export const dynamic = "force-dynamic"; // THE MODEL LOG (demo epic D3): GET answers the panel's view -- the runs, the // count header, the calls grouped by phase, one page a group -- of an // iteration (`article`, `n`) or of a job with no iteration (`job`). Read only; // the panel polls it while its run is live. // GET /api/model-log?article=&n=[&task=&jobId=&run=&latest=1&outcome=&phase=&offset=&limit=] // GET /api/model-log?job=[&…] // 404 no such iteration · 400 a bad query · 409 an iteration.json that does not read export async function GET(request: Request) { try { const sp = new URL(request.url).searchParams; let q; try { q = viewQueryOf(sp); } catch (e) { throw new ModelLogError((e as Error).message); } return ok(await readModelLogView(sourceOf(sp), q)); } catch (e) { return fail(e); } }