From 58b4b16ff6ea0e1fc8f870d113ae3416c915c9cc Mon Sep 17 00:00:00 2001 From: samzong Date: Tue, 23 Dec 2025 11:58:20 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(pages):=20dynamic?= =?UTF-8?q?ally=20build=20open=20and=20closed=20source=20points=20for=20ro?= =?UTF-8?q?uters=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: samzong --- src/pages/LeaderboardPage.tsx | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/pages/LeaderboardPage.tsx b/src/pages/LeaderboardPage.tsx index e1d6bf0..fe80e3f 100644 --- a/src/pages/LeaderboardPage.tsx +++ b/src/pages/LeaderboardPage.tsx @@ -58,24 +58,26 @@ const LeaderboardPage: React.FC = () => { const maxCompareReached = selectedCompareIds.length >= MAX_COMPARE; const [modelCardRouter, setModelCardRouter] = useState(null); - // Deferral curve data - const openSourcePoints = { - CARROT: { accuracy: 0.672, cost_per_1k: 2.060741 }, - RouterDC: { accuracy: 0.3344, cost_per_1k: 0.063751 }, - GraphRouter: { accuracy: 0.6072, cost_per_1k: 0.363695 }, - KNN: { accuracy: 0.5905, cost_per_1k: 4.266104 }, - MLP: { accuracy: 0.6191, cost_per_1k: 4.830245 }, - RouteLLM: { accuracy: 0.6224, cost_per_1k: 4.937691 }, - 'MIRT-BERT': { accuracy: 0.6731, cost_per_1k: 0.150629 }, - 'NIRT-BERT': { accuracy: 0.6159, cost_per_1k: 0.600228 }, - }; + // dynamically built from routers data + const { openSourcePoints, closedSourcePoints } = useMemo(() => { + const openSource: Record = {}; + const closedSource: Record = {}; + + routers.forEach(router => { + const point = { + accuracy: router.metrics.accuracy / 100, + cost_per_1k: router.metrics.costPer1k, + }; + + if (router.type === 'open-source') { + openSource[router.name] = point; + } else { + closedSource[router.name] = point; + } + }); - const closedSourcePoints = { - NotDiamond: { accuracy: 0.6651, cost_per_1k: 9.330411 }, - Azure: { accuracy: 0.6798, cost_per_1k: 0.619866 }, - 'GPT-5': { accuracy: 0.7428, cost_per_1k: 14.407096 }, - 'vLLM-SR': { accuracy: 0.6665, cost_per_1k: 1.61393 }, - }; + return { openSourcePoints: openSource, closedSourcePoints: closedSource }; + }, []); const filteredAndSortedRouters = useMemo(() => { const metricKeyMap = {