import { NextRequest } from "next/server";
import { getErrorAnalysis } from "@/lib/data";

export async function GET(request: NextRequest) {
  const modelId = request.nextUrl.searchParams.get("model");
  const checkpoint = request.nextUrl.searchParams.get("checkpoint");

  if (!modelId || !checkpoint) {
    return Response.json({ error: "model and checkpoint params required" }, { status: 400 });
  }

  const errors = await getErrorAnalysis(modelId, checkpoint);
  if (!errors) {
    return Response.json({ error: "Not found" }, { status: 404 });
  }

  return Response.json(errors);
}
