Xianbao QIAN
commited on
Commit
·
31ec36d
1
Parent(s):
0c2c8f3
/trend fully working
Browse files- src/pages/trend/index.tsx +28 -7
- src/utils/modelData.ts +33 -17
- src/utils/providers.ts +9 -5
src/pages/trend/index.tsx
CHANGED
@@ -77,21 +77,42 @@ const TrendPage: React.FC<TrendProps> = ({ monthlyData = [], totalData = [], det
|
|
77 |
|
78 |
// Filter total data based on content type
|
79 |
const filteredTotalData = totalData.filter(d => {
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
return
|
|
|
84 |
});
|
85 |
|
86 |
// Group data by provider
|
87 |
const providerData = Object.fromEntries(
|
88 |
Object.keys(PROVIDERS_MAP).map(provider => {
|
89 |
const providerMonthlyData = monthlyData.filter(d => {
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
93 |
return d.provider === provider && matchesContentType;
|
94 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
return [provider, providerMonthlyData || []];
|
96 |
})
|
97 |
);
|
|
|
77 |
|
78 |
// Filter total data based on content type
|
79 |
const filteredTotalData = totalData.filter(d => {
|
80 |
+
if (contentType === 'all') {
|
81 |
+
return d.isDataset === null; // Show only combined counts for 'all'
|
82 |
+
}
|
83 |
+
return (contentType === 'datasets' && d.isDataset === true) ||
|
84 |
+
(contentType === 'models' && d.isDataset === false);
|
85 |
});
|
86 |
|
87 |
// Group data by provider
|
88 |
const providerData = Object.fromEntries(
|
89 |
Object.keys(PROVIDERS_MAP).map(provider => {
|
90 |
const providerMonthlyData = monthlyData.filter(d => {
|
91 |
+
if (contentType === 'all') {
|
92 |
+
return d.provider === provider; // Show all items for the provider
|
93 |
+
}
|
94 |
+
const matchesContentType = (contentType === 'datasets' && d.isDataset === true) ||
|
95 |
+
(contentType === 'models' && d.isDataset === false);
|
96 |
return d.provider === provider && matchesContentType;
|
97 |
});
|
98 |
+
|
99 |
+
// If showing all, aggregate the counts for each month
|
100 |
+
if (contentType === 'all') {
|
101 |
+
const aggregatedData: Record<string, MonthlyActivity> = {};
|
102 |
+
providerMonthlyData.forEach(d => {
|
103 |
+
if (!aggregatedData[d.date]) {
|
104 |
+
aggregatedData[d.date] = {
|
105 |
+
date: d.date,
|
106 |
+
count: 0,
|
107 |
+
provider: d.provider,
|
108 |
+
isDataset: null
|
109 |
+
};
|
110 |
+
}
|
111 |
+
aggregatedData[d.date].count += d.count;
|
112 |
+
});
|
113 |
+
return [provider, Object.values(aggregatedData).sort((a, b) => a.date.localeCompare(b.date))];
|
114 |
+
}
|
115 |
+
|
116 |
return [provider, providerMonthlyData || []];
|
117 |
})
|
118 |
);
|
src/utils/modelData.ts
CHANGED
@@ -21,7 +21,7 @@ export interface MonthlyActivity {
|
|
21 |
date: string; // YYYY-MM format
|
22 |
count: number;
|
23 |
provider: string;
|
24 |
-
isDataset
|
25 |
name?: string;
|
26 |
}
|
27 |
|
@@ -280,25 +280,41 @@ export function processDetailedModelData(models: ModelData[]): DetailedModelData
|
|
280 |
|
281 |
// Helper function to get total monthly data across all providers
|
282 |
export const getTotalMonthlyData = (monthlyData: MonthlyActivity[]): MonthlyActivity[] => {
|
283 |
-
const totalByMonth: Record<string, Record<
|
284 |
|
285 |
-
|
286 |
-
|
287 |
if (!totalByMonth[date]) {
|
288 |
-
totalByMonth[date] = {};
|
289 |
-
}
|
290 |
-
if (!totalByMonth[date][type]) {
|
291 |
-
totalByMonth[date][type] = {
|
292 |
-
date,
|
293 |
-
count: 0,
|
294 |
-
provider: 'Total',
|
295 |
-
isDataset: isDataset
|
296 |
-
};
|
297 |
}
|
298 |
-
totalByMonth[date][type].count += count;
|
299 |
});
|
300 |
|
301 |
-
|
302 |
-
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
};
|
|
|
21 |
date: string; // YYYY-MM format
|
22 |
count: number;
|
23 |
provider: string;
|
24 |
+
isDataset: boolean | null; // null means it includes both
|
25 |
name?: string;
|
26 |
}
|
27 |
|
|
|
280 |
|
281 |
// Helper function to get total monthly data across all providers
|
282 |
export const getTotalMonthlyData = (monthlyData: MonthlyActivity[]): MonthlyActivity[] => {
|
283 |
+
const totalByMonth: Record<string, Record<'model' | 'dataset' | 'all', number>> = {};
|
284 |
|
285 |
+
// Initialize the structure
|
286 |
+
monthlyData.forEach(({ date }) => {
|
287 |
if (!totalByMonth[date]) {
|
288 |
+
totalByMonth[date] = { model: 0, dataset: 0, all: 0 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
}
|
|
|
290 |
});
|
291 |
|
292 |
+
// Aggregate counts by month and type
|
293 |
+
monthlyData.forEach(({ date, count, isDataset }) => {
|
294 |
+
const type = isDataset ? 'dataset' : 'model';
|
295 |
+
totalByMonth[date][type] += count;
|
296 |
+
totalByMonth[date].all += count; // Track combined count
|
297 |
+
});
|
298 |
+
|
299 |
+
// Convert to MonthlyActivity array
|
300 |
+
return Object.entries(totalByMonth).flatMap(([date, counts]) => [
|
301 |
+
{
|
302 |
+
date,
|
303 |
+
count: counts.all,
|
304 |
+
provider: 'Total',
|
305 |
+
isDataset: null // null means it includes both
|
306 |
+
},
|
307 |
+
{
|
308 |
+
date,
|
309 |
+
count: counts.model,
|
310 |
+
provider: 'Total',
|
311 |
+
isDataset: false
|
312 |
+
},
|
313 |
+
{
|
314 |
+
date,
|
315 |
+
count: counts.dataset,
|
316 |
+
provider: 'Total',
|
317 |
+
isDataset: true
|
318 |
+
}
|
319 |
+
]).sort((a, b) => a.date.localeCompare(b.date));
|
320 |
};
|
src/utils/providers.ts
CHANGED
@@ -7,9 +7,13 @@ export const PROVIDERS_MAP: Record<string, ProviderInfo> = {
|
|
7 |
"BAAI": { color: "#FF7000", authors: ["BAAI"] },
|
8 |
"DeepSeek": { color: "#1877F2", authors: ["deepseek-ai"] },
|
9 |
"Shanghai AI Lab": { color: "#10A37F", authors: ["internlm", "OpenGVLab", "openmmlab", "Vchitect"] },
|
10 |
-
"Alibaba": { color: "#
|
11 |
-
"ZhipuAI / GLM": { color: "#
|
12 |
-
"Tencent": { color: "#
|
13 |
-
"Yi/01": { color: "#
|
14 |
-
"
|
|
|
|
|
|
|
|
|
15 |
};
|
|
|
7 |
"BAAI": { color: "#FF7000", authors: ["BAAI"] },
|
8 |
"DeepSeek": { color: "#1877F2", authors: ["deepseek-ai"] },
|
9 |
"Shanghai AI Lab": { color: "#10A37F", authors: ["internlm", "OpenGVLab", "openmmlab", "Vchitect"] },
|
10 |
+
"Alibaba": { color: "#FF9F1C", authors: ["Qwen", "Alibaba-NLP", "alibaba-pai", "DAMO-NLP-SG", 'ali-vilab', 'modelscope', 'FunAudioLLM'] },
|
11 |
+
"ZhipuAI / GLM": { color: "#E84855", authors: ["THUDM", "ZhipuAI"] },
|
12 |
+
"Tencent": { color: "#2AB7CA", authors: ["Tencent", "TencentARC"] },
|
13 |
+
"Yi/01": { color: "#FED766", authors: ["01-ai"] },
|
14 |
+
"m-a-p": { color: "#4F6D7A", authors: ["m-a-p"] },
|
15 |
+
"Skywork": { color: "#50514F", authors: ["Skywork"] },
|
16 |
+
"xverse": { color: "#F25F5C", authors: ["xverse"] },
|
17 |
+
"OpenBMB": { color: "#70C1B3", authors: ["openbmb"] },
|
18 |
+
"Baichuan": { color: "#247BA0", authors: ["baichuan-inc"] }
|
19 |
};
|