Skip to content

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

Python

improve eval runner UI

Abi Rajad8a80dc7030a
diff --git a/frontend/src/components/evals/InputFileSelector.tsx b/frontend/src/components/evals/InputFileSelector.tsx
index de524d54..906aed2f 100644
--- a/frontend/src/components/evals/InputFileSelector.tsx
+++ b/frontend/src/components/evals/InputFileSelector.tsx
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { HTTP_BACKEND_URL } from "../../config";
-import { BsCheckLg } from "react-icons/bs";
+import { BsCheckLg, BsChevronDown, BsChevronRight } from "react-icons/bs";
import { Button } from "../ui/button";
interface InputFile {
@@ -16,7 +16,8 @@ function InputFileSelector({ onFilesSelected }: InputFileSelectorProps) {
const [inputFiles, setInputFiles] = useState<InputFile[]>([]);
const [selectedFiles, setSelectedFiles] = useState<string[]>([]);
const [isLoading, setIsLoading] = useState(false);
-
+ const [isExpanded, setIsExpanded] = useState(false);
+
useEffect(() => {
fetchInputFiles();
}, []);
@@ -65,63 +66,83 @@ function InputFileSelector({ onFilesSelected }: InputFileSelectorProps) {
onFilesSelected([]);
};
+ const toggleExpanded = () => {
+ setIsExpanded(!isExpanded);
+ };
+
if (isLoading) {
- return <div className="text-center">Loading input files...</div>;
+ return <div className="text-center text-sm text-gray-500">Loading input files...</div>;
}
+ const fileCount = inputFiles.length;
+ const selectedCount = selectedFiles.length;
+
return (
- <div className="w-full max-w-md">
- <div className="border rounded-md p-2 space-y-2 max-h-80 overflow-y-auto">
- {inputFiles.map((file) => (
- <div
- key={file.path}
- className={`flex items-center justify-between p-2 rounded cursor-pointer hover:bg-gray-50 ${
- selectedFiles.includes(file.path)
- ? "bg-blue-50 border border-blue-200"
- : ""
- }`}
- onClick={() => handleFileToggle(file.path)}
- >
- <span className="text-sm truncate" title={file.name}>
- {file.name}
+ <div className="w-full">
+ <div
+ className="flex items-center justify-between cursor-pointer hover:bg-gray-50 rounded-md p-2 mb-2 border"
+ onClick={toggleExpanded}
+ >
+ <div className="flex items-center gap-2">
+ {isExpanded ? <BsChevronDown className="text-gray-500" /> : <BsChevronRight className="text-gray-500" />}
+ <div>
+ <span className="text-sm font-medium">Input Files</span>
+ <span className="ml-2 text-xs text-gray-500">
+ {selectedCount} of {fileCount} selected
</span>
- {selectedFiles.includes(file.path) ? (
- <BsCheckLg className="h-4 w-4 text-blue-500" />
- ) : (
- <div className="h-4 w-4 border rounded-sm" />
- )}
</div>
- ))}
+ </div>
+
+ <div className="flex space-x-1" onClick={(e) => e.stopPropagation()}>
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={handleSelectAll}
+ className="text-xs h-6 px-2 text-gray-500 hover:text-gray-700"
+ disabled={selectedCount === fileCount}
+ >
+ All
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={handleClearAll}
+ className="text-xs h-6 px-2 text-gray-500 hover:text-gray-700"
+ disabled={selectedCount === 0}
+ >
+ None
+ </Button>
+ </div>
</div>
- <div className="flex justify-between mt-2">
- <p className="text-sm text-gray-500">
- Selected: {selectedFiles.length} file
- {selectedFiles.length !== 1 ? "s" : ""}
- </p>
- <div className="space-x-2">
- {selectedFiles.length < inputFiles.length && (
- <Button
- variant="ghost"
- size="sm"
- onClick={handleSelectAll}
- className="text-sm text-gray-500 hover:text-gray-700"
- >
- Select all
- </Button>
- )}
- {selectedFiles.length > 0 && (
- <Button
- variant="ghost"
- size="sm"
- onClick={handleClearAll}
- className="text-sm text-gray-500 hover:text-gray-700"
- >
- Clear all
- </Button>
- )}
+ {isExpanded && (
+ <div className="border rounded-md overflow-hidden">
+ <div className="max-h-48 overflow-y-auto">
+ <div className="grid grid-cols-1 divide-y divide-gray-100">
+ {inputFiles.map((file) => (
+ <div
+ key={file.path}
+ className={`flex items-center justify-between px-3 py-1.5 cursor-pointer hover:bg-gray-50 ${
+ selectedFiles.includes(file.path)
+ ? "bg-blue-50"
+ : ""
+ }`}
+ onClick={() => handleFileToggle(file.path)}
+ >
+ <span className="text-xs truncate pr-2" title={file.name}>
+ {file.name}
+ </span>
+ {selectedFiles.includes(file.path) ? (
+ <BsCheckLg className="h-3 w-3 text-blue-500 flex-shrink-0" />
+ ) : (
+ <div className="h-3 w-3 border rounded-sm flex-shrink-0" />
+ )}
+ </div>
+ ))}
+ </div>
+ </div>
</div>
- </div>
+ )}
</div>
);
}
diff --git a/frontend/src/components/evals/RunEvalsPage.tsx b/frontend/src/components/evals/RunEvalsPage.tsx
index c5a74cf8..4490e3f7 100644
--- a/frontend/src/components/evals/RunEvalsPage.tsx
+++ b/frontend/src/components/evals/RunEvalsPage.tsx
@@ -87,112 +87,141 @@ function RunEvalsPage() {
};
return (
- <div className="flex flex-col items-center justify-center min-h-screen">
- <h1 className="text-2xl font-bold mb-8">Run Evaluations</h1>
-
- <div className="max-w-md text-center mb-8 text-gray-600">
- <p className="mb-2">
- Evaluation inputs will be read from:
- <code className="block bg-gray-100 p-1 mt-1 rounded">
- backend/evals_data/inputs
- </code>
- </p>
- <p>
- Results will be saved to:
- <code className="block bg-gray-100 p-1 mt-1 rounded">
- backend/evals_data/outputs
- </code>
- </p>
+ <div className="container mx-auto px-4 py-8">
+ <h1 className="text-2xl font-bold mb-6 text-center">Run Evaluations</h1>
+
+ <div className="bg-gray-50 border border-gray-200 rounded-lg p-4 mb-6 text-sm text-gray-600 mx-auto max-w-5xl">
+ <div className="flex justify-between items-center flex-wrap gap-4">
+ <div>
+ <p className="font-medium">Evaluation inputs:</p>
+ <code className="bg-gray-100 px-2 py-1 rounded text-xs">
+ backend/evals_data/inputs
+ </code>
+ </div>
+ <div>
+ <p className="font-medium">Results will be saved to:</p>
+ <code className="bg-gray-100 px-2 py-1 rounded text-xs">
+ backend/evals_data/outputs
+ </code>
+ </div>
+ <Button
+ onClick={runEvals}
+ disabled={isRunning || selectedModels.length === 0 || selectedFiles.length === 0}
+ className={`px-6 ${isRunning ? "bg-blue-400" : "bg-blue-600 hover:bg-blue-700"}`}
+ >
+ {isRunning ? "Running Evals..." : "Run Evals"}
+ </Button>
+ </div>
</div>
- <div className="space-y-6 w-full max-w-md">
- <div>
- <label className="block text-gray-700 text-sm font-bold mb-2">
- Select Models
- </label>
- <div className="border rounded-md p-2 space-y-2">
- {models.map((model) => (
- <div
- key={model}
- className={`flex items-center justify-between p-2 rounded cursor-pointer hover:bg-gray-50 ${
- selectedModels.includes(model)
- ? "bg-blue-50 border border-blue-200"
- : ""
- }`}
- onClick={() => handleModelToggle(model)}
- >
- <span className="text-sm">{model}</span>
- {selectedModels.includes(model) ? (
- <BsCheckLg className="h-4 w-4 text-blue-500" />
- ) : (
- <div className="h-4 w-4 border rounded-sm" />
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 max-w-5xl mx-auto">
+ {/* Model Selection Section */}
+ <div className="bg-white rounded-lg border border-gray-200 shadow-sm">
+ <div className="border-b border-gray-200 px-4 py-3 bg-gray-50 rounded-t-lg">
+ <h2 className="font-medium">Select Models</h2>
+ </div>
+ <div className="p-3">
+ <div className="border rounded-md max-h-[300px] overflow-y-auto">
+ <div className="grid grid-cols-1 divide-y divide-gray-100">
+ {models.map((model) => (
+ <div
+ key={model}
+ className={`flex items-center justify-between px-3 py-2 cursor-pointer hover:bg-gray-50 ${
+ selectedModels.includes(model)
+ ? "bg-blue-50"
+ : ""
+ }`}
+ onClick={() => handleModelToggle(model)}
+ >
+ <span className="text-sm truncate" title={model}>{model}</span>
+ {selectedModels.includes(model) ? (
+ <BsCheckLg className="h-3.5 w-3.5 text-blue-500 flex-shrink-0" />
+ ) : (
+ <div className="h-3.5 w-3.5 border rounded-sm flex-shrink-0" />
+ )}
+ </div>
+ ))}
+ </div>
+ </div>
+ <div className="flex justify-between mt-2 text-xs">
+ <p className="text-gray-500">
+ Selected: {selectedModels.length} / {models.length}
+ </p>
+ <div className="space-x-2">
+ {selectedModels.length < models.length && (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={handleSelectAll}
+ className="text-xs h-6 px-2 text-gray-500 hover:text-gray-700"
+ >
+ Select all
+ </Button>
+ )}
+ {selectedModels.length > 0 && (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => setSelectedModels([])}
+ className="text-xs h-6 px-2 text-gray-500 hover:text-gray-700"
+ >
+ Clear
+ </Button>
)}
</div>
- ))}
- </div>
- <div className="flex justify-between mt-2">
- <p className="text-sm text-gray-500">
- Selected: {selectedModels.length} model
- {selectedModels.length !== 1 ? "s" : ""}
- </p>
- <div className="space-x-2">
- {selectedModels.length < models.length && (
- <Button
- variant="ghost"
- size="sm"
- onClick={handleSelectAll}
- className="text-sm text-gray-500 hover:text-gray-700"
- >
- Select all
- </Button>
- )}
- {selectedModels.length > 0 && (
- <Button
- variant="ghost"
- size="sm"
- onClick={() => setSelectedModels([])}
- className="text-sm text-gray-500 hover:text-gray-700"
- >
- Clear all
- </Button>
- )}
</div>
</div>
</div>
- <div>
- <label className="block text-gray-700 text-sm font-bold mb-2">
- Select Stack
- </label>
- <select
- value={selectedStack}
- onChange={(e) => setSelectedStack(e.target.value)}
- className="shadow border rounded w-full py-2 px-3 text-gray-700"
- required
- >
- {stacks.map((stack) => (
- <option key={stack} value={stack}>
- {stack}
- </option>
- ))}
- </select>
+ {/* Stack Selection Section */}
+ <div className="bg-white rounded-lg border border-gray-200 shadow-sm">
+ <div className="border-b border-gray-200 px-4 py-3 bg-gray-50 rounded-t-lg">
+ <h2 className="font-medium">Select Stack</h2>
+ </div>
+ <div className="p-3">
+ <select
+ value={selectedStack}
+ onChange={(e) => setSelectedStack(e.target.value)}
+ className="w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"
+ >
+ {stacks.map((stack) => (
+ <option key={stack} value={stack}>
+ {stack}
+ </option>
+ ))}
+ </select>
+ </div>
</div>
- <div>
- <label className="block text-gray-700 text-sm font-bold mb-2">
- Select Input Files
- </label>
- <InputFileSelector onFilesSelected={handleFilesSelected} />
+ {/* Input Files Section */}
+ <div className="bg-white rounded-lg border border-gray-200 shadow-sm lg:col-span-1 md:col-span-2">
+ <div className="border-b border-gray-200 px-4 py-3 bg-gray-50 rounded-t-lg">
+ <h2 className="font-medium">Select Input Files</h2>
+ </div>
+ <div className="p-3">
+ <InputFileSelector onFilesSelected={handleFilesSelected} />
+ </div>
</div>
</div>
- <Button
- onClick={runEvals}
- disabled={isRunning || selectedModels.length === 0 || selectedFiles.length === 0}
- className="w-48 mt-6"
- >
- {isRunning ? "Running Evals..." : "Run Evals"}
- </Button>
+ {/* Summary Section */}
+ <div className="mt-6 bg-white rounded-lg border border-gray-200 p-4 max-w-5xl mx-auto">
+ <div className="flex flex-wrap gap-4 justify-between items-center">
+ <div className="flex flex-col gap-0.5">
+ <p className="text-sm font-medium">Configuration Summary</p>
+ <p className="text-xs text-gray-500">
+ {selectedModels.length} models • {selectedStack} • {selectedFiles.length} files
+ </p>
+ </div>
+ <Button
+ onClick={runEvals}
+ disabled={isRunning || selectedModels.length === 0 || selectedFiles.length === 0}
+ className={`w-36 ${isRunning ? "bg-blue-400" : "bg-blue-600 hover:bg-blue-700"}`}
+ >
+ {isRunning ? "Running Evals..." : "Run Evals"}
+ </Button>
+ </div>
+ </div>
</div>
);
}