"use client" import type { CSSProperties } from "react" import { useAudienceMode } from "@/components/audience-mode-provider" import { useRouter } from "next/navigation" import { Award, BadgeCheck, BookOpenText, ExternalLink, Eye, FlaskConical, LibraryBig, MoreHorizontal, Scale, } 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 { 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 } 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" } export function BenchmarkEvaluationCard({ data, onDelete, delayMs = 0 }: 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) return ( router.push(`/evaluations/${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} {data.architecture && {data.architecture}} {data.input_modalities && data.input_modalities.length > 1 && ( Multimodal )} {data.independent_verification_ratio > 0 ? ( Independent reporting ) : data.evaluator_count > 0 ? ( {reportingSummaryLabel} ) : null}
router.push(`/evaluations/${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 )}
{isResearchView ? (
Method + Provenance
{library && ( )} {data.latest_source_name && ( )} {data.source_types.length > 0 && ( s.replace(/_/g, " ")).join(", ")} /> )} {data.missing_generation_config_count > 0 && ( )} {library?.fork && (
Non-standard eval library fork
)}
{highlights.length > 0 && (
Benchmark Signals
{highlights.map((item, index) => ( ))}
)}
) : (
Reporting Context
Reporting summary
This model has reported results from {reportingSummaryLabel.toLowerCase()} across {data.benchmarks_count} benchmark{data.benchmarks_count !== 1 ? "s" : ""}. {data.independent_verification_ratio > 0 ? ` ${Math.round(data.independent_verification_ratio * 100)}% of results are independently reported.` : " Current results are self-reported."}
{data.evaluator_names.slice(0, 2).map((evaluator) => ( {evaluator} ))}
{highlights.length > 0 && (
What Was Tested
{highlights.map((item, index) => ( ))}
)}
)}
) } 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}
) }