Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
add new yourbench error message
Browse files
frontend/src/components/Benchmark/Display.jsx
CHANGED
@@ -19,6 +19,7 @@ import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
|
19 |
import API_CONFIG from "../../config/api";
|
20 |
import { useThemeMode } from "../../hooks/useThemeMode";
|
21 |
import getTheme from "../../config/theme";
|
|
|
22 |
|
23 |
/**
|
24 |
* Component to display benchmark information and evaluation button
|
@@ -28,6 +29,7 @@ import getTheme from "../../config/theme";
|
|
28 |
* @param {Function} props.onStartEvaluation - Function to call when evaluation button is clicked
|
29 |
* @param {string} props.sessionId - Session ID used for the benchmark generation
|
30 |
* @param {string} props.datasetUrl - URL to the Hugging Face dataset
|
|
|
31 |
* @returns {JSX.Element} Benchmark display component
|
32 |
*/
|
33 |
const Display = ({
|
@@ -35,6 +37,7 @@ const Display = ({
|
|
35 |
onStartEvaluation,
|
36 |
sessionId,
|
37 |
datasetUrl,
|
|
|
38 |
}) => {
|
39 |
const [isDownloading, setIsDownloading] = useState(false);
|
40 |
const { mode } = useThemeMode();
|
@@ -51,10 +54,10 @@ const Display = ({
|
|
51 |
|
52 |
setIsDownloading(true);
|
53 |
try {
|
54 |
-
//
|
55 |
const downloadUrl = `${API_CONFIG.BASE_URL}/download-questions/${sessionId}`;
|
56 |
|
57 |
-
//
|
58 |
const link = document.createElement("a");
|
59 |
link.href = downloadUrl;
|
60 |
link.setAttribute("download", `yourbench_${sessionId}_questions.json`);
|
@@ -62,13 +65,24 @@ const Display = ({
|
|
62 |
link.click();
|
63 |
document.body.removeChild(link);
|
64 |
} catch (error) {
|
65 |
-
console.error("
|
66 |
-
alert("
|
67 |
} finally {
|
68 |
setIsDownloading(false);
|
69 |
}
|
70 |
};
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
return (
|
73 |
<>
|
74 |
<Box
|
|
|
19 |
import API_CONFIG from "../../config/api";
|
20 |
import { useThemeMode } from "../../hooks/useThemeMode";
|
21 |
import getTheme from "../../config/theme";
|
22 |
+
import ErrorDisplay from "../common/ErrorDisplay";
|
23 |
|
24 |
/**
|
25 |
* Component to display benchmark information and evaluation button
|
|
|
29 |
* @param {Function} props.onStartEvaluation - Function to call when evaluation button is clicked
|
30 |
* @param {string} props.sessionId - Session ID used for the benchmark generation
|
31 |
* @param {string} props.datasetUrl - URL to the Hugging Face dataset
|
32 |
+
* @param {boolean} props.success - Whether the benchmark generation was successful
|
33 |
* @returns {JSX.Element} Benchmark display component
|
34 |
*/
|
35 |
const Display = ({
|
|
|
37 |
onStartEvaluation,
|
38 |
sessionId,
|
39 |
datasetUrl,
|
40 |
+
success = true,
|
41 |
}) => {
|
42 |
const [isDownloading, setIsDownloading] = useState(false);
|
43 |
const { mode } = useThemeMode();
|
|
|
54 |
|
55 |
setIsDownloading(true);
|
56 |
try {
|
57 |
+
// Request to download JSON questions instead of the dataset
|
58 |
const downloadUrl = `${API_CONFIG.BASE_URL}/download-questions/${sessionId}`;
|
59 |
|
60 |
+
// Create a temporary link element to trigger the download
|
61 |
const link = document.createElement("a");
|
62 |
link.href = downloadUrl;
|
63 |
link.setAttribute("download", `yourbench_${sessionId}_questions.json`);
|
|
|
65 |
link.click();
|
66 |
document.body.removeChild(link);
|
67 |
} catch (error) {
|
68 |
+
console.error("Error while downloading questions:", error);
|
69 |
+
alert("Error downloading the file. Please try again.");
|
70 |
} finally {
|
71 |
setIsDownloading(false);
|
72 |
}
|
73 |
};
|
74 |
|
75 |
+
// If benchmark failed or if the questions array is empty, display an error message
|
76 |
+
if (!success || sampleQuestions.length === 0) {
|
77 |
+
return (
|
78 |
+
<ErrorDisplay
|
79 |
+
title="Insufficient Document"
|
80 |
+
error="The provided document does not contain enough information to generate questions. Please try with a more comprehensive document."
|
81 |
+
sx={{ mt: 4 }}
|
82 |
+
/>
|
83 |
+
);
|
84 |
+
}
|
85 |
+
|
86 |
return (
|
87 |
<>
|
88 |
<Box
|
frontend/src/pages/BenchmarkDisplayPage.jsx
CHANGED
@@ -15,6 +15,7 @@ function BenchmarkDisplayPage() {
|
|
15 |
const [datasetUrl, setDatasetUrl] = useState(null);
|
16 |
const [isValidSession, setIsValidSession] = useState(true);
|
17 |
const [isLoading, setIsLoading] = useState(true);
|
|
|
18 |
const { mode } = useThemeMode();
|
19 |
const theme = getTheme(mode);
|
20 |
|
@@ -53,6 +54,8 @@ function BenchmarkDisplayPage() {
|
|
53 |
const data = await response.json();
|
54 |
console.log("API data:", data);
|
55 |
|
|
|
|
|
56 |
if (data.success && data.questions && data.questions.length > 0) {
|
57 |
console.log("Questions loaded successfully:", data.questions);
|
58 |
setBenchmarkQuestions(data.questions);
|
@@ -70,6 +73,7 @@ function BenchmarkDisplayPage() {
|
|
70 |
} catch (error) {
|
71 |
console.error("Error retrieving questions:", error);
|
72 |
setIsValidSession(false);
|
|
|
73 |
} finally {
|
74 |
setIsLoading(false);
|
75 |
}
|
@@ -147,6 +151,7 @@ function BenchmarkDisplayPage() {
|
|
147 |
? benchmarkQuestions
|
148 |
: defaultSampleQuestions
|
149 |
}
|
|
|
150 |
/>
|
151 |
</Box>
|
152 |
)}
|
|
|
15 |
const [datasetUrl, setDatasetUrl] = useState(null);
|
16 |
const [isValidSession, setIsValidSession] = useState(true);
|
17 |
const [isLoading, setIsLoading] = useState(true);
|
18 |
+
const [success, setSuccess] = useState(true);
|
19 |
const { mode } = useThemeMode();
|
20 |
const theme = getTheme(mode);
|
21 |
|
|
|
54 |
const data = await response.json();
|
55 |
console.log("API data:", data);
|
56 |
|
57 |
+
setSuccess(data.success || false);
|
58 |
+
|
59 |
if (data.success && data.questions && data.questions.length > 0) {
|
60 |
console.log("Questions loaded successfully:", data.questions);
|
61 |
setBenchmarkQuestions(data.questions);
|
|
|
73 |
} catch (error) {
|
74 |
console.error("Error retrieving questions:", error);
|
75 |
setIsValidSession(false);
|
76 |
+
setSuccess(false);
|
77 |
} finally {
|
78 |
setIsLoading(false);
|
79 |
}
|
|
|
151 |
? benchmarkQuestions
|
152 |
: defaultSampleQuestions
|
153 |
}
|
154 |
+
success={success}
|
155 |
/>
|
156 |
</Box>
|
157 |
)}
|