MCPcopy Create free account
hub / github.com/AntiHub-Project/AntiHub / loadModels

Function loadModels

components/shared-pool-models.tsx:49–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48 useEffect(() => {
49 const loadModels = async () => {
50 try {
51 const data = await getSharedPoolStats();
52 // 转换为数组并按指定顺序排序
53 const modelArray = Object.entries(data.quotas_by_model).map(([name, stats]) => ({
54 name,
55 stats
56 }));
57 // 按指定顺序排序
58 const sorted = modelArray.sort((a, b) => {
59 const indexA = MODEL_ORDER.indexOf(a.name);
60 const indexB = MODEL_ORDER.indexOf(b.name);
61 // 如果模型不在列表中,放到最后
62 if (indexA === -1 && indexB === -1) return 0;
63 if (indexA === -1) return 1;
64 if (indexB === -1) return -1;
65 return indexA - indexB;
66 });
67 setModels(sorted);
68 } catch (err) {
69 setError(err instanceof Error ? err.message : '加载模型数据失败');
70 } finally {
71 setIsLoading(false);
72 }
73 };
74
75 loadModels();
76 }, []);

Callers 1

SharedPoolModelsFunction · 0.85

Calls 1

getSharedPoolStatsFunction · 0.90

Tested by

no test coverage detected