Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Update BestOfNEvalsPage.tsx

Abi Raja49ea5a871a51
diff --git a/frontend/src/components/evals/BestOfNEvalsPage.tsx b/frontend/src/components/evals/BestOfNEvalsPage.tsx
index faeacb5f..4cf796ce 100644
--- a/frontend/src/components/evals/BestOfNEvalsPage.tsx
+++ b/frontend/src/components/evals/BestOfNEvalsPage.tsx
@@ -30,18 +30,20 @@ function BestOfNEvalsPage() {
const [folderPaths, setFolderPaths] = useState<string[]>([""]);
const [isLoading, setIsLoading] = useState(false);
const [selectedHtml, setSelectedHtml] = useState<string>("");
-
+
// Available folders from backend
const [availableFolders, setAvailableFolders] = useState<OutputFolder[]>([]);
-
+
// Navigation state
const [currentComparisonIndex, setCurrentComparisonIndex] = useState(0);
const [currentModelIndex, setCurrentModelIndex] = useState(0);
-
+
// UI state
const [showResults, setShowResults] = useState(false);
- const [winnerFilter, setWinnerFilter] = useState<number | "tie" | "all">("all");
-
+ const [winnerFilter, setWinnerFilter] = useState<number | "tie" | "all">(
+ "all"
+ );
+
// Refs for synchronized scrolling
const iframeRefs = useRef<(HTMLIFrameElement | null)[]>([]);
@@ -67,17 +69,24 @@ function BestOfNEvalsPage() {
const syncScroll = (sourceIframe: HTMLIFrameElement) => {
try {
- const sourceDocument = sourceIframe.contentDocument || sourceIframe.contentWindow?.document;
+ const sourceDocument =
+ sourceIframe.contentDocument ||
+ sourceIframe.contentWindow?.document;
if (!sourceDocument) return;
const syncHandler = () => {
- const scrollTop = sourceDocument.documentElement.scrollTop || sourceDocument.body.scrollTop;
- const scrollLeft = sourceDocument.documentElement.scrollLeft || sourceDocument.body.scrollLeft;
-
- iframes.forEach(iframe => {
+ const scrollTop =
+ sourceDocument.documentElement.scrollTop ||
+ sourceDocument.body.scrollTop;
+ const scrollLeft =
+ sourceDocument.documentElement.scrollLeft ||
+ sourceDocument.body.scrollLeft;
+
+ iframes.forEach((iframe) => {
if (!iframe || iframe === sourceIframe) return;
try {
- const targetDocument = iframe.contentDocument || iframe.contentWindow?.document;
+ const targetDocument =
+ iframe.contentDocument || iframe.contentWindow?.document;
if (targetDocument) {
targetDocument.documentElement.scrollTop = scrollTop;
targetDocument.body.scrollTop = scrollTop;
@@ -90,15 +99,18 @@ function BestOfNEvalsPage() {
});
};
- sourceDocument.addEventListener('scroll', syncHandler);
- return () => sourceDocument.removeEventListener('scroll', syncHandler);
+ sourceDocument.addEventListener("scroll", syncHandler);
+ return () =>
+ sourceDocument.removeEventListener("scroll", syncHandler);
} catch (e) {
// Ignore cross-origin errors
}
};
- const cleanupFunctions = iframes.map(iframe => iframe ? syncScroll(iframe) : null).filter(Boolean);
- return () => cleanupFunctions.forEach(cleanup => cleanup?.());
+ const cleanupFunctions = iframes
+ .map((iframe) => (iframe ? syncScroll(iframe) : null))
+ .filter(Boolean);
+ return () => cleanupFunctions.forEach((cleanup) => cleanup?.());
};
// Wait for iframes to load
@@ -111,13 +123,15 @@ function BestOfNEvalsPage() {
if (winnerFilter === "all") {
return evals.map((_, index) => index);
}
- return evals.map((_, index) => index).filter(index => {
- const outcome = outcomes[index];
- if (winnerFilter === "tie") {
- return outcome === "tie";
- }
- return outcome === winnerFilter;
- });
+ return evals
+ .map((_, index) => index)
+ .filter((index) => {
+ const outcome = outcomes[index];
+ if (winnerFilter === "tie") {
+ return outcome === "tie";
+ }
+ return outcome === winnerFilter;
+ });
};
const filteredIndices = getFilteredIndices();
@@ -125,9 +139,11 @@ function BestOfNEvalsPage() {
// Navigation functions
const goToPrevious = () => {
if (winnerFilter === "all") {
- setCurrentComparisonIndex(prev => Math.max(0, prev - 1));
+ setCurrentComparisonIndex((prev) => Math.max(0, prev - 1));
} else {
- const currentFilteredIndex = filteredIndices.indexOf(currentComparisonIndex);
+ const currentFilteredIndex = filteredIndices.indexOf(
+ currentComparisonIndex
+ );
if (currentFilteredIndex > 0) {
setCurrentComparisonIndex(filteredIndices[currentFilteredIndex - 1]);
}
@@ -136,9 +152,11 @@ function BestOfNEvalsPage() {
const goToNext = () => {
if (winnerFilter === "all") {
- setCurrentComparisonIndex(prev => Math.min(evals.length - 1, prev + 1));
+ setCurrentComparisonIndex((prev) => Math.min(evals.length - 1, prev + 1));
} else {
- const currentFilteredIndex = filteredIndices.indexOf(currentComparisonIndex);
+ const currentFilteredIndex = filteredIndices.indexOf(
+ currentComparisonIndex
+ );
if (currentFilteredIndex < filteredIndices.length - 1) {
setCurrentComparisonIndex(filteredIndices[currentFilteredIndex + 1]);
}
@@ -151,7 +169,11 @@ function BestOfNEvalsPage() {
// Update current index when filter changes
useEffect(() => {
- if (winnerFilter !== "all" && filteredIndices.length > 0 && !filteredIndices.includes(currentComparisonIndex)) {
+ if (
+ winnerFilter !== "all" &&
+ filteredIndices.length > 0 &&
+ !filteredIndices.includes(currentComparisonIndex)
+ ) {
setCurrentComparisonIndex(filteredIndices[0]);
}
}, [winnerFilter, filteredIndices, currentComparisonIndex]);
@@ -162,31 +184,33 @@ function BestOfNEvalsPage() {
if (evals.length === 0) return;
switch (e.key) {
- case 'ArrowLeft':
+ case "ArrowLeft":
e.preventDefault();
- setCurrentModelIndex(prev => prev > 0 ? prev - 1 : folderNames.length - 1);
+ setCurrentModelIndex((prev) =>
+ prev > 0 ? prev - 1 : folderNames.length - 1
+ );
break;
- case 'ArrowRight':
+ case "ArrowRight":
e.preventDefault();
- setCurrentModelIndex(prev => (prev + 1) % folderNames.length);
+ setCurrentModelIndex((prev) => (prev + 1) % folderNames.length);
break;
- case 'ArrowUp':
+ case "ArrowUp":
e.preventDefault();
goToPrevious();
break;
- case 'ArrowDown':
+ case "ArrowDown":
e.preventDefault();
goToNext();
break;
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
+ case "1":
+ case "2":
+ case "3":
+ case "4":
+ case "5":
+ case "6":
+ case "7":
+ case "8":
+ case "9":
e.preventDefault();
const modelIndex = parseInt(e.key) - 1;
if (modelIndex < folderNames.length) {
@@ -199,19 +223,19 @@ function BestOfNEvalsPage() {
}
}
break;
- case 't':
+ case "t":
e.preventDefault();
- handleVote(currentComparisonIndex, 'tie');
+ handleVote(currentComparisonIndex, "tie");
break;
- case 'Tab':
+ case "Tab":
e.preventDefault();
- setCurrentModelIndex(prev => (prev + 1) % folderNames.length);
+ setCurrentModelIndex((prev) => (prev + 1) % folderNames.length);
break;
}
};
- window.addEventListener('keydown', handleKeyPress);
- return () => window.removeEventListener('keydown', handleKeyPress);
+ window.addEventListener("keydown", handleKeyPress);
+ return () => window.removeEventListener("keydown", handleKeyPress);
}, [currentComparisonIndex, evals.length, folderNames.length]);
// Add/remove folder input fields
@@ -257,10 +281,7 @@ function BestOfNEvalsPage() {
try {
const queryParams = new URLSearchParams();
folderPaths.forEach((path, index) => {
- queryParams.append(
- `folder${index + 1}`,
- path
- );
+ queryParams.append(`folder${index + 1}`, path);
});
const response = await fetch(
@@ -295,12 +316,12 @@ function BestOfNEvalsPage() {
const stats = calculateStats();
const currentEval = evals[currentComparisonIndex];
-
+
// Format time helper
const formatTimeAgo = (timestamp: number) => {
const now = Date.now() / 1000;
const diff = now - timestamp;
-
+
if (diff < 3600) {
const minutes = Math.floor(diff / 60);
return `${minutes}m ago`;
@@ -312,31 +333,30 @@ function BestOfNEvalsPage() {
return `${days}d ago`;
}
};
-
// Copy results as CSV to clipboard
const copyResultsAsCSV = async () => {
const rows: string[] = [];
-
+
// Add summary statistics only
- stats.stats.forEach(stat => {
+ stats.stats.forEach((stat) => {
rows.push(`${stat.name}\t${stat.wins}\t${stat.percentage}%`);
});
if (stats.ties > 0) {
rows.push(`Ties\t${stats.ties}\t${stats.tiePercentage}%`);
}
-
- const csvContent = rows.join('\n');
-
+
+ const csvContent = rows.join("\n");
+
try {
await navigator.clipboard.writeText(csvContent);
} catch (err) {
// Fallback for older browsers
- const textArea = document.createElement('textarea');
+ const textArea = document.createElement("textarea");
textArea.value = csvContent;
document.body.appendChild(textArea);
textArea.select();
- document.execCommand('copy');
+ document.execCommand("copy");
document.body.removeChild(textArea);
}
};
@@ -349,11 +369,15 @@ function BestOfNEvalsPage() {
/* Setup Section */
<div className="flex flex-col gap-4 max-w-5xl mx-auto px-6">
<div className="flex items-center justify-between mb-2">
- <h2 className="text-xl font-semibold text-gray-200">Configure Model Comparison</h2>
+ <h2 className="text-xl font-semibold text-gray-200">
+ Configure Model Comparison
+ </h2>
<button
onClick={async () => {
try {
- const response = await fetch(`${HTTP_BACKEND_URL}/output_folders`);
+ const response = await fetch(
+ `${HTTP_BACKEND_URL}/output_folders`
+ );
const folders: OutputFolder[] = await response.json();
setAvailableFolders(folders);
} catch (error) {
@@ -363,8 +387,18 @@ function BestOfNEvalsPage() {
className="bg-gray-600 hover:bg-gray-700 text-white px-3 py-1.5 rounded-lg text-sm transition-colors flex items-center gap-2"
title="Refresh folder list"
>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
+ />
</svg>
Refresh
</button>
@@ -373,23 +407,41 @@ function BestOfNEvalsPage() {
{folderPaths.map((path, index) => (
<div key={index} className="relative">
<div className="flex items-center gap-2">
- <span className="text-sm text-gray-400 font-medium w-16">Model {index + 1}</span>
+ <span className="text-sm text-gray-400 font-medium w-16">
+ Model {index + 1}
+ </span>
<div className="flex-1 relative">
<select
value={path}
- onChange={(e) => updateFolderPath(index, e.target.value)}
+ onChange={(e) =>
+ updateFolderPath(index, e.target.value)
+ }
className="w-full px-4 py-3 pr-10 rounded-lg bg-gray-700 text-white border border-gray-600 focus:border-blue-500 focus:outline-none transition-colors text-sm appearance-none cursor-pointer"
>
<option value="">Select a folder...</option>
{availableFolders.map((folder) => (
- <option key={folder.path} value={folder.path} title={folder.name}>
+ <option
+ key={folder.path}
+ value={folder.path}
+ title={folder.name}
+ >
{folder.name}
</option>
))}
</select>
<div className="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
- <svg className="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
+ <svg
+ className="w-5 h-5 text-gray-400"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M19 9l-7 7-7-7"
+ />
</svg>
</div>
</div>
@@ -399,8 +451,18 @@ function BestOfNEvalsPage() {
className="bg-red-500 hover:bg-red-600 px-3 py-3 rounded-lg transition-colors"
title="Remove model"
>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M6 18L18 6M6 6l12 12"
+ />
</svg>
</button>
)}
@@ -413,29 +475,66 @@ function BestOfNEvalsPage() {
onClick={addFolderInput}
className="bg-gray-600 hover:bg-gray-700 text-white px-5 py-2.5 rounded-lg text-sm font-medium transition-colors flex items-center gap-2"
>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M12 4v16m8-8H4"
+ />
</svg>
Add Model
</button>
<button
onClick={loadEvals}
- disabled={isLoading || folderPaths.some(p => !p)}
+ disabled={isLoading || folderPaths.some((p) => !p)}
className="bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:cursor-not-allowed text-white px-8 py-2.5 rounded-lg text-sm font-medium transition-colors flex items-center gap-2"
>
{isLoading ? (
<>
<svg className="animate-spin h-4 w-4" viewBox="0 0 24 24">
- <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none" />
- <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
+ <circle
+ className="opacity-25"
+ cx="12"
+ cy="12"
+ r="10"
+ stroke="currentColor"
+ strokeWidth="4"
+ fill="none"
+ />
+ <path
+ className="opacity-75"
+ fill="currentColor"
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
+ />
</svg>
Loading...
</>
) : (
<>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z" />
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"
+ />
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
+ />
</svg>
Start Comparison
</>
@@ -460,11 +559,21 @@ function BestOfNEvalsPage() {
className="bg-gray-700 hover:bg-gray-600 text-white px-2.5 py-1 rounded-lg text-sm transition-colors"
title="Back to setup"
>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 19l-7-7m0 0l7-7m-7 7h18" />
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M10 19l-7-7m0 0l7-7m-7 7h18"
+ />
</svg>
</button>
-
+
<div className="flex items-center bg-gray-700 rounded-lg">
<button
onClick={goToPrevious}
@@ -472,29 +581,47 @@ function BestOfNEvalsPage() {
className="px-2.5 py-1 rounded-l-lg hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
title="Previous comparison (↑)"
>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M15 19l-7-7 7-7"
+ />
</svg>
</button>
-
+
<select
value={currentComparisonIndex}
onChange={(e) => goToComparison(parseInt(e.target.value))}
className="bg-transparent text-white px-3 py-1 text-sm font-medium focus:outline-none appearance-none cursor-pointer"
>
- {winnerFilter === "all" ? (
- evals.map((_, index) => (
- <option key={index} value={index} className="bg-gray-800">
- Comparison {index + 1} {outcomes[index] !== null ? '✓' : ''}
- </option>
- ))
- ) : (
- filteredIndices.map((index) => (
- <option key={index} value={index} className="bg-gray-800">
- Comparison {index + 1} {outcomes[index] !== null ? '✓' : ''}
- </option>
- ))
- )}
+ {winnerFilter === "all"
+ ? evals.map((_, index) => (
+ <option
+ key={index}
+ value={index}
+ className="bg-gray-800"
+ >
+ Comparison {index + 1}{" "}
+ {outcomes[index] !== null ? "✓" : ""}
+ </option>
+ ))
+ : filteredIndices.map((index) => (
+ <option
+ key={index}
+ value={index}
+ className="bg-gray-800"
+ >
+ Comparison {index + 1}{" "}
+ {outcomes[index] !== null ? "✓" : ""}
+ </option>
+ ))}
</select>
<button
@@ -503,45 +630,84 @@ function BestOfNEvalsPage() {
className="px-2.5 py-1 rounded-r-lg hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
title="Next comparison (↓)"
>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M9 5l7 7-7 7"
+ />
</svg>
</button>
</div>
<span className="text-sm text-gray-400 font-medium">
- {winnerFilter === "all"
+ {winnerFilter === "all"
? `${currentComparisonIndex + 1} of ${evals.length}`
- : `${filteredIndices.indexOf(currentComparisonIndex) + 1} of ${filteredIndices.length} (filtered)`
- }
+ : `${
+ filteredIndices.indexOf(currentComparisonIndex) + 1
+ } of ${filteredIndices.length} (filtered)`}
</span>
</div>
{/* Center: Progress and Results */}
<div className="flex items-center gap-3">
<div className="flex items-center gap-2 bg-gray-700/50 px-3 py-1 rounded-lg">
- <span className="text-xs text-gray-400 font-medium">Progress</span>
+ <span className="text-xs text-gray-400 font-medium">
+ Progress
+ </span>
<div className="w-24 h-1.5 bg-gray-600 rounded-full overflow-hidden">
- <div
+ <div
className="h-full bg-gradient-to-r from-blue-500 to-blue-400 transition-all duration-500 ease-out"
- style={{ width: `${Math.round((stats.totalVotes / evals.length) * 100)}%` }}
+ style={{
+ width: `${Math.round(
+ (stats.totalVotes / evals.length) * 100
+ )}%`,
+ }}
></div>
</div>
<span className="text-sm font-semibold text-gray-200">
{Math.round((stats.totalVotes / evals.length) * 100)}%
</span>
</div>
-
+
<button
onClick={() => setShowResults(!showResults)}
className="flex items-center gap-1.5 px-2.5 py-1 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm text-gray-200 transition-colors"
>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"
+ />
</svg>
Results
- <svg className={`w-3 h-3 transition-transform duration-200 ${showResults ? 'rotate-180' : ''}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
+ <svg
+ className={`w-3 h-3 transition-transform duration-200 ${
+ showResults ? "rotate-180" : ""
+ }`}
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M19 9l-7 7-7-7"
+ />
</svg>
</button>
@@ -566,11 +732,13 @@ function BestOfNEvalsPage() {
))}
<option value="tie">Ties</option>
</select>
-
+
{showResults && (
<div className="bg-gray-800 rounded overflow-hidden">
<div className="flex items-center justify-between px-2 py-1 bg-gray-700">
- <span className="text-xs text-gray-300 font-semibold">Results</span>
+ <span className="text-xs text-gray-300 font-semibold">
+ Results
+ </span>
<button
onClick={copyResultsAsCSV}
className="text-xs px-2 py-0.5 bg-blue-600 hover:bg-blue-700 text-white rounded"
@@ -589,16 +757,26 @@ function BestOfNEvalsPage() {
<tbody>
{stats.stats.map((stat, i) => (
<tr key={i} className="border-t border-gray-600">
- <td className="px-2 py-1 text-white">{stat.name}</td>
- <td className="px-2 py-1 text-green-400 text-center">{stat.wins}</td>
- <td className="px-2 py-1 text-green-400 text-center">{stat.percentage}%</td>
+ <td className="px-2 py-1 text-white">
+ {stat.name}
+ </td>
+ <td className="px-2 py-1 text-green-400 text-center">
+ {stat.wins}
+ </td>
+ <td className="px-2 py-1 text-green-400 text-center">
+ {stat.percentage}%
+ </td>
</tr>
))}
{stats.ties > 0 && (
<tr className="border-t border-gray-600">
<td className="px-2 py-1 text-white">Ties</td>
- <td className="px-2 py-1 text-yellow-400 text-center">{stats.ties}</td>
- <td className="px-2 py-1 text-yellow-400 text-center">{stats.tiePercentage}%</td>
+ <td className="px-2 py-1 text-yellow-400 text-center">
+ {stats.ties}
+ </td>
+ <td className="px-2 py-1 text-yellow-400 text-center">
+ {stats.tiePercentage}%
+ </td>
</tr>
)}
</tbody>
@@ -625,15 +803,25 @@ function BestOfNEvalsPage() {
<div className="bg-white rounded-lg shadow-sm overflow-hidden">
<div className="bg-gray-100 text-gray-700 px-3 py-1.5 border-b border-gray-200">
<h3 className="font-medium text-xs flex items-center gap-1">
- <svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
+ <svg
+ className="w-3 h-3"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
+ />
</svg>
Reference Image
</h3>
</div>
<div className="w-full h-[calc(100vh-200px)] flex items-center justify-center bg-gray-50 p-2">
- <img
- src={currentEval.input}
+ <img
+ src={currentEval.input}
alt={`Input for comparison ${currentComparisonIndex + 1}`}
className="max-w-full max-h-full object-contain rounded shadow-sm"
/>
@@ -656,17 +844,24 @@ function BestOfNEvalsPage() {
: "text-gray-600 hover:bg-gray-50"
}`}
>
- {name} <span className="text-xs opacity-60">({index + 1})</span>
+ {name}{" "}
+ <span className="text-xs opacity-60">
+ ({index + 1})
+ </span>
</button>
<button
- onClick={() => handleVote(currentComparisonIndex, index)}
+ onClick={() =>
+ handleVote(currentComparisonIndex, index)
+ }
className={`px-3 py-2 text-xs font-medium transition-all border-r border-gray-200 ${
outcomes[currentComparisonIndex] === index
? "bg-green-100 text-green-700"
: "text-gray-500 hover:bg-gray-50"
}`}
>
- {outcomes[currentComparisonIndex] === index ? "✓" : "Vote"}
+ {outcomes[currentComparisonIndex] === index
+ ? "✓"
+ : "Vote"}
</button>
</div>
))}
@@ -678,7 +873,9 @@ function BestOfNEvalsPage() {
: "text-gray-500 hover:bg-gray-50"
}`}
>
- {outcomes[currentComparisonIndex] === "tie" ? "Tie ✓" : "Tie (T)"}
+ {outcomes[currentComparisonIndex] === "tie"
+ ? "Tie ✓"
+ : "Tie (T)"}
</button>
</div>
</div>
@@ -696,25 +893,41 @@ function BestOfNEvalsPage() {
<DialogTrigger asChild>
<button
className="flex items-center gap-1 bg-gray-700 hover:bg-gray-800 text-white px-2 py-0.5 rounded text-xs transition-colors"
- onClick={() => setSelectedHtml(currentEval.outputs[currentModelIndex])}
+ onClick={() =>
+ setSelectedHtml(
+ currentEval.outputs[currentModelIndex]
+ )
+ }
>
- <svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />
+ <svg
+ className="w-3 h-3"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"
+ />
</svg>
Full Screen
</button>
</DialogTrigger>
- <DialogContent className="w-[95vw] max-w-[95vw] h-[95vh] max-h-[95vh] bg-gray-900">
- <div className="absolute top-4 left-4 bg-black/80 backdrop-blur text-white px-3 py-2 rounded-lg z-10">
- <span className="font-semibold">{folderNames[currentModelIndex]}</span>
- </div>
- <iframe
- srcDoc={selectedHtml}
- className="w-full h-full rounded-lg"
- ></iframe>
- </DialogContent>
- </Dialog>
- </div>
+ <DialogContent className="w-[95vw] max-w-[95vw] h-[95vh] max-h-[95vh] bg-gray-900">
+ <div className="absolute top-4 left-4 bg-black/80 backdrop-blur text-white px-3 py-2 rounded-lg z-10">
+ <span className="font-semibold">
+ {folderNames[currentModelIndex]}
+ </span>
+ </div>
+ <iframe
+ srcDoc={selectedHtml}
+ className="w-full h-full rounded-lg"
+ ></iframe>
+ </DialogContent>
+ </Dialog>
+ </div>
<div className="relative bg-gray-50">
<iframe
ref={(el) => {
@@ -722,7 +935,7 @@ function BestOfNEvalsPage() {
}}
srcDoc={currentEval.outputs[currentModelIndex]}
className="w-full h-[calc(100vh-200px)]"
- style={{ colorScheme: 'light' }}
+ style={{ colorScheme: "light" }}
></iframe>
</div>
</div>