Update app.py
Browse files
app.py
CHANGED
@@ -28,31 +28,43 @@ app.add_middleware(
|
|
28 |
|
29 |
@app.get("/api/results")
|
30 |
async def get_results():
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
# Convert to list for processing
|
35 |
-
data = dataset["train"].to_pandas()
|
36 |
-
|
37 |
-
# Process the data to group by model and calculate scores
|
38 |
-
processed_data = []
|
39 |
-
grouped = data.groupby('model_id')
|
40 |
-
|
41 |
-
for model_id, group in grouped:
|
42 |
-
model_data = {
|
43 |
-
'model_id': model_id,
|
44 |
-
'scores': {}
|
45 |
-
}
|
46 |
|
47 |
-
#
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
|
58 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
|
|
28 |
|
29 |
@app.get("/api/results")
|
30 |
async def get_results():
|
31 |
+
try:
|
32 |
+
# Load the dataset
|
33 |
+
dataset = load_dataset("smolagents-benchmark/results")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
# Convert to list for processing
|
36 |
+
data = dataset["train"].to_pandas()
|
37 |
+
|
38 |
+
# Log some info to help debug
|
39 |
+
print("Dataset loaded, shape:", data.shape)
|
40 |
+
print("Columns:", data.columns)
|
41 |
+
print("First row:", data.iloc[0])
|
42 |
+
|
43 |
+
# Process the data to group by model and calculate scores
|
44 |
+
processed_data = []
|
45 |
+
grouped = data.groupby('model_id')
|
46 |
+
|
47 |
+
for model_id, group in grouped:
|
48 |
+
model_data = {
|
49 |
+
'model_id': model_id,
|
50 |
+
'scores': {}
|
51 |
+
}
|
52 |
|
53 |
+
# Calculate scores for each source
|
54 |
+
for source in group['source'].unique():
|
55 |
+
source_data = group[group['source'] == source]
|
56 |
+
avg_acc = source_data['acc'].mean()
|
57 |
+
model_data['scores'][source] = float(avg_acc)
|
58 |
+
|
59 |
+
processed_data.append(model_data)
|
60 |
+
|
61 |
+
return processed_data
|
62 |
+
|
63 |
+
except Exception as e:
|
64 |
+
# Print the full error traceback to your logs
|
65 |
+
print("Error occurred:", str(e))
|
66 |
+
print("Traceback:", traceback.format_exc())
|
67 |
+
raise HTTPException(status_code=500, detail=str(e))
|
68 |
|
69 |
|
70 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|