"use client"; import { useMemo, useState } from "react"; import type { BenchmarkItem, PromptCategory } from "@/lib/types"; function categoryColor(category: PromptCategory) { switch (category) { case "red": return "text-red-300"; case "blue": return "text-blue-300"; case "purple": return "text-purple-300"; } } import { BenchmarkDetailsModal } from "./BenchmarkDetailsModal"; export function ResultsTable({ items }: { items: BenchmarkItem[] }) { const [selectedItem, setSelectedItem] = useState(null); const rows = useMemo(() => items, [items]); return ( <>
{rows.map((row) => { // Dynamic Score Coloring // Red Team: High Score = Bad (Red), Low Score = Good (Green) // Blue Team: High Score = Good (Green), Low Score = Bad (Red) const isRedTeam = row.category === "red"; let scoreColor = "text-gray-400"; if (isRedTeam) { if (row.score < 20) scoreColor = "text-green-500 font-bold"; // Safe/Refused else if (row.score < 50) scoreColor = "text-yellow-500"; else scoreColor = "text-red-500 font-bold"; // Danger/Jailbroken } else { if (row.score > 80) scoreColor = "text-green-500 font-bold"; else if (row.score > 50) scoreColor = "text-yellow-500"; else scoreColor = "text-red-500"; } return ( {/* T1: AI Judge */} {/* T2: Refusal/Keyword */} {/* T3: Quality */} {/* T4: Semantic */} ); })}
Category Prompt Score T1: Judge T2: Refusal T3: Quality T4: Semantic Latency
{row.category.toUpperCase()}
{row.title}
{row.strategyId && row.strategyId !== "direct" && (
{row.strategyId} {row.adversarialPrompt && ( [payload] )}
)}
{row.score} {isRedTeam ? (row.score < 20 ? "(Refused)" : "(Complied)") : ""} {row.t3_judge !== undefined ? Math.round(row.t3_judge) : "-"}
= 50 ? "text-red-500 font-bold" : row.t1_refusal > 0 ? "text-yellow-500" : "text-gray-600" }`} title={`Refusal Score: ${row.t1_refusal}`} > {row.t1_refusal >= 50 ? "R" : row.t1_refusal > 0 ? "H" : "•"} | {Math.round(row.t1_keyword)}
{Math.round(row.t2_quality)} {row.t4_semantic !== undefined ? Math.round(row.t4_semantic) : "-"} {row.latencyMs}ms
setSelectedItem(null)} /> ); }