Skip to content

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

Python

move to separate page

Abi Raja52bde8c8d024
diff --git a/frontend/src/components/evals/EvalsPage.tsx b/frontend/src/components/evals/EvalsPage.tsx
index 935f774c..c66bc9c3 100644
--- a/frontend/src/components/evals/EvalsPage.tsx
+++ b/frontend/src/components/evals/EvalsPage.tsx
@@ -1,7 +1,6 @@
-import React, { useEffect, useState } from "react";
+import React, { useEffect } from "react";
import { HTTP_BACKEND_URL } from "../../config";
import RatingPicker from "./RatingPicker";
-import { Button } from "../ui/button";
interface Eval {
input: string;
@@ -11,7 +10,6 @@ interface Eval {
function EvalsPage() {
const [evals, setEvals] = React.useState<Eval[]>([]);
const [ratings, setRatings] = React.useState<number[]>([]);
- const [isRunning, setIsRunning] = useState(false);
const total = ratings.reduce((a, b) => a + b, 0);
const max = ratings.length * 4;
@@ -28,42 +26,12 @@ function EvalsPage() {
});
}, [evals]);
- const runEvals = async () => {
- try {
- setIsRunning(true);
- const response = await fetch(`${HTTP_BACKEND_URL}/run_evals`, {
- method: "POST",
- });
-
- if (!response.ok) {
- throw new Error("Failed to run evals");
- }
-
- const outputFiles = await response.json();
- console.log("Generated files:", outputFiles);
-
- // Refresh the evals list after running
- const evalsResponse = await fetch(`${HTTP_BACKEND_URL}/evals`);
- const newEvals = await evalsResponse.json();
- setEvals(newEvals);
- setRatings(new Array(newEvals.length).fill(0));
- } catch (error) {
- console.error("Error running evals:", error);
- // You might want to add a toast notification here
- } finally {
- setIsRunning(false);
- }
- };
-
return (
<div className="mx-auto">
<div className="flex items-center justify-between w-full h-12 bg-zinc-950">
<span className="text-2xl font-semibold text-white ml-4">
Total: {total} out of {max} ({score}%)
</span>
- <Button onClick={runEvals} disabled={isRunning} className="mr-4">
- {isRunning ? "Running Evals..." : "Run Evals"}
- </Button>
</div>
<div className="flex flex-col gap-y-4 mt-4 mx-auto justify-center">
diff --git a/frontend/src/components/evals/RunEvalsPage.tsx b/frontend/src/components/evals/RunEvalsPage.tsx
new file mode 100644
index 00000000..2ed307a1
--- /dev/null
+++ b/frontend/src/components/evals/RunEvalsPage.tsx
@@ -0,0 +1,43 @@
+import { useState } from "react";
+import { Button } from "../ui/button";
+import { HTTP_BACKEND_URL } from "../../config";
+import { useNavigate } from "react-router-dom";
+
+function RunEvalsPage() {
+ const [isRunning, setIsRunning] = useState(false);
+ const navigate = useNavigate();
+
+ const runEvals = async () => {
+ try {
+ setIsRunning(true);
+ const response = await fetch(`${HTTP_BACKEND_URL}/run_evals`, {
+ method: "POST",
+ });
+
+ if (!response.ok) {
+ throw new Error("Failed to run evals");
+ }
+
+ const outputFiles = await response.json();
+ console.log("Generated files:", outputFiles);
+
+ // Navigate to evals page after completion
+ navigate("/evals");
+ } catch (error) {
+ console.error("Error running evals:", error);
+ } finally {
+ setIsRunning(false);
+ }
+ };
+
+ return (
+ <div className="flex flex-col items-center justify-center min-h-screen">
+ <h1 className="text-2xl font-bold mb-8">Run Evaluations</h1>
+ <Button onClick={runEvals} disabled={isRunning} className="w-48">
+ {isRunning ? "Running Evals..." : "Run Evals"}
+ </Button>
+ </div>
+ );
+}
+
+export default RunEvalsPage;
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index 1da1c4ae..c18896b2 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -6,6 +6,7 @@ import { Toaster } from "react-hot-toast";
import EvalsPage from "./components/evals/EvalsPage.tsx";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import PairwiseEvalsPage from "./components/evals/PairwiseEvalsPage";
+import RunEvalsPage from "./components/evals/RunEvalsPage.tsx";
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
@@ -14,6 +15,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
<Route path="/" element={<App />} />
<Route path="/evals" element={<EvalsPage />} />
<Route path="/pairwise-evals" element={<PairwiseEvalsPage />} />
+ <Route path="/run-evals" element={<RunEvalsPage />} />
</Routes>
</Router>
<Toaster toastOptions={{ className: "dark:bg-zinc-950 dark:text-white" }} />