Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
update production api url
Browse files- Dockerfile +3 -0
- backend/data/lighteval_results/lighteval_results.json +9 -9
- backend/data/lighteval_results/results/deepseek-ai/DeepSeek-V3-0324/results_2025-03-28T12-28-57.341922.json +121 -0
- backend/routes/evaluation.py +2 -1
- backend/tasks/createBenchConfigFile.py +9 -7
- backend/tasks/evaluationTask.py +36 -30
- frontend/src/components/BenchmarkDisplay.jsx +2 -1
- frontend/src/components/BenchmarkEvaluation.jsx +15 -11
- frontend/src/components/BenchmarkGenerator.jsx +16 -11
- frontend/src/config/api.js +11 -0
- frontend/src/pages/BenchmarkDisplayPage.jsx +2 -1
Dockerfile
CHANGED
@@ -5,6 +5,9 @@ COPY frontend/package*.json ./
|
|
5 |
RUN npm install
|
6 |
COPY frontend/ ./
|
7 |
|
|
|
|
|
|
|
8 |
RUN npm run build
|
9 |
|
10 |
# Build backend
|
|
|
5 |
RUN npm install
|
6 |
COPY frontend/ ./
|
7 |
|
8 |
+
# Set environment variable for production build
|
9 |
+
ENV REACT_APP_NODE_ENV=production
|
10 |
+
|
11 |
RUN npm run build
|
12 |
|
13 |
# Build backend
|
backend/data/lighteval_results/lighteval_results.json
CHANGED
@@ -1,11 +1,4 @@
|
|
1 |
[
|
2 |
-
{
|
3 |
-
"model": "deepseek-ai/DeepSeek-V3-0324",
|
4 |
-
"provider": "novita",
|
5 |
-
"accuracy": 1.0,
|
6 |
-
"execution_time": 54.32098197937012,
|
7 |
-
"status": "success"
|
8 |
-
},
|
9 |
{
|
10 |
"model": "Qwen/QwQ-32B",
|
11 |
"provider": "sambanova",
|
@@ -14,14 +7,21 @@
|
|
14 |
"status": "timeout"
|
15 |
},
|
16 |
{
|
17 |
-
"model": "
|
18 |
"provider": "sambanova",
|
19 |
"accuracy": 0.0,
|
20 |
"execution_time": 60.0,
|
21 |
"status": "timeout"
|
22 |
},
|
23 |
{
|
24 |
-
"model": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
"provider": "sambanova",
|
26 |
"accuracy": 0.0,
|
27 |
"execution_time": 60.0,
|
|
|
1 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
{
|
3 |
"model": "Qwen/QwQ-32B",
|
4 |
"provider": "sambanova",
|
|
|
7 |
"status": "timeout"
|
8 |
},
|
9 |
{
|
10 |
+
"model": "Qwen/Qwen2.5-72B-Instruct",
|
11 |
"provider": "sambanova",
|
12 |
"accuracy": 0.0,
|
13 |
"execution_time": 60.0,
|
14 |
"status": "timeout"
|
15 |
},
|
16 |
{
|
17 |
+
"model": "deepseek-ai/DeepSeek-V3-0324",
|
18 |
+
"provider": "novita",
|
19 |
+
"accuracy": 0.0,
|
20 |
+
"execution_time": 60.0,
|
21 |
+
"status": "timeout"
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"model": "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
|
25 |
"provider": "sambanova",
|
26 |
"accuracy": 0.0,
|
27 |
"execution_time": 60.0,
|
backend/data/lighteval_results/results/deepseek-ai/DeepSeek-V3-0324/results_2025-03-28T12-28-57.341922.json
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"config_general": {
|
3 |
+
"lighteval_sha": "?",
|
4 |
+
"num_fewshot_seeds": 1,
|
5 |
+
"override_batch_size": null,
|
6 |
+
"max_samples": 30,
|
7 |
+
"job_id": 0,
|
8 |
+
"start_time": 191865.098197958,
|
9 |
+
"end_time": 191926.425937958,
|
10 |
+
"total_evaluation_time_secondes": "61.32774000000791",
|
11 |
+
"model_name": "deepseek-ai/DeepSeek-V3-0324",
|
12 |
+
"model_sha": "",
|
13 |
+
"model_dtype": null,
|
14 |
+
"model_size": "",
|
15 |
+
"generation_parameters": {
|
16 |
+
"early_stopping": null,
|
17 |
+
"repetition_penalty": null,
|
18 |
+
"frequency_penalty": null,
|
19 |
+
"length_penalty": null,
|
20 |
+
"presence_penalty": null,
|
21 |
+
"max_new_tokens": null,
|
22 |
+
"min_new_tokens": null,
|
23 |
+
"seed": null,
|
24 |
+
"stop_tokens": null,
|
25 |
+
"temperature": null,
|
26 |
+
"top_k": null,
|
27 |
+
"min_p": null,
|
28 |
+
"top_p": null,
|
29 |
+
"truncate_prompt": null,
|
30 |
+
"response_format": null
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"results": {
|
34 |
+
"custom|yourbench|0": {
|
35 |
+
"accuracy": 1.0,
|
36 |
+
"accuracy_stderr": 0.0
|
37 |
+
},
|
38 |
+
"all": {
|
39 |
+
"accuracy": 1.0,
|
40 |
+
"accuracy_stderr": 0.0
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"versions": {
|
44 |
+
"custom|yourbench|0": 0
|
45 |
+
},
|
46 |
+
"config_tasks": {
|
47 |
+
"custom|yourbench": {
|
48 |
+
"name": "yourbench",
|
49 |
+
"prompt_function": "yourbench_prompt",
|
50 |
+
"hf_repo": "yourbench/yourbench_d61a6289-9f2e-4138-b01a-63c43c5daf0b",
|
51 |
+
"hf_subset": "multi_hop_questions",
|
52 |
+
"metric": [
|
53 |
+
{
|
54 |
+
"metric_name": [
|
55 |
+
"accuracy"
|
56 |
+
],
|
57 |
+
"higher_is_better": {
|
58 |
+
"accuracy": true
|
59 |
+
},
|
60 |
+
"category": "7",
|
61 |
+
"use_case": "1",
|
62 |
+
"sample_level_fn": "compute",
|
63 |
+
"corpus_level_fn": {
|
64 |
+
"accuracy": "mean"
|
65 |
+
}
|
66 |
+
}
|
67 |
+
],
|
68 |
+
"hf_revision": null,
|
69 |
+
"hf_filter": null,
|
70 |
+
"hf_avail_splits": [
|
71 |
+
"train"
|
72 |
+
],
|
73 |
+
"trust_dataset": true,
|
74 |
+
"evaluation_splits": [
|
75 |
+
"train"
|
76 |
+
],
|
77 |
+
"few_shots_split": null,
|
78 |
+
"few_shots_select": null,
|
79 |
+
"generation_size": 8192,
|
80 |
+
"generation_grammar": null,
|
81 |
+
"stop_sequence": [],
|
82 |
+
"num_samples": null,
|
83 |
+
"suite": [
|
84 |
+
"custom"
|
85 |
+
],
|
86 |
+
"original_num_docs": 34,
|
87 |
+
"effective_num_docs": 30,
|
88 |
+
"must_remove_duplicate_docs": false,
|
89 |
+
"version": 0
|
90 |
+
}
|
91 |
+
},
|
92 |
+
"summary_tasks": {
|
93 |
+
"custom|yourbench|0": {
|
94 |
+
"hashes": {
|
95 |
+
"hash_examples": "1b5afc5f13827f79",
|
96 |
+
"hash_full_prompts": "cd8c39c007643835",
|
97 |
+
"hash_input_tokens": "79ab129e9a18c6d6",
|
98 |
+
"hash_cont_tokens": "79ab129e9a18c6d6"
|
99 |
+
},
|
100 |
+
"truncated": 0,
|
101 |
+
"non_truncated": 30,
|
102 |
+
"padded": 0,
|
103 |
+
"non_padded": 30,
|
104 |
+
"effective_few_shots": 0.0,
|
105 |
+
"num_truncated_few_shots": 0
|
106 |
+
}
|
107 |
+
},
|
108 |
+
"summary_general": {
|
109 |
+
"hashes": {
|
110 |
+
"hash_examples": "b18e19e266a5bc51",
|
111 |
+
"hash_full_prompts": "1eaa15cbc4a17d04",
|
112 |
+
"hash_input_tokens": "05a66e44e190c178",
|
113 |
+
"hash_cont_tokens": "05a66e44e190c178"
|
114 |
+
},
|
115 |
+
"truncated": 0,
|
116 |
+
"non_truncated": 30,
|
117 |
+
"padded": 0,
|
118 |
+
"non_padded": 30,
|
119 |
+
"num_truncated_few_shots": 0
|
120 |
+
}
|
121 |
+
}
|
backend/routes/evaluation.py
CHANGED
@@ -5,6 +5,7 @@ from tasks.evaluationTask import EvaluationTask
|
|
5 |
from huggingface_hub import hf_hub_download
|
6 |
import json
|
7 |
from datetime import datetime
|
|
|
8 |
|
9 |
router = APIRouter(tags=["evaluation"])
|
10 |
|
@@ -51,7 +52,7 @@ async def evaluate_benchmark(data: Dict[str, Any]):
|
|
51 |
active_evaluation_tasks[session_id] = evaluation_task
|
52 |
|
53 |
# Démarrer l'évaluation de manière asynchrone
|
54 |
-
evaluation_task.run()
|
55 |
|
56 |
# Récupérer les logs initiaux
|
57 |
initial_logs = evaluation_task.get_logs()
|
|
|
5 |
from huggingface_hub import hf_hub_download
|
6 |
import json
|
7 |
from datetime import datetime
|
8 |
+
import asyncio
|
9 |
|
10 |
router = APIRouter(tags=["evaluation"])
|
11 |
|
|
|
52 |
active_evaluation_tasks[session_id] = evaluation_task
|
53 |
|
54 |
# Démarrer l'évaluation de manière asynchrone
|
55 |
+
asyncio.create_task(evaluation_task.run())
|
56 |
|
57 |
# Récupérer les logs initiaux
|
58 |
initial_logs = evaluation_task.get_logs()
|
backend/tasks/createBenchConfigFile.py
CHANGED
@@ -278,13 +278,15 @@ class CreateBenchConfigTask:
|
|
278 |
# Mark the task as running
|
279 |
self.is_running_flag.set()
|
280 |
|
281 |
-
#
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
|
|
|
|
288 |
|
289 |
def is_running(self) -> bool:
|
290 |
"""
|
|
|
278 |
# Mark the task as running
|
279 |
self.is_running_flag.set()
|
280 |
|
281 |
+
# Run the task directly without threading
|
282 |
+
try:
|
283 |
+
config_path = self._run_task(file_path)
|
284 |
+
return config_path
|
285 |
+
except Exception as e:
|
286 |
+
error_msg = f"Error generating configuration: {str(e)}"
|
287 |
+
self._add_log(f"[ERROR] {error_msg}")
|
288 |
+
self.mark_task_completed()
|
289 |
+
raise RuntimeError(error_msg)
|
290 |
|
291 |
def is_running(self) -> bool:
|
292 |
"""
|
backend/tasks/evaluationTask.py
CHANGED
@@ -13,6 +13,7 @@ import json
|
|
13 |
from typing import List, Dict
|
14 |
from tasks.get_model_providers import get_model_providers
|
15 |
from huggingface_hub import HfApi
|
|
|
16 |
|
17 |
class EvaluationTask:
|
18 |
"""
|
@@ -60,7 +61,7 @@ class EvaluationTask:
|
|
60 |
except Exception as e:
|
61 |
print(f"[{datetime.now().strftime('%H:%M:%S')}] Failed to save results to Hub: {str(e)}")
|
62 |
|
63 |
-
def _run_lighteval(self, model_name: str, provider: str, dataset_name: str) -> dict:
|
64 |
start_time = time.time()
|
65 |
print(f"[{datetime.now().strftime('%H:%M:%S')}] Starting evaluation with {provider} provider for {model_name}")
|
66 |
|
@@ -88,21 +89,38 @@ TASKS_TABLE = [yourbench]
|
|
88 |
temp_file_path,
|
89 |
"--max-samples", "30",
|
90 |
"--output-dir", "data/lighteval_results",
|
91 |
-
# "--save-details",
|
92 |
"--no-push-to-hub"
|
93 |
]
|
94 |
|
95 |
try:
|
96 |
-
# Run the command with environment variables and timeout of
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
return {
|
101 |
"model": model_name,
|
102 |
"provider": provider,
|
103 |
"accuracy": 0.0,
|
104 |
-
"execution_time":
|
105 |
-
"status": "
|
106 |
}
|
107 |
|
108 |
# Calculate execution time
|
@@ -138,12 +156,9 @@ TASKS_TABLE = [yourbench]
|
|
138 |
"status": "parse_error"
|
139 |
}
|
140 |
|
141 |
-
def
|
142 |
"""
|
143 |
-
Run the evaluation task
|
144 |
-
|
145 |
-
Returns:
|
146 |
-
List of results for each model
|
147 |
"""
|
148 |
# Start global timer
|
149 |
script_start_time = time.time()
|
@@ -164,14 +179,13 @@ TASKS_TABLE = [yourbench]
|
|
164 |
|
165 |
print(f"[{datetime.now().strftime('%H:%M:%S')}] Starting parallel evaluations")
|
166 |
|
167 |
-
# Run evaluations in parallel using
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
self.results = [future.result() for future in concurrent.futures.as_completed(futures)]
|
175 |
|
176 |
# Calculate total script execution time
|
177 |
total_time = time.time() - script_start_time
|
@@ -182,8 +196,6 @@ TASKS_TABLE = [yourbench]
|
|
182 |
|
183 |
# Mark the task as completed
|
184 |
self.is_completed = True
|
185 |
-
|
186 |
-
return self.results
|
187 |
|
188 |
def get_logs(self) -> List[str]:
|
189 |
"""
|
@@ -201,10 +213,4 @@ TASKS_TABLE = [yourbench]
|
|
201 |
Returns:
|
202 |
True if completed, False otherwise
|
203 |
"""
|
204 |
-
return self.is_completed
|
205 |
-
|
206 |
-
def run(self) -> None:
|
207 |
-
"""
|
208 |
-
Run the evaluation task (wrapper around run_parallel)
|
209 |
-
"""
|
210 |
-
self.run_parallel()
|
|
|
13 |
from typing import List, Dict
|
14 |
from tasks.get_model_providers import get_model_providers
|
15 |
from huggingface_hub import HfApi
|
16 |
+
import asyncio
|
17 |
|
18 |
class EvaluationTask:
|
19 |
"""
|
|
|
61 |
except Exception as e:
|
62 |
print(f"[{datetime.now().strftime('%H:%M:%S')}] Failed to save results to Hub: {str(e)}")
|
63 |
|
64 |
+
async def _run_lighteval(self, model_name: str, provider: str, dataset_name: str) -> dict:
|
65 |
start_time = time.time()
|
66 |
print(f"[{datetime.now().strftime('%H:%M:%S')}] Starting evaluation with {provider} provider for {model_name}")
|
67 |
|
|
|
89 |
temp_file_path,
|
90 |
"--max-samples", "30",
|
91 |
"--output-dir", "data/lighteval_results",
|
|
|
92 |
"--no-push-to-hub"
|
93 |
]
|
94 |
|
95 |
try:
|
96 |
+
# Run the command with environment variables and increased timeout of 300 seconds
|
97 |
+
process = await asyncio.create_subprocess_exec(
|
98 |
+
*cmd_args,
|
99 |
+
env=os.environ,
|
100 |
+
stdout=asyncio.subprocess.PIPE,
|
101 |
+
stderr=asyncio.subprocess.PIPE
|
102 |
+
)
|
103 |
+
|
104 |
+
try:
|
105 |
+
await asyncio.wait_for(process.communicate(), timeout=60)
|
106 |
+
except asyncio.TimeoutError:
|
107 |
+
process.kill()
|
108 |
+
print(f"[{datetime.now().strftime('%H:%M:%S')}] Evaluation timed out for {model_name} after {time.time() - start_time:.2f}s")
|
109 |
+
return {
|
110 |
+
"model": model_name,
|
111 |
+
"provider": provider,
|
112 |
+
"accuracy": 0.0,
|
113 |
+
"execution_time": 60.0,
|
114 |
+
"status": "timeout"
|
115 |
+
}
|
116 |
+
except Exception as e:
|
117 |
+
print(f"[{datetime.now().strftime('%H:%M:%S')}] Error running evaluation for {model_name}: {str(e)}")
|
118 |
return {
|
119 |
"model": model_name,
|
120 |
"provider": provider,
|
121 |
"accuracy": 0.0,
|
122 |
+
"execution_time": time.time() - start_time,
|
123 |
+
"status": "error"
|
124 |
}
|
125 |
|
126 |
# Calculate execution time
|
|
|
156 |
"status": "parse_error"
|
157 |
}
|
158 |
|
159 |
+
async def run(self) -> None:
|
160 |
"""
|
161 |
+
Run the evaluation task asynchronously
|
|
|
|
|
|
|
162 |
"""
|
163 |
# Start global timer
|
164 |
script_start_time = time.time()
|
|
|
179 |
|
180 |
print(f"[{datetime.now().strftime('%H:%M:%S')}] Starting parallel evaluations")
|
181 |
|
182 |
+
# Run evaluations in parallel using asyncio
|
183 |
+
tasks = []
|
184 |
+
for model_name, providers in model_providers:
|
185 |
+
if providers: # Only run if providers are available
|
186 |
+
tasks.append(self._run_lighteval(model_name, providers[0], self.dataset_name))
|
187 |
+
|
188 |
+
self.results = await asyncio.gather(*tasks)
|
|
|
189 |
|
190 |
# Calculate total script execution time
|
191 |
total_time = time.time() - script_start_time
|
|
|
196 |
|
197 |
# Mark the task as completed
|
198 |
self.is_completed = True
|
|
|
|
|
199 |
|
200 |
def get_logs(self) -> List[str]:
|
201 |
"""
|
|
|
213 |
Returns:
|
214 |
True if completed, False otherwise
|
215 |
"""
|
216 |
+
return self.is_completed
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/components/BenchmarkDisplay.jsx
CHANGED
@@ -16,6 +16,7 @@ import AssessmentIcon from "@mui/icons-material/Assessment";
|
|
16 |
import LinkIcon from "@mui/icons-material/Link";
|
17 |
import DownloadIcon from "@mui/icons-material/Download";
|
18 |
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
|
|
19 |
|
20 |
/**
|
21 |
* Component to display benchmark information and evaluation button
|
@@ -67,7 +68,7 @@ const BenchmarkDisplay = ({
|
|
67 |
setIsDownloading(true);
|
68 |
try {
|
69 |
// Requête pour télécharger le dataset
|
70 |
-
const downloadUrl =
|
71 |
|
72 |
// Créer un élément a temporaire pour déclencher le téléchargement
|
73 |
const link = document.createElement("a");
|
|
|
16 |
import LinkIcon from "@mui/icons-material/Link";
|
17 |
import DownloadIcon from "@mui/icons-material/Download";
|
18 |
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
19 |
+
import API_CONFIG from "../config/api";
|
20 |
|
21 |
/**
|
22 |
* Component to display benchmark information and evaluation button
|
|
|
68 |
setIsDownloading(true);
|
69 |
try {
|
70 |
// Requête pour télécharger le dataset
|
71 |
+
const downloadUrl = `${API_CONFIG.BASE_URL}/download-dataset/${sessionId}`;
|
72 |
|
73 |
// Créer un élément a temporaire pour déclencher le téléchargement
|
74 |
const link = document.createElement("a");
|
frontend/src/components/BenchmarkEvaluation.jsx
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import React, { useState, useEffect, useRef } from "react";
|
2 |
import { Box, Typography, CircularProgress, Alert, Paper } from "@mui/material";
|
3 |
-
import { useNavigate } from "react-router-dom";
|
|
|
4 |
|
5 |
// Starting messages with their timing
|
6 |
const STARTING_MESSAGES = [
|
@@ -96,15 +97,18 @@ const BenchmarkEvaluation = ({ sessionId, onComplete }) => {
|
|
96 |
|
97 |
try {
|
98 |
// Call API to start evaluation
|
99 |
-
const response = await fetch(
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
108 |
|
109 |
const result = await response.json();
|
110 |
|
@@ -113,7 +117,7 @@ const BenchmarkEvaluation = ({ sessionId, onComplete }) => {
|
|
113 |
pollingIntervalRef.current = setInterval(async () => {
|
114 |
try {
|
115 |
const logsResponse = await fetch(
|
116 |
-
|
117 |
);
|
118 |
|
119 |
if (logsResponse.ok) {
|
|
|
1 |
import React, { useState, useEffect, useRef } from "react";
|
2 |
import { Box, Typography, CircularProgress, Alert, Paper } from "@mui/material";
|
3 |
+
import { useNavigate, useSearchParams } from "react-router-dom";
|
4 |
+
import API_CONFIG from "../config/api";
|
5 |
|
6 |
// Starting messages with their timing
|
7 |
const STARTING_MESSAGES = [
|
|
|
97 |
|
98 |
try {
|
99 |
// Call API to start evaluation
|
100 |
+
const response = await fetch(
|
101 |
+
`${API_CONFIG.BASE_URL}/evaluate-benchmark`,
|
102 |
+
{
|
103 |
+
method: "POST",
|
104 |
+
headers: {
|
105 |
+
"Content-Type": "application/json",
|
106 |
+
},
|
107 |
+
body: JSON.stringify({
|
108 |
+
session_id: sessionId,
|
109 |
+
}),
|
110 |
+
}
|
111 |
+
);
|
112 |
|
113 |
const result = await response.json();
|
114 |
|
|
|
117 |
pollingIntervalRef.current = setInterval(async () => {
|
118 |
try {
|
119 |
const logsResponse = await fetch(
|
120 |
+
`${API_CONFIG.BASE_URL}/evaluation-logs/${sessionId}`
|
121 |
);
|
122 |
|
123 |
if (logsResponse.ok) {
|
frontend/src/components/BenchmarkGenerator.jsx
CHANGED
@@ -3,6 +3,8 @@ import { Box, Typography, CircularProgress, Alert, Paper } from "@mui/material";
|
|
3 |
import PlayArrowIcon from "@mui/icons-material/PlayArrow";
|
4 |
import AccessTimeIcon from "@mui/icons-material/AccessTime";
|
5 |
import LogDisplay from "./LogDisplay";
|
|
|
|
|
6 |
|
7 |
// Define all benchmark steps in sequence
|
8 |
const BENCHMARK_STEPS = [
|
@@ -172,15 +174,18 @@ const BenchmarkGenerator = ({ sessionId, onComplete }) => {
|
|
172 |
|
173 |
try {
|
174 |
// Call the API to generate the benchmark
|
175 |
-
const response = await fetch(
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
184 |
|
185 |
const result = await response.json();
|
186 |
|
@@ -192,7 +197,7 @@ const BenchmarkGenerator = ({ sessionId, onComplete }) => {
|
|
192 |
try {
|
193 |
// Call the API to get the config logs
|
194 |
const configLogsResponse = await fetch(
|
195 |
-
|
196 |
);
|
197 |
|
198 |
if (configLogsResponse.ok) {
|
@@ -237,7 +242,7 @@ const BenchmarkGenerator = ({ sessionId, onComplete }) => {
|
|
237 |
try {
|
238 |
// Call the API to get the latest benchmark logs
|
239 |
const logsResponse = await fetch(
|
240 |
-
|
241 |
);
|
242 |
|
243 |
if (logsResponse.ok) {
|
|
|
3 |
import PlayArrowIcon from "@mui/icons-material/PlayArrow";
|
4 |
import AccessTimeIcon from "@mui/icons-material/AccessTime";
|
5 |
import LogDisplay from "./LogDisplay";
|
6 |
+
import { useNavigate, useSearchParams } from "react-router-dom";
|
7 |
+
import API_CONFIG from "../config/api";
|
8 |
|
9 |
// Define all benchmark steps in sequence
|
10 |
const BENCHMARK_STEPS = [
|
|
|
174 |
|
175 |
try {
|
176 |
// Call the API to generate the benchmark
|
177 |
+
const response = await fetch(
|
178 |
+
`${API_CONFIG.BASE_URL}/generate-benchmark`,
|
179 |
+
{
|
180 |
+
method: "POST",
|
181 |
+
headers: {
|
182 |
+
"Content-Type": "application/json",
|
183 |
+
},
|
184 |
+
body: JSON.stringify({
|
185 |
+
session_id: sessionId,
|
186 |
+
}),
|
187 |
+
}
|
188 |
+
);
|
189 |
|
190 |
const result = await response.json();
|
191 |
|
|
|
197 |
try {
|
198 |
// Call the API to get the config logs
|
199 |
const configLogsResponse = await fetch(
|
200 |
+
`${API_CONFIG.BASE_URL}/config-logs/${sessionId}`
|
201 |
);
|
202 |
|
203 |
if (configLogsResponse.ok) {
|
|
|
242 |
try {
|
243 |
// Call the API to get the latest benchmark logs
|
244 |
const logsResponse = await fetch(
|
245 |
+
`${API_CONFIG.BASE_URL}/benchmark-logs/${sessionId}`
|
246 |
);
|
247 |
|
248 |
if (logsResponse.ok) {
|
frontend/src/config/api.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// API Configuration
|
2 |
+
const API_CONFIG = {
|
3 |
+
// Use the current origin in production (Hugging Face Spaces)
|
4 |
+
// Fallback to localhost in development
|
5 |
+
BASE_URL:
|
6 |
+
process.env.REACT_APP_NODE_ENV === "production"
|
7 |
+
? window.location.origin
|
8 |
+
: "http://localhost:3001",
|
9 |
+
};
|
10 |
+
|
11 |
+
export default API_CONFIG;
|
frontend/src/pages/BenchmarkDisplayPage.jsx
CHANGED
@@ -3,6 +3,7 @@ import { Box, CircularProgress } from "@mui/material";
|
|
3 |
import { useNavigate, useSearchParams, Navigate } from "react-router-dom";
|
4 |
import Intro from "../components/Intro";
|
5 |
import BenchmarkDisplay from "../components/BenchmarkDisplay";
|
|
|
6 |
|
7 |
function BenchmarkDisplayPage() {
|
8 |
const navigate = useNavigate();
|
@@ -30,7 +31,7 @@ function BenchmarkDisplayPage() {
|
|
30 |
sessionId
|
31 |
);
|
32 |
try {
|
33 |
-
const apiUrl =
|
34 |
console.log("Appel API:", apiUrl);
|
35 |
|
36 |
const response = await fetch(apiUrl);
|
|
|
3 |
import { useNavigate, useSearchParams, Navigate } from "react-router-dom";
|
4 |
import Intro from "../components/Intro";
|
5 |
import BenchmarkDisplay from "../components/BenchmarkDisplay";
|
6 |
+
import API_CONFIG from "../config/api";
|
7 |
|
8 |
function BenchmarkDisplayPage() {
|
9 |
const navigate = useNavigate();
|
|
|
31 |
sessionId
|
32 |
);
|
33 |
try {
|
34 |
+
const apiUrl = `${API_CONFIG.BASE_URL}/benchmark-questions/${sessionId}`;
|
35 |
console.log("Appel API:", apiUrl);
|
36 |
|
37 |
const response = await fetch(apiUrl);
|