Commit
·
94135f6
1
Parent(s):
73caaf7
fix loading on mobile
Browse files- app/page.tsx +45 -57
app/page.tsx
CHANGED
|
@@ -22,7 +22,6 @@ export default function IndexPage() {
|
|
| 22 |
const [spaceSdkData, setSpaceSdkData] = useState<Array<{ name: string; value: number; fill: string }>>([])
|
| 23 |
const [baseModel, setBaseModel] = useState("meta-llama/Meta-Llama-3-8B")
|
| 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 |
const [chartDataError, setChartDataError] = useState<string | null>(null)
|
|
@@ -65,12 +64,11 @@ export default function IndexPage() {
|
|
| 65 |
setConn(connection)
|
| 66 |
}
|
| 67 |
|
| 68 |
-
// fetch data when connection establishes and isMobile is false
|
| 69 |
useEffect(() => {
|
| 70 |
-
if (conn
|
| 71 |
fetchChartData(conn)
|
| 72 |
}
|
| 73 |
-
}, [conn
|
| 74 |
|
| 75 |
const fetchChartData = async (connection: duckdb.AsyncDuckDBConnection) => {
|
| 76 |
try {
|
|
@@ -90,43 +88,45 @@ export default function IndexPage() {
|
|
| 90 |
setChartDataError("There was an issue with the query for the Hugging Face Hub growth chart.")
|
| 91 |
}
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
}
|
| 131 |
|
| 132 |
const handleBaseModelSubmit = async (e: React.FormEvent) => {
|
|
@@ -137,7 +137,6 @@ export default function IndexPage() {
|
|
| 137 |
return
|
| 138 |
}
|
| 139 |
|
| 140 |
-
setIsLoading(true)
|
| 141 |
try {
|
| 142 |
const result = await conn.query(FETCH_FINETUNE_MODEL_GROWTH_QUERY(baseModel))
|
| 143 |
const data = result.toArray().map((row: { date: Date; count: bigint }) => ({
|
|
@@ -148,8 +147,6 @@ export default function IndexPage() {
|
|
| 148 |
} catch (error) {
|
| 149 |
console.error("Error executing query:", error)
|
| 150 |
toast.error(`Failed to fetch data for ${baseModel}`)
|
| 151 |
-
} finally {
|
| 152 |
-
setIsLoading(false)
|
| 153 |
}
|
| 154 |
}
|
| 155 |
|
|
@@ -167,9 +164,7 @@ export default function IndexPage() {
|
|
| 167 |
)}
|
| 168 |
</div>
|
| 169 |
|
| 170 |
-
{
|
| 171 |
-
|
| 172 |
-
{isMobile === false && (
|
| 173 |
<>
|
| 174 |
<div className="flex flex-wrap gap-8 max-w-6xl mt-10 w-full mx-auto">
|
| 175 |
<div className="flex-1 min-w-[300px]">
|
|
@@ -214,15 +209,8 @@ export default function IndexPage() {
|
|
| 214 |
placeholder="Base Model Name"
|
| 215 |
className="px-4 w-full py-2 border rounded"
|
| 216 |
/>
|
| 217 |
-
<Button type="submit"
|
| 218 |
-
|
| 219 |
-
<>
|
| 220 |
-
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
| 221 |
-
Loading
|
| 222 |
-
</>
|
| 223 |
-
) : (
|
| 224 |
-
"Submit"
|
| 225 |
-
)}
|
| 226 |
</Button>
|
| 227 |
</form>
|
| 228 |
</div>
|
|
@@ -244,4 +232,4 @@ export default function IndexPage() {
|
|
| 244 |
</div>
|
| 245 |
</section>
|
| 246 |
)
|
| 247 |
-
}
|
|
|
|
| 22 |
const [spaceSdkData, setSpaceSdkData] = useState<Array<{ name: string; value: number; fill: string }>>([])
|
| 23 |
const [baseModel, setBaseModel] = useState("meta-llama/Meta-Llama-3-8B")
|
| 24 |
const [finetuneModelGrowthData, setFinetuneModelGrowthData] = useState<Array<{ date: Date; count: number }>>([])
|
|
|
|
| 25 |
const [topFinetunedModels, setTopFinetunedModels] = useState<Array<{ model: string; finetunes: number }> | undefined>(undefined)
|
| 26 |
const isMobile = useIsMobile()
|
| 27 |
const [chartDataError, setChartDataError] = useState<string | null>(null)
|
|
|
|
| 64 |
setConn(connection)
|
| 65 |
}
|
| 66 |
|
|
|
|
| 67 |
useEffect(() => {
|
| 68 |
+
if (conn) {
|
| 69 |
fetchChartData(conn)
|
| 70 |
}
|
| 71 |
+
}, [conn])
|
| 72 |
|
| 73 |
const fetchChartData = async (connection: duckdb.AsyncDuckDBConnection) => {
|
| 74 |
try {
|
|
|
|
| 88 |
setChartDataError("There was an issue with the query for the Hugging Face Hub growth chart.")
|
| 89 |
}
|
| 90 |
|
| 91 |
+
// Only fetch additional data if not on mobile
|
| 92 |
+
if (!isMobile) {
|
| 93 |
+
const [modelLicenseResult, datasetLicenseResult, spaceSdkResult, topFinetunedModelsResult] =
|
| 94 |
+
await Promise.all([
|
| 95 |
+
connection.query(FETCH_MODEL_LICENSE_DATA_QUERY),
|
| 96 |
+
connection.query(FETCH_DATASET_LICENSE_DATA_QUERY),
|
| 97 |
+
connection.query(FETCH_SPACE_SDK_DATA_QUERY),
|
| 98 |
+
connection.query(FETCH_TOP_BASE_MODELS_TABLE_QUERY),
|
| 99 |
+
])
|
| 100 |
+
|
| 101 |
+
setModelLicenseData(
|
| 102 |
+
modelLicenseResult.toArray().map((row, index) => ({
|
| 103 |
+
name: row.tag.replace("license:", ""),
|
| 104 |
+
value: Number(row.count),
|
| 105 |
+
fill: `hsl(${index * 30}, 70%, 50%)`,
|
| 106 |
+
}))
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
setDatasetLicenseData(
|
| 110 |
+
datasetLicenseResult.toArray().map((row, index) => ({
|
| 111 |
+
name: row.tag.replace("license:", ""),
|
| 112 |
+
value: Number(row.count),
|
| 113 |
+
fill: `hsl(${index * 30}, 70%, 50%)`,
|
| 114 |
+
}))
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
setSpaceSdkData(
|
| 118 |
+
spaceSdkResult.toArray().map((row, index) => ({
|
| 119 |
+
name: row.sdk,
|
| 120 |
+
value: Number(row.count),
|
| 121 |
+
fill: `hsl(${index * 30}, 70%, 50%)`,
|
| 122 |
+
}))
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
setTopFinetunedModels(topFinetunedModelsResult.toArray().map(row => ({
|
| 126 |
+
model: row.model,
|
| 127 |
+
finetunes: Number(row.finetunes)
|
| 128 |
+
})))
|
| 129 |
+
}
|
| 130 |
}
|
| 131 |
|
| 132 |
const handleBaseModelSubmit = async (e: React.FormEvent) => {
|
|
|
|
| 137 |
return
|
| 138 |
}
|
| 139 |
|
|
|
|
| 140 |
try {
|
| 141 |
const result = await conn.query(FETCH_FINETUNE_MODEL_GROWTH_QUERY(baseModel))
|
| 142 |
const data = result.toArray().map((row: { date: Date; count: bigint }) => ({
|
|
|
|
| 147 |
} catch (error) {
|
| 148 |
console.error("Error executing query:", error)
|
| 149 |
toast.error(`Failed to fetch data for ${baseModel}`)
|
|
|
|
|
|
|
| 150 |
}
|
| 151 |
}
|
| 152 |
|
|
|
|
| 164 |
)}
|
| 165 |
</div>
|
| 166 |
|
| 167 |
+
{!isMobile && (
|
|
|
|
|
|
|
| 168 |
<>
|
| 169 |
<div className="flex flex-wrap gap-8 max-w-6xl mt-10 w-full mx-auto">
|
| 170 |
<div className="flex-1 min-w-[300px]">
|
|
|
|
| 209 |
placeholder="Base Model Name"
|
| 210 |
className="px-4 w-full py-2 border rounded"
|
| 211 |
/>
|
| 212 |
+
<Button type="submit" className="w-full">
|
| 213 |
+
Submit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
</Button>
|
| 215 |
</form>
|
| 216 |
</div>
|
|
|
|
| 232 |
</div>
|
| 233 |
</section>
|
| 234 |
)
|
| 235 |
+
}
|