@@ -12,6 +12,9 @@ import { Button } from "../components/ui/button";
1212import { Input } from "../components/ui/input" ;
1313import "./leaderboard.css" ;
1414
15+ const leaderboardFamilies = [ "Spot" , "Perps" , "Predictions" ] as const ;
16+ type LeaderboardFamily = ( typeof leaderboardFamilies ) [ number ] ;
17+
1518type SortMetric = "passRate" | "accuracy" | "latency" | "cost" ;
1619type SortDirection = "asc" | "desc" ;
1720type ScatterMetric = "latency" | "cost" ;
@@ -257,13 +260,13 @@ function SortButton({
257260}
258261
259262export function LeaderboardPage ( {
260- initialFamily = "All tasks " ,
263+ initialFamily = "Spot " ,
261264 initialSearch = "" ,
262265} : {
263- initialFamily ?: FamilyFilter ;
266+ initialFamily ?: LeaderboardFamily ;
264267 initialSearch ?: string ;
265268} ) {
266- const [ family , setFamily ] = useState < FamilyFilter > ( initialFamily ) ;
269+ const [ family , setFamily ] = useState < LeaderboardFamily > ( initialFamily ) ;
267270 const [ search , setSearch ] = useState ( initialSearch ) ;
268271 const [ sortMetric , setSortMetric ] = useState < SortMetric > ( "passRate" ) ;
269272 const [ sortDirection , setSortDirection ] = useState < SortDirection > ( "desc" ) ;
@@ -285,21 +288,18 @@ export function LeaderboardPage({
285288 accuracy : metrics . accuracy ,
286289 } ;
287290 } ) ;
288- const measuredRows : LeaderboardRow [ ] =
289- family === "All tasks"
290- ? [ ]
291- : measuredModels
292- . filter (
293- ( model ) =>
294- model . families [ family ] !== undefined &&
295- ( query . length === 0 ||
296- `${ model . name } ${ model . provider } ` . toLocaleLowerCase ( ) . includes ( query ) ) ,
297- )
298- . map ( ( model ) => ( {
299- kind : "measured" ,
300- model,
301- result : model . families [ family ] ! ,
302- } ) ) ;
291+ const measuredRows : LeaderboardRow [ ] = measuredModels
292+ . filter (
293+ ( model ) =>
294+ model . families [ family ] !== undefined &&
295+ ( query . length === 0 ||
296+ `${ model . name } ${ model . provider } ` . toLocaleLowerCase ( ) . includes ( query ) ) ,
297+ )
298+ . map ( ( model ) => ( {
299+ kind : "measured" ,
300+ model,
301+ result : model . families [ family ] ! ,
302+ } ) ) ;
303303 const visible = [ ...illustrativeRows , ...measuredRows ] ;
304304
305305 return visible . sort ( ( left , right ) => {
@@ -345,19 +345,13 @@ export function LeaderboardPage({
345345 } ;
346346
347347 const resetFilters = ( ) => {
348- setFamily ( "All tasks " ) ;
348+ setFamily ( "Spot " ) ;
349349 setSearch ( "" ) ;
350350 } ;
351351
352- const tableCaption =
353- family === "All tasks"
354- ? `Model results across all ${ numberFormatter . format ( dataset . tasks ) } illustrative tasks.`
355- : `Model results for the ${ family } family, one of four ${ numberFormatter . format ( dataset . tasksPerFamily ) } -task families.` ;
352+ const tableCaption = `Model results for the ${ family } family, one of four ${ numberFormatter . format ( dataset . tasksPerFamily ) } -task families.` ;
356353 const displayedUniverse =
357- models . length +
358- ( family === "All tasks"
359- ? 0
360- : measuredModels . filter ( ( model ) => model . families [ family ] !== undefined ) . length ) ;
354+ models . length + measuredModels . filter ( ( model ) => model . families [ family ] !== undefined ) . length ;
361355
362356 return (
363357 < PageShell active = "leaderboard" >
@@ -422,7 +416,7 @@ export function LeaderboardPage({
422416 </ div >
423417
424418 < div className = "lb-toolbar" >
425- < FamilyTabs value = { family } onChange = { setFamily } />
419+ < FamilyTabs value = { family } onChange = { setFamily } options = { leaderboardFamilies } />
426420 < label className = "lb-search-field" >
427421 < span className = "lb-visually-hidden" > Search models</ span >
428422 < Search size = { 15 } aria-hidden = "true" />
@@ -614,11 +608,7 @@ export function LeaderboardPage({
614608 </ td >
615609 < td >
616610 { numberFormatter . format (
617- row . kind === "measured"
618- ? row . result . total
619- : family === "All tasks"
620- ? dataset . tasks
621- : dataset . tasksPerFamily ,
611+ row . kind === "measured" ? row . result . total : dataset . tasksPerFamily ,
622612 ) }
623613 </ td >
624614 </ tr >
0 commit comments