m-ric commited on
Commit
047960a
·
verified ·
1 Parent(s): 22158c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -12
app.py CHANGED
@@ -26,18 +26,33 @@ app.add_middleware(
26
  )
27
 
28
 
29
- @app.get("/invert")
30
- async def invert(text: str):
31
- return {
32
- "original": text,
33
- "inverted": text[::-1],
34
- }
35
-
36
-
37
- @app.get("/data")
38
- async def get_data():
39
- data = {"data": np.random.rand(100).tolist()}
40
- return JSONResponse(data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
 
43
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
 
26
  )
27
 
28
 
29
+ @app.get("/api/results")
30
+ async def get_results():
31
+ # Load the dataset
32
+ dataset = load_dataset("smolagents-benchmark/results")
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
+ # Calculate scores for each source
48
+ for source in group['source'].unique():
49
+ source_data = group[group['source'] == source]
50
+ avg_acc = source_data['acc'].mean()
51
+ model_data['scores'][source] = float(avg_acc)
52
+
53
+ processed_data.append(model_data)
54
+
55
+ return processed_data
56
 
57
 
58
  app.mount("/", StaticFiles(directory="static", html=True), name="static")