Spaces:
Sleeping
Sleeping
Commit
·
3c0c362
1
Parent(s):
b7c3fee
fix info
Browse files- src/utils.ts +5 -10
src/utils.ts
CHANGED
|
@@ -15,21 +15,16 @@ export async function fetchJson<T = any>(url: URL, context: string): Promise<T>
|
|
| 15 |
}
|
| 16 |
|
| 17 |
export async function getDefaultConfigAndSplit(datasetId: string): Promise<{ config: string; split: string }> {
|
| 18 |
-
const
|
| 19 |
-
const
|
| 20 |
|
| 21 |
-
const
|
|
|
|
| 22 |
if (!firstConfig) {
|
| 23 |
throw new Error("No configs found for dataset");
|
| 24 |
}
|
| 25 |
|
| 26 |
-
const
|
| 27 |
-
dataset: datasetId,
|
| 28 |
-
config: firstConfig,
|
| 29 |
-
});
|
| 30 |
-
const infoResult = await fetchJson<any>(infoUrl, "Failed to get dataset info");
|
| 31 |
-
|
| 32 |
-
const splits = infoResult.dataset_info?.splits || {};
|
| 33 |
const firstSplit = Object.keys(splits)[0];
|
| 34 |
if (!firstSplit) {
|
| 35 |
throw new Error("No splits found for dataset");
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
export async function getDefaultConfigAndSplit(datasetId: string): Promise<{ config: string; split: string }> {
|
| 18 |
+
const infoUrl = buildUrl("https://datasets-server.huggingface.co/info", { dataset: datasetId });
|
| 19 |
+
const infoResult = await fetchJson<any>(infoUrl, "Failed to get dataset info");
|
| 20 |
|
| 21 |
+
const configs = Object.keys(infoResult.dataset_info || {});
|
| 22 |
+
const firstConfig = configs[0];
|
| 23 |
if (!firstConfig) {
|
| 24 |
throw new Error("No configs found for dataset");
|
| 25 |
}
|
| 26 |
|
| 27 |
+
const splits = infoResult.dataset_info[firstConfig]?.splits || {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
const firstSplit = Object.keys(splits)[0];
|
| 29 |
if (!firstSplit) {
|
| 30 |
throw new Error("No splits found for dataset");
|