"use client" import type { CSSProperties } from "react" import { useAudienceMode } from "@/components/audience-mode-provider" import { useRouter } from "next/navigation" import { Award, BookOpenText, ChevronDown, CheckCircle2, ExternalLink, Eye, FlaskConical, LibraryBig, MoreHorizontal, ShieldCheck, TriangleAlert, } from "lucide-react" import type { CategoryType } from "@/lib/benchmark-schema" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" import { Progress } from "@/components/ui/progress" export type BenchmarkEvaluationCardData = { id: string route_id: string model_name: string model_id: string canonical_model_name: string developer: string evaluations_count: number benchmarks_count: number variant_count: number categories: CategoryType[] category_stats: Record latest_timestamp: string evaluator_count: number evaluator_names: string[] source_type_count: number source_types: string[] evidence_count: number missing_generation_config_count: number third_party_eval_count: number independent_verification_ratio: number reproducibility_status: "complete" | "partial" | "missing" eval_libraries: Array<{ name: string version?: string fork?: string }> latest_source_name?: string params_billions?: number | null top_scores: Array<{ benchmark: string score: number metric: string unit?: string }> source_urls: string[] detail_urls: string[] model_url?: string release_date?: string input_modalities?: string[] output_modalities?: string[] architecture?: string params?: string inference_engine?: string inference_platform?: string } interface BenchmarkEvaluationCardProps { data: BenchmarkEvaluationCardData onDelete?: (id: string) => void delayMs?: number selectedForCompare?: boolean onToggleCompare?: (id: string) => void } function formatDate(isoString: string) { const numeric = Number(isoString) const parsedDate = !Number.isNaN(numeric) && !isoString.includes("-") ? new Date(numeric * 1000) : new Date(isoString) try { return parsedDate.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric", }) } catch { return isoString } } function formatHighlightScore(score: number, unit?: string) { if (unit === "accuracy" || unit === "pass@1" || (!unit && score >= 0 && score <= 1)) { return `${(score * 100).toFixed(1)}%` } if (unit === "points") return score.toFixed(1) return score.toFixed(2) } function scoreToPercent(score: number, unit?: string): number { if (score >= 0 && score <= 1) return score * 100 return Math.min(Math.max(score, 0), 100) } function getPolicyBenchmarkLabel(name: string) { const value = name.toLowerCase() if (value.includes("ifeval")) return "Following instructions" if (value.includes("bbh")) return "Reasoning and logic" if (value.includes("math")) return "Advanced mathematics" if (value.includes("gpqa")) return "Expert knowledge" if (value.includes("musr")) return "Narrative reasoning" if (value.includes("mmlu")) return "Broad knowledge" if (value.includes("tau-bench")) return "Agentic task completion" if (value.includes("swe-bench")) return "Software engineering" return name } function formatParamsBillions(value: number | null | undefined) { if (value == null || Number.isNaN(value)) return null if (value >= 100) return `${Math.round(value)}B` return `${value.toFixed(1)}B` } function getReportingSummaryLabel(data: BenchmarkEvaluationCardData) { if (data.evaluator_count > 0) { return `${data.evaluator_count} reporting org${data.evaluator_count !== 1 ? "s" : ""}` } if (data.latest_source_name) { return data.latest_source_name } return "Aggregated reporting view" } function getReproducibilitySummary(data: BenchmarkEvaluationCardData) { switch (data.reproducibility_status) { case "complete": return { label: "Full config coverage", tone: "secondary" as const, icon: CheckCircle2, } case "partial": return { label: "Partial config coverage", tone: "outline" as const, icon: FlaskConical, } default: return { label: "Config mostly missing", tone: "destructive" as const, icon: TriangleAlert, } } } function getIndependentSummary(data: BenchmarkEvaluationCardData) { const percent = Math.round(data.independent_verification_ratio * 100) if (data.independent_verification_ratio >= 0.75) { return `${percent}% independent` } if (data.independent_verification_ratio > 0) { return `${percent}% independent` } return "Self-reported only" } export function BenchmarkEvaluationCard({ data, onDelete, delayMs = 0, selectedForCompare = false, onToggleCompare, }: BenchmarkEvaluationCardProps) { const router = useRouter() const { mode } = useAudienceMode() const isResearchView = mode === "research" const highlights = data.top_scores.slice(0, 3) const library = data.eval_libraries[0] const paramsBillions = formatParamsBillions(data.params_billions) const reportingSummaryLabel = getReportingSummaryLabel(data) const reproducibility = getReproducibilitySummary(data) const independentSummary = getIndependentSummary(data) return ( router.push(`/models/${data.route_id}`)} >
Model Summary
{reportingSummaryLabel} / {formatDate(data.latest_timestamp)}
{data.model_name}
{data.developer || "Unknown developer"}
{data.variant_count > 1 && ( {data.variant_count} versions )} {paramsBillions && {paramsBillions} parameters} {reproducibility.label} 0 ? "secondary" : "outline"}> {independentSummary}
{onToggleCompare ? ( ) : null} router.push(`/models/${data.route_id}`)}> View Details {data.source_urls.length > 0 && ( window.open(data.source_urls[0], "_blank")}> View Source )} {onDelete && ( onDelete(data.id)} className="text-destructive"> Remove )}
{reportingSummaryLabel} {reproducibility.label} 0 ? "secondary" : "outline"}> {independentSummary}
{isResearchView ? "Most useful signals first: benchmark coverage, reproducibility, and benchmark-level performance. Open the details panel only when you need methodology or provenance." : "Most useful signals first: benchmark coverage, reporting posture, and what was actually tested. Open the details panel if you need source or methodology context."}
{highlights.length > 0 ? (
{isResearchView ? ( ) : ( )} {isResearchView ? "Most Relevant Benchmarks" : "What Was Tested"}
{highlights.map((item, index) => ( ))}
) : null} event.stopPropagation()} className="border-t border-border/60 px-4 py-4">
{library && ( )} {data.latest_source_name && ( )} {data.source_types.length > 0 && ( s.replace(/_/g, " ")).join(", ")} /> )} {data.architecture && } {data.missing_generation_config_count > 0 && ( )} {library?.fork && (
Non-standard eval library fork
)}
) } function CompactStat({ label, value, tone, }: { label: string value: string tone: string }) { return (
{label}
{value}
) } function KeyValueRow({ label, value }: { label: string; value: string }) { return (
{label} {value}
) } function SignalRow({ rank, label, rawLabel, scoreLabel, scorePercent, isLast, }: { rank: number label: string rawLabel?: string scoreLabel: string scorePercent: number isLast?: boolean }) { return (
{rank}
{label}
{rawLabel &&
{rawLabel}
}
{scoreLabel}
) }