m-ric commited on
Commit
acea508
·
verified ·
1 Parent(s): f6dd71f

Update frontend/src/App.js

Browse files
Files changed (1) hide show
  1. frontend/src/App.js +64 -97
frontend/src/App.js CHANGED
@@ -2,54 +2,31 @@ import React, { useState, useEffect } from 'react';
2
  import { chain } from 'lodash';
3
  import './App.css';
4
 
5
- const ScoreBar = ({ score, vanillaScore, showVanilla = true }) => {
6
  if (score === undefined || score === null) return null;
7
 
8
  const percentage = score <= 1 ? score * 100 : score;
9
  const hue = Math.min(percentage * 1.2, 120); // Maps 0-100% to 0-120 (red to green)
10
  const backgroundColor = `hsl(${hue}, 80%, 50%)`;
11
 
12
- const vanillaPercentage = vanillaScore <= 1 ? vanillaScore * 100 : vanillaScore;
13
- const vanillaHue = Math.min(vanillaPercentage * 1.2, 120);
14
- const vanillaBackgroundColor = `hsl(${vanillaHue}, 80%, 50%)`;
15
-
16
  return (
17
- <div className="score-container">
18
- <div className="score-bar">
19
- <div
20
- className="score-fill"
21
- style={{
22
- width: `${percentage}%`,
23
- backgroundColor
24
- }}
25
- />
26
- <span className="score-text">
27
- {percentage.toFixed(1)}%
28
- </span>
29
- </div>
30
-
31
- {showVanilla && vanillaScore !== undefined && vanillaScore !== null && (
32
- <div className="score-bar vanilla-bar">
33
- <div
34
- className="score-fill"
35
- style={{
36
- width: `${vanillaPercentage}%`,
37
- backgroundColor: vanillaBackgroundColor
38
- }}
39
- />
40
- <span className="score-text vanilla-text">
41
- {vanillaPercentage.toFixed(1)}% <small>vanilla</small>
42
- </span>
43
- </div>
44
- )}
45
  </div>
46
  );
47
  };
48
 
49
  const App = () => {
50
- const [data, setData] = useState([]);
51
- const [vanillaData, setVanillaData] = useState([]);
52
- const [toolCallingData, setToolCallingData] = useState([]);
53
  const [loading, setLoading] = useState(true);
54
  const [error, setError] = useState(null);
55
  const [sortConfig, setSortConfig] = useState({ key: 'Average', direction: 'desc' });
@@ -62,30 +39,13 @@ const App = () => {
62
  try {
63
  setLoading(true);
64
 
65
- // Fetch code agent data (default)
66
- const codeResponse = await fetch('https://smolagents-smolagents-llm-leaderboard.hf.space/api/results');
67
- if (!codeResponse.ok) {
68
- throw new Error(`HTTP error! status: ${codeResponse.status}`);
69
- }
70
- const codeData = await codeResponse.json();
71
- setData(codeData);
72
-
73
- // Fetch vanilla data
74
- const vanillaResponse = await fetch('https://smolagents-smolagents-llm-leaderboard.hf.space/api/results?agent_action_type=vanilla');
75
- if (!vanillaResponse.ok) {
76
- throw new Error(`HTTP error! status: ${vanillaResponse.status}`);
77
  }
78
- const vanillaJsonData = await vanillaResponse.json();
79
- setVanillaData(vanillaJsonData);
80
-
81
- // Fetch tool-calling data
82
- const toolCallingResponse = await fetch('https://smolagents-smolagents-llm-leaderboard.hf.space/api/results?agent_action_type=tool-calling');
83
- if (!toolCallingResponse.ok) {
84
- throw new Error(`HTTP error! status: ${toolCallingResponse.status}`);
85
- }
86
- const toolCallingJsonData = await toolCallingResponse.json();
87
- setToolCallingData(toolCallingJsonData);
88
-
89
  } catch (err) {
90
  console.error('Error fetching data:', err);
91
  setError(err.message);
@@ -93,6 +53,7 @@ const App = () => {
93
  setLoading(false);
94
  }
95
  };
 
96
  fetchData();
97
  }, []);
98
 
@@ -101,21 +62,21 @@ const App = () => {
101
  setSortConfig({ key, direction });
102
  };
103
 
104
- // Get active dataset based on user selection
105
- const getActiveData = () => {
106
- if (showToolCalling) {
107
- return toolCallingData;
108
- }
109
- return data; // Default to code agent data
110
  };
111
 
112
- // Find vanilla score for a model
113
  const getVanillaScore = (modelId, metric) => {
114
- const vanillaModel = vanillaData.find(item => item.model_id === modelId);
115
- return vanillaModel?.scores[metric];
 
 
116
  };
117
 
118
- const filteredAndSortedData = chain(getActiveData())
119
  .filter(item => item.model_id.toLowerCase().includes(searchQuery.toLowerCase()))
120
  .orderBy(
121
  [item => {
@@ -139,8 +100,8 @@ const App = () => {
139
  <p className="subtitle">Uses <a target="_blank" href="https://github.com/huggingface/smolagents">smolagents</a> with <a target="_blank" href="https://huggingface.co/datasets/smolagents/benchmark-v1">smolagents benchmark</a>.</p>
140
  </div>
141
 
142
- <div className="filters-container">
143
- <div className="search-container">
144
  <input
145
  type="text"
146
  className="search-input"
@@ -148,26 +109,26 @@ const App = () => {
148
  value={searchQuery}
149
  onChange={(e) => setSearchQuery(e.target.value)}
150
  />
151
- </div>
152
-
153
- <div className="options-container">
154
- <label className="option-label">
155
- <input
156
- type="checkbox"
157
- checked={showVanilla}
158
- onChange={() => setShowVanilla(!showVanilla)}
159
- />
160
- Show Vanilla Scores
161
- </label>
162
 
163
- <label className="option-label">
164
- <input
165
- type="checkbox"
166
- checked={showToolCalling}
167
- onChange={() => setShowToolCalling(!showToolCalling)}
168
- />
169
- Show Tool-Calling Scores
170
- </label>
 
 
 
 
 
 
 
 
 
 
 
171
  </div>
172
  </div>
173
 
@@ -192,14 +153,20 @@ const App = () => {
192
  <tbody>
193
  {filteredAndSortedData.map((item, index) => (
194
  <tr key={index}>
195
- <td className="model-name">{item.model_id}</td>
 
 
 
 
 
 
 
196
  {["Average", "GAIA", "MATH", "SimpleQA"].map(metric => (
197
  <td key={metric}>
198
- <ScoreBar
199
- score={item.scores[metric]}
200
- vanillaScore={getVanillaScore(item.model_id, metric)}
201
- showVanilla={showVanilla}
202
- />
203
  </td>
204
  ))}
205
  </tr>
@@ -209,7 +176,7 @@ const App = () => {
209
  </div>
210
 
211
  <div className="legend">
212
- <p><strong>Agent types:</strong> {showToolCalling ? 'Tool-Calling' : 'Code'}{showVanilla ? ' (with Vanilla comparison)' : ''}</p>
213
  </div>
214
  </div>
215
  );
 
2
  import { chain } from 'lodash';
3
  import './App.css';
4
 
5
+ const ScoreBar = ({ score }) => {
6
  if (score === undefined || score === null) return null;
7
 
8
  const percentage = score <= 1 ? score * 100 : score;
9
  const hue = Math.min(percentage * 1.2, 120); // Maps 0-100% to 0-120 (red to green)
10
  const backgroundColor = `hsl(${hue}, 80%, 50%)`;
11
 
 
 
 
 
12
  return (
13
+ <div className="score-bar">
14
+ <div
15
+ className="score-fill"
16
+ style={{
17
+ width: `${percentage}%`,
18
+ backgroundColor
19
+ }}
20
+ />
21
+ <span className="score-text">
22
+ {percentage.toFixed(1)}%
23
+ </span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  </div>
25
  );
26
  };
27
 
28
  const App = () => {
29
+ const [allData, setAllData] = useState([]);
 
 
30
  const [loading, setLoading] = useState(true);
31
  const [error, setError] = useState(null);
32
  const [sortConfig, setSortConfig] = useState({ key: 'Average', direction: 'desc' });
 
39
  try {
40
  setLoading(true);
41
 
42
+ // Fetch all data from API
43
+ const response = await fetch('https://smolagents-smolagents-llm-leaderboard.hf.space/api/results');
44
+ if (!response.ok) {
45
+ throw new Error(`HTTP error! status: ${response.status}`);
 
 
 
 
 
 
 
 
46
  }
47
+ const jsonData = await response.json();
48
+ setAllData(jsonData);
 
 
 
 
 
 
 
 
 
49
  } catch (err) {
50
  console.error('Error fetching data:', err);
51
  setError(err.message);
 
53
  setLoading(false);
54
  }
55
  };
56
+
57
  fetchData();
58
  }, []);
59
 
 
62
  setSortConfig({ key, direction });
63
  };
64
 
65
+ // Filter data based on selected action type
66
+ const getFilteredData = () => {
67
+ const actionType = showToolCalling ? 'tool-calling' : 'code';
68
+ return allData.filter(item => item.source === actionType);
 
 
69
  };
70
 
71
+ // Get vanilla score for a model
72
  const getVanillaScore = (modelId, metric) => {
73
+ const vanillaEntry = allData.find(item =>
74
+ item.model_id === modelId && item.source === 'vanilla'
75
+ );
76
+ return vanillaEntry?.scores[metric];
77
  };
78
 
79
+ const filteredAndSortedData = chain(getFilteredData())
80
  .filter(item => item.model_id.toLowerCase().includes(searchQuery.toLowerCase()))
81
  .orderBy(
82
  [item => {
 
100
  <p className="subtitle">Uses <a target="_blank" href="https://github.com/huggingface/smolagents">smolagents</a> with <a target="_blank" href="https://huggingface.co/datasets/smolagents/benchmark-v1">smolagents benchmark</a>.</p>
101
  </div>
102
 
103
+ <div className="search-container">
104
+ <div className="search-with-options">
105
  <input
106
  type="text"
107
  className="search-input"
 
109
  value={searchQuery}
110
  onChange={(e) => setSearchQuery(e.target.value)}
111
  />
 
 
 
 
 
 
 
 
 
 
 
112
 
113
+ <div className="options-container">
114
+ <label className="option-label">
115
+ <input
116
+ type="checkbox"
117
+ checked={showVanilla}
118
+ onChange={() => setShowVanilla(!showVanilla)}
119
+ />
120
+ Show Vanilla Scores
121
+ </label>
122
+
123
+ <label className="option-label">
124
+ <input
125
+ type="checkbox"
126
+ checked={showToolCalling}
127
+ onChange={() => setShowToolCalling(!showToolCalling)}
128
+ />
129
+ Show Tool-Calling Scores
130
+ </label>
131
+ </div>
132
  </div>
133
  </div>
134
 
 
153
  <tbody>
154
  {filteredAndSortedData.map((item, index) => (
155
  <tr key={index}>
156
+ <td className="model-cell">
157
+ <div className="model-name">{item.model_id}</div>
158
+ {showVanilla && (
159
+ <div className="vanilla-name">
160
+ {`vanilla: ${getVanillaScore(item.model_id, 'Average')?.toFixed(1) || 'N/A'}%`}
161
+ </div>
162
+ )}
163
+ </td>
164
  {["Average", "GAIA", "MATH", "SimpleQA"].map(metric => (
165
  <td key={metric}>
166
+ <ScoreBar score={item.scores[metric]} />
167
+ {showVanilla && getVanillaScore(item.model_id, metric) !== undefined && (
168
+ <ScoreBar score={getVanillaScore(item.model_id, metric)} />
169
+ )}
 
170
  </td>
171
  ))}
172
  </tr>
 
176
  </div>
177
 
178
  <div className="legend">
179
+ <p><strong>Agent type:</strong> {showToolCalling ? 'Tool-Calling' : 'Code'}{showVanilla ? ' (with Vanilla comparison)' : ''}</p>
180
  </div>
181
  </div>
182
  );