Caleb Fahlgren
commited on
Commit
•
d59a538
1
Parent(s):
1f7d2c6
only show main chart on mobile due to compute resources on mobile phones
Browse files- app/page.tsx +82 -71
- hooks/useIsMobile.ts +18 -0
app/page.tsx
CHANGED
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react"
|
|
4 |
import * as duckdb from "@duckdb/duckdb-wasm"
|
5 |
import { Loader2 } from "lucide-react"
|
6 |
import { toast } from 'sonner'
|
|
|
7 |
|
8 |
import { CREATE_VIEWS_QUERY, FETCH_CHART_DATA_QUERY, FETCH_DATASET_LICENSE_DATA_QUERY, FETCH_FINETUNE_MODEL_GROWTH_QUERY, FETCH_MODEL_LICENSE_DATA_QUERY, FETCH_SPACE_SDK_DATA_QUERY, FETCH_TOP_BASE_MODELS_TABLE_QUERY } from "@/lib/queries"
|
9 |
import { AreaChartStacked, ChartDataPoint } from "@/components/area-chart-stacked"
|
@@ -23,6 +24,7 @@ export default function IndexPage() {
|
|
23 |
const [finetuneModelGrowthData, setFinetuneModelGrowthData] = useState<Array<{ date: Date; count: number }>>([])
|
24 |
const [isLoading, setIsLoading] = useState(false)
|
25 |
const [topFinetunedModels, setTopFinetunedModels] = useState<Array<{ model: string; finetunes: number }> | undefined>(undefined)
|
|
|
26 |
|
27 |
useEffect(() => {
|
28 |
initDB()
|
@@ -60,9 +62,15 @@ export default function IndexPage() {
|
|
60 |
await connection.query(CREATE_VIEWS_QUERY)
|
61 |
|
62 |
setConn(connection)
|
63 |
-
await fetchChartData(connection)
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
const fetchChartData = async (connection: duckdb.AsyncDuckDBConnection) => {
|
67 |
const result = await connection.query(FETCH_CHART_DATA_QUERY)
|
68 |
|
@@ -111,6 +119,7 @@ export default function IndexPage() {
|
|
111 |
model: row.model,
|
112 |
finetunes: Number(row.finetunes)
|
113 |
})))
|
|
|
114 |
}
|
115 |
|
116 |
const handleBaseModelSubmit = async (e: React.FormEvent) => {
|
@@ -123,14 +132,11 @@ export default function IndexPage() {
|
|
123 |
|
124 |
setIsLoading(true)
|
125 |
try {
|
126 |
-
console.log("Fetching finetune model growth data for", baseModel)
|
127 |
const result = await conn.query(FETCH_FINETUNE_MODEL_GROWTH_QUERY(baseModel))
|
128 |
-
console.log("Received Result")
|
129 |
const data = result.toArray().map((row: { date: Date; count: bigint }) => ({
|
130 |
date: new Date(row.date),
|
131 |
count: parseInt(row.count.toString())
|
132 |
}))
|
133 |
-
console.log("Setting finetune model growth data", data)
|
134 |
setFinetuneModelGrowthData(data)
|
135 |
} catch (error) {
|
136 |
console.error("Error executing query:", error)
|
@@ -150,76 +156,81 @@ export default function IndexPage() {
|
|
150 |
<AreaChartStacked data={chartData} />
|
151 |
</div>
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
218 |
)}
|
219 |
-
|
|
|
220 |
<CTABanner />
|
221 |
</div>
|
222 |
</section>
|
223 |
-
|
224 |
)
|
225 |
}
|
|
|
4 |
import * as duckdb from "@duckdb/duckdb-wasm"
|
5 |
import { Loader2 } from "lucide-react"
|
6 |
import { toast } from 'sonner'
|
7 |
+
import { useIsMobile } from "@/hooks/useIsMobile"
|
8 |
|
9 |
import { CREATE_VIEWS_QUERY, FETCH_CHART_DATA_QUERY, FETCH_DATASET_LICENSE_DATA_QUERY, FETCH_FINETUNE_MODEL_GROWTH_QUERY, FETCH_MODEL_LICENSE_DATA_QUERY, FETCH_SPACE_SDK_DATA_QUERY, FETCH_TOP_BASE_MODELS_TABLE_QUERY } from "@/lib/queries"
|
10 |
import { AreaChartStacked, ChartDataPoint } from "@/components/area-chart-stacked"
|
|
|
24 |
const [finetuneModelGrowthData, setFinetuneModelGrowthData] = useState<Array<{ date: Date; count: number }>>([])
|
25 |
const [isLoading, setIsLoading] = useState(false)
|
26 |
const [topFinetunedModels, setTopFinetunedModels] = useState<Array<{ model: string; finetunes: number }> | undefined>(undefined)
|
27 |
+
const isMobile = useIsMobile()
|
28 |
|
29 |
useEffect(() => {
|
30 |
initDB()
|
|
|
62 |
await connection.query(CREATE_VIEWS_QUERY)
|
63 |
|
64 |
setConn(connection)
|
|
|
65 |
}
|
66 |
|
67 |
+
// fetch data when connection establishes and isMobile is false
|
68 |
+
useEffect(() => {
|
69 |
+
if (conn && !isMobile) {
|
70 |
+
fetchChartData(conn)
|
71 |
+
}
|
72 |
+
}, [conn, isMobile])
|
73 |
+
|
74 |
const fetchChartData = async (connection: duckdb.AsyncDuckDBConnection) => {
|
75 |
const result = await connection.query(FETCH_CHART_DATA_QUERY)
|
76 |
|
|
|
119 |
model: row.model,
|
120 |
finetunes: Number(row.finetunes)
|
121 |
})))
|
122 |
+
|
123 |
}
|
124 |
|
125 |
const handleBaseModelSubmit = async (e: React.FormEvent) => {
|
|
|
132 |
|
133 |
setIsLoading(true)
|
134 |
try {
|
|
|
135 |
const result = await conn.query(FETCH_FINETUNE_MODEL_GROWTH_QUERY(baseModel))
|
|
|
136 |
const data = result.toArray().map((row: { date: Date; count: bigint }) => ({
|
137 |
date: new Date(row.date),
|
138 |
count: parseInt(row.count.toString())
|
139 |
}))
|
|
|
140 |
setFinetuneModelGrowthData(data)
|
141 |
} catch (error) {
|
142 |
console.error("Error executing query:", error)
|
|
|
156 |
<AreaChartStacked data={chartData} />
|
157 |
</div>
|
158 |
|
159 |
+
{/* Mobile devices have much less resources to process these queries */}
|
160 |
+
|
161 |
+
{isMobile === false && (
|
162 |
+
<>
|
163 |
+
<div className="flex flex-wrap gap-8 max-w-6xl mt-10 w-full mx-auto">
|
164 |
+
<div className="flex-1 min-w-[300px]">
|
165 |
+
<CustomPieChart
|
166 |
+
title="Model Licenses"
|
167 |
+
data={modelLicenseData}
|
168 |
+
dataKey="value"
|
169 |
+
/>
|
170 |
+
</div>
|
171 |
+
<div className="flex-1 min-w-[300px]">
|
172 |
+
<CustomPieChart
|
173 |
+
title="Dataset Licenses"
|
174 |
+
data={datasetLicenseData}
|
175 |
+
dataKey="value"
|
176 |
+
/>
|
177 |
+
</div>
|
178 |
+
<div className="flex-1 min-w-[300px]">
|
179 |
+
<CustomPieChart
|
180 |
+
title="Space SDKs"
|
181 |
+
data={spaceSdkData}
|
182 |
+
dataKey="value"
|
183 |
+
/>
|
184 |
+
</div>
|
185 |
+
</div>
|
186 |
+
|
187 |
+
<div className="flex flex-col gap-4 max-w-4xl my-36 w-full mx-auto">
|
188 |
+
<h2 className="text-4xl font-bold my-10 text-center">Finetuned Model Leaderboard</h2>
|
189 |
+
<GenericTable
|
190 |
+
data={topFinetunedModels}
|
191 |
+
caption="Top 10 base models by number of finetunes"
|
192 |
+
/>
|
193 |
+
</div>
|
194 |
+
|
195 |
+
<div className="flex flex-col items-center gap-4 max-w-6xl w-full mx-auto">
|
196 |
+
<h2 className="text-4xl font-bold text-center">Finetuned Model Growth</h2>
|
197 |
+
<p className="text-center mb-4">Find how many finetuned models have been created for your favorite model</p>
|
198 |
+
<form onSubmit={handleBaseModelSubmit} className="flex flex-col gap-2 w-full max-w-sm">
|
199 |
+
<input
|
200 |
+
type="text"
|
201 |
+
value={baseModel}
|
202 |
+
onChange={(e) => setBaseModel(e.target.value.trim())}
|
203 |
+
placeholder="Base Model Name"
|
204 |
+
className="px-4 w-full py-2 border rounded"
|
205 |
+
/>
|
206 |
+
<Button type="submit" disabled={isLoading} className="w-full">
|
207 |
+
{isLoading ? (
|
208 |
+
<>
|
209 |
+
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
210 |
+
Loading
|
211 |
+
</>
|
212 |
+
) : (
|
213 |
+
"Submit"
|
214 |
+
)}
|
215 |
+
</Button>
|
216 |
+
</form>
|
217 |
+
</div>
|
218 |
+
|
219 |
+
{finetuneModelGrowthData.length > 0 && (
|
220 |
+
<div className="flex flex-col gap-4 max-w-4xl mt-10 w-full mx-auto">
|
221 |
+
<SimpleArea
|
222 |
+
title="Finetune Model Growth"
|
223 |
+
description={`Showing the growth of finetune models over time for ${baseModel || "your favorite model"}`}
|
224 |
+
data={finetuneModelGrowthData}
|
225 |
+
/>
|
226 |
+
</div>
|
227 |
+
)}
|
228 |
+
</>
|
229 |
)}
|
230 |
+
|
231 |
+
<div className="my-20 lg:my-48">
|
232 |
<CTABanner />
|
233 |
</div>
|
234 |
</section>
|
|
|
235 |
)
|
236 |
}
|
hooks/useIsMobile.ts
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useState, useEffect } from 'react';
|
2 |
+
|
3 |
+
export function useIsMobile() {
|
4 |
+
const [isMobile, setIsMobile] = useState(true);
|
5 |
+
|
6 |
+
useEffect(() => {
|
7 |
+
const checkIfMobile = () => {
|
8 |
+
setIsMobile(window.innerWidth < 768);
|
9 |
+
};
|
10 |
+
|
11 |
+
checkIfMobile();
|
12 |
+
window.addEventListener('resize', checkIfMobile);
|
13 |
+
|
14 |
+
return () => window.removeEventListener('resize', checkIfMobile);
|
15 |
+
}, []);
|
16 |
+
|
17 |
+
return isMobile;
|
18 |
+
}
|