Update frontend/src/App.tsx
Browse files- frontend/src/App.tsx +52 -3
frontend/src/App.tsx
CHANGED
@@ -7,7 +7,9 @@ import RadarView from './components/RadarView';
|
|
7 |
import LineTrendView from './components/LineTrendView';
|
8 |
import ComparisonTable from './components/ComparisonTable';
|
9 |
import AddModelForm from './components/AddModelForm';
|
|
|
10 |
import { ChartRow, ModelMetrics } from './types';
|
|
|
11 |
|
12 |
const colors = ['#4F46E5', '#059669', '#DC2626', '#7C3AED', '#EA580C', '#0891B2'];
|
13 |
const metrics = ['bleu','chrf','cer','wer','rouge1','rouge2','rougeL','quality_score'];
|
@@ -22,6 +24,32 @@ function App() {
|
|
22 |
const [activeTab, setActiveTab] = useState<'dashboard' | 'addModel' | 'comparison'>('dashboard');
|
23 |
const [newModelName, setNewModelName] = useState('');
|
24 |
const [isEvaluating, setIsEvaluating] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
const modelNames = data ? Object.keys(data) : [];
|
27 |
const languagePairs = data && selectedModel && data[selectedModel]
|
@@ -186,10 +214,9 @@ function App() {
|
|
186 |
newModelName={newModelName}
|
187 |
isEvaluating={isEvaluating}
|
188 |
onNameChange={setNewModelName}
|
189 |
-
onEvaluate={
|
190 |
-
// Add evaluation logic here
|
191 |
-
}}
|
192 |
/>
|
|
|
193 |
</div>
|
194 |
)}
|
195 |
{activeTab === 'comparison' && (
|
@@ -212,6 +239,28 @@ function App() {
|
|
212 |
<LineTrendView data={barChartData} selectedModels={selectedModels} comparisonMode={comparisonMode} colors={colors} />
|
213 |
</div>
|
214 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
</div>
|
216 |
</div>
|
217 |
);
|
|
|
7 |
import LineTrendView from './components/LineTrendView';
|
8 |
import ComparisonTable from './components/ComparisonTable';
|
9 |
import AddModelForm from './components/AddModelForm';
|
10 |
+
import LanguageLevelTable from './components/LanguageLevelTable';
|
11 |
import { ChartRow, ModelMetrics } from './types';
|
12 |
+
import axios from 'axios';
|
13 |
|
14 |
const colors = ['#4F46E5', '#059669', '#DC2626', '#7C3AED', '#EA580C', '#0891B2'];
|
15 |
const metrics = ['bleu','chrf','cer','wer','rouge1','rouge2','rougeL','quality_score'];
|
|
|
24 |
const [activeTab, setActiveTab] = useState<'dashboard' | 'addModel' | 'comparison'>('dashboard');
|
25 |
const [newModelName, setNewModelName] = useState('');
|
26 |
const [isEvaluating, setIsEvaluating] = useState(false);
|
27 |
+
const [evaluationError, setEvaluationError] = useState<string | null>(null);
|
28 |
+
|
29 |
+
const handleEvaluate = async () => {
|
30 |
+
if (!newModelName.trim()) {
|
31 |
+
setEvaluationError('Model name cannot be empty.');
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
setIsEvaluating(true);
|
36 |
+
setEvaluationError(null);
|
37 |
+
|
38 |
+
try {
|
39 |
+
const response = await axios.post('http://localhost:8000/evaluate', {
|
40 |
+
model_name: newModelName,
|
41 |
+
});
|
42 |
+
|
43 |
+
// Handle success
|
44 |
+
alert(`Evaluation successful! Metrics: ${JSON.stringify(response.data.metrics)}`);
|
45 |
+
setNewModelName(''); // Clear the input field
|
46 |
+
} catch (error: any) {
|
47 |
+
// Handle error
|
48 |
+
setEvaluationError(error.response?.data?.detail || 'An error occurred during evaluation.');
|
49 |
+
} finally {
|
50 |
+
setIsEvaluating(false);
|
51 |
+
}
|
52 |
+
};
|
53 |
|
54 |
const modelNames = data ? Object.keys(data) : [];
|
55 |
const languagePairs = data && selectedModel && data[selectedModel]
|
|
|
214 |
newModelName={newModelName}
|
215 |
isEvaluating={isEvaluating}
|
216 |
onNameChange={setNewModelName}
|
217 |
+
onEvaluate={handleEvaluate}
|
|
|
|
|
218 |
/>
|
219 |
+
{evaluationError && <p className="text-red-600 mt-4">{evaluationError}</p>}
|
220 |
</div>
|
221 |
)}
|
222 |
{activeTab === 'comparison' && (
|
|
|
239 |
<LineTrendView data={barChartData} selectedModels={selectedModels} comparisonMode={comparisonMode} colors={colors} />
|
240 |
</div>
|
241 |
)}
|
242 |
+
{activeTab === 'dashboard' && (
|
243 |
+
<div>
|
244 |
+
<h2 className="text-2xl font-bold mb-4">Dashboard</h2>
|
245 |
+
<LanguageLevelTable
|
246 |
+
data={data}
|
247 |
+
selectedModels={selectedModels}
|
248 |
+
metrics={metrics}
|
249 |
+
colors={colors}
|
250 |
+
/>
|
251 |
+
</div>
|
252 |
+
)}
|
253 |
+
{activeTab === 'comparison' && (
|
254 |
+
<div>
|
255 |
+
<h2 className="text-2xl font-bold mb-4">Comparison</h2>
|
256 |
+
<LanguageLevelTable
|
257 |
+
data={data}
|
258 |
+
selectedModels={selectedModels}
|
259 |
+
metrics={metrics}
|
260 |
+
colors={colors}
|
261 |
+
/>
|
262 |
+
</div>
|
263 |
+
)}
|
264 |
</div>
|
265 |
</div>
|
266 |
);
|