Files
Kaname/src/app/(app)/endpoints/page.tsx
T
Claude 2e56351e96 Benchmarks: lean list queries
listBenchmarks() selected every column of every run, including the raw A/B
series, all quality eval items, hardware facts and descriptions, while lists
show only the snapshot, settings, headline numbers and the quality score. With
200 runs /api/benchmarks returned 732 KB, re-fetched every 3 s while a run was
active; the table used about 55 KB of it.

- listBenchmarks() returns lean rows: the headline numbers are computed on the
  server from the summary, the quality score comes from json_extract().
- The model page asks for 5 runs (it shows 5), the ⌘K index for 300.
- getBenchmark()/getBenchmarks() keep the full rows for detail and compare;
  cancel and delete only read the state.
- ListRow (lists) and RunRow (detail) are separate types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 20:52:12 +00:00

95 lines
4.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { PlusIcon, ServerIcon } from "lucide-react";
import type { Metadata } from "next";
import Link from "next/link";
import { buttonVariants } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { ENGINE_LABEL } from "@/lib/benchmark-meta";
import { listBenchmarks } from "@/lib/benchmarks";
import { listEndpoints } from "@/lib/endpoints";
import { PageHero } from "@/components/hero/page-hero";
import { EndpointStatus } from "./endpoint-status";
export const dynamic = "force-dynamic";
export const metadata: Metadata = { title: "Endpoints" };
export default async function EndpointsPage() {
const [endpoints, runs] = await Promise.all([listEndpoints(), listBenchmarks()]);
// Newest completed speed run and quality score per endpoint.
const latest = new Map<string, { decode: number | null; quality: number | null }>();
for (const r of runs) {
if (!r.endpointId || r.state !== "completed") continue;
const cur = latest.get(r.endpointId) ?? { decode: null, quality: null };
if (r.kind === "run" && cur.decode == null) cur.decode = r.headline.decode;
if (r.kind === "eval" && cur.quality == null) cur.quality = r.qualityScore;
latest.set(r.endpointId, cur);
}
return (
<PageHero
title="Endpoints"
description="OpenAI-compatible servers to benchmark. They run elsewhere; Kaname only sends them requests."
painting={{ view: 0.6, focus: [0.75, 0.35], anchor: [0.62, 0.35] }}
actions={
<Link href="/endpoints/new" className={buttonVariants()}>
<PlusIcon />
Add endpoint
</Link>
}
>
{endpoints.length === 0 ? (
<Card className="items-center gap-3 py-10 text-center">
<ServerIcon className="size-8 text-muted-foreground" />
<p className="max-w-md text-sm text-muted-foreground">
No endpoints yet. Add the URL of a llama.cpp, vLLM, SGLang or Ollama server, describe its hardware, and benchmark it.
</p>
</Card>
) : (
<Card className="py-0">
<Table>
<TableHeader>
<TableRow>
<TableHead>Endpoint</TableHead>
<TableHead className="hidden md:table-cell">Model</TableHead>
<TableHead className="hidden lg:table-cell">Hardware</TableHead>
<TableHead className="text-right">Decode t/s</TableHead>
<TableHead className="hidden text-right sm:table-cell">Quality</TableHead>
<TableHead className="w-32">Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{endpoints.map((e) => {
const l = latest.get(e.id);
const engine = e.hardware.engineName || (e.engine ?? e.probe?.engine ? ENGINE_LABEL[(e.engine ?? e.probe?.engine)!] : null);
return (
<TableRow key={e.id}>
<TableCell className="whitespace-normal">
<Link href={`/endpoints/${e.id}`} className="font-medium hover:underline">
{e.name}
</Link>
<div className="text-xs text-muted-foreground">
{e.baseUrl}
{engine && ` · ${engine}${e.probe?.engineVersion ? ` ${e.probe.engineVersion}` : ""}`}
</div>
</TableCell>
<TableCell className="hidden max-w-64 truncate text-sm md:table-cell">{e.model ?? (e.probe?.models.length === 1 ? e.probe.models[0] : "–")}</TableCell>
<TableCell className="hidden text-sm text-muted-foreground lg:table-cell">
{e.hardware.gpuName ? `${e.hardware.gpuCount ?? 1}× ${e.hardware.gpuName}` : (e.hardware.cpu ?? "–")}
</TableCell>
<TableCell className="text-right font-medium tabular-nums">{l?.decode != null ? l.decode.toFixed(1) : "–"}</TableCell>
<TableCell className="hidden text-right tabular-nums sm:table-cell">{l?.quality != null ? `${l.quality}%` : "–"}</TableCell>
<TableCell>
<EndpointStatus probe={e.probe} />
</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</Card>
)}
</PageHero>
);
}