m-ric HF Staff commited on
Commit
b3d493a
·
verified ·
1 Parent(s): ba1da69

Update frontend/src/App.js

Browse files
Files changed (1) hide show
  1. frontend/src/App.js +124 -17
frontend/src/App.js CHANGED
@@ -1,23 +1,130 @@
1
- import logo from './logo.svg';
2
- import './App.css';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  function App() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  return (
6
- <div className="App">
7
- <header className="App-header">
8
- <img src={logo} className="App-logo" alt="logo" />
9
- <p>
10
- Edit <code>src/App.js</code> and save to reload.
11
- </p>
12
- <a
13
- className="App-link"
14
- href="https://reactjs.org"
15
- target="_blank"
16
- rel="noopener noreferrer"
17
- >
18
- Learn React
19
- </a>
20
- </header>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  </div>
22
  );
23
  }
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import { ArrowUpDown } from 'lucide-react';
3
+ import _ from 'lodash';
4
+
5
+ const ScoreBar = ({ score }) => {
6
+ const percentage = score <= 1 ? score * 100 : score;
7
+ const hue = Math.min(percentage * 1.2, 120); // 0 = red, 120 = green
8
+ const backgroundColor = `hsl(${hue}, 70%, 45%)`;
9
+
10
+ return (
11
+ <div className="relative h-8 bg-gray-100 rounded w-full">
12
+ <div
13
+ className="absolute top-0 left-0 h-full rounded transition-all duration-200"
14
+ style={{
15
+ width: `${percentage}%`,
16
+ backgroundColor
17
+ }}
18
+ />
19
+ <div className="absolute inset-0 flex items-center justify-end px-3">
20
+ <span className="text-sm font-medium text-white mix-blend-difference">
21
+ {percentage.toFixed(2)}%
22
+ </span>
23
+ </div>
24
+ </div>
25
+ );
26
+ };
27
 
28
  function App() {
29
+ const [data, setData] = useState([]);
30
+ const [loading, setLoading] = useState(true);
31
+ const [error, setError] = useState(null);
32
+ const [sortConfig, setSortConfig] = useState({ key: 'GAIA', direction: 'desc' });
33
+
34
+ useEffect(() => {
35
+ const fetchData = async () => {
36
+ try {
37
+ setLoading(true);
38
+ const response = await fetch('/api/results');
39
+ if (!response.ok) {
40
+ throw new Error('Failed to fetch data');
41
+ }
42
+ const jsonData = await response.json();
43
+ setData(jsonData);
44
+ } catch (err) {
45
+ console.error('Error fetching data:', err);
46
+ setError(err.message);
47
+ } finally {
48
+ setLoading(false);
49
+ }
50
+ };
51
+
52
+ fetchData();
53
+ }, []);
54
+
55
+ const handleSort = (key) => {
56
+ const direction = sortConfig.key === key && sortConfig.direction === 'desc' ? 'asc' : 'desc';
57
+ setSortConfig({ key, direction });
58
+ };
59
+
60
+ const sortedData = _.orderBy(
61
+ data,
62
+ [item => item.scores[sortConfig.key] || 0],
63
+ [sortConfig.direction]
64
+ );
65
+
66
+ if (loading) {
67
+ return (
68
+ <div className="flex items-center justify-center min-h-screen">
69
+ <div className="text-lg">Loading benchmark results...</div>
70
+ </div>
71
+ );
72
+ }
73
+
74
+ if (error) {
75
+ return (
76
+ <div className="flex items-center justify-center min-h-screen text-red-600">
77
+ Error: {error}
78
+ </div>
79
+ );
80
+ }
81
+
82
  return (
83
+ <div className="p-6">
84
+ <div className="mb-6">
85
+ <h1 className="text-2xl font-bold mb-2">Model Benchmark Results</h1>
86
+ <p className="text-gray-600">Comparing model performance across different benchmarks</p>
87
+ </div>
88
+
89
+ <div className="overflow-x-auto">
90
+ <table className="w-full border-collapse">
91
+ <thead>
92
+ <tr className="border-b border-gray-200">
93
+ <th className="py-3 text-left font-medium text-gray-700 w-1/4">Model</th>
94
+ {["GAIA", "MATH", "SimpleQA"].map(benchmark => (
95
+ <th
96
+ key={benchmark}
97
+ onClick={() => handleSort(benchmark)}
98
+ className="py-3 px-4 text-left font-medium text-gray-700 cursor-pointer hover:text-blue-600"
99
+ >
100
+ <div className="flex items-center gap-1">
101
+ {benchmark}
102
+ <ArrowUpDown className="h-4 w-4" />
103
+ </div>
104
+ </th>
105
+ ))}
106
+ </tr>
107
+ </thead>
108
+ <tbody>
109
+ {sortedData.map((item, index) => (
110
+ <tr key={index} className="border-b border-gray-100">
111
+ <td className="py-3 pr-4 font-medium truncate" title={item.model_id}>
112
+ {item.model_id}
113
+ </td>
114
+ <td className="py-3 px-4">
115
+ <ScoreBar score={item.scores.GAIA} />
116
+ </td>
117
+ <td className="py-3 px-4">
118
+ <ScoreBar score={item.scores.MATH} />
119
+ </td>
120
+ <td className="py-3 px-4">
121
+ <ScoreBar score={item.scores.SimpleQA} />
122
+ </td>
123
+ </tr>
124
+ ))}
125
+ </tbody>
126
+ </table>
127
+ </div>
128
  </div>
129
  );
130
  }