awacke1 commited on
Commit
dc0052d
1 Parent(s): 4a09bb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -4,6 +4,17 @@ import gradio as gr
4
  import pandas as pd
5
  import json
6
 
 
 
 
 
 
 
 
 
 
 
 
7
  async def get_splits(dataset_name: str) -> Dict[str, List[Dict]]:
8
  URL = f"https://datasets-server.huggingface.co/splits?dataset={dataset_name}"
9
  async with httpx.AsyncClient() as session:
@@ -19,7 +30,7 @@ async def get_valid_datasets_old() -> Dict[str, List[str]]:
19
  # The one to watch: https://huggingface.co/rungalileo
20
  # rungalileo/medical_transcription_40
21
 
22
- async def get_valid_datasets() -> Dict[str, List[str]]:
23
  URL = f"https://datasets-server.huggingface.co/valid"
24
  async with httpx.AsyncClient() as session:
25
  response = await session.get(URL)
 
4
  import pandas as pd
5
  import json
6
 
7
+ async def get_valid_datasets() -> Dict[str, List[str]]:
8
+ URL = f"https://huggingface.co/api/datasets"
9
+ async with httpx.AsyncClient() as session:
10
+ response = await session.get(URL)
11
+ try:
12
+ datasets = [dataset["id"] for dataset in response.json()]
13
+ except (KeyError, json.JSONDecodeError):
14
+ datasets = [] # Set a default value if the response is not in the expected format
15
+ return gr.Dropdown.update(choices=datasets, value="awacke1/ChatbotMemory.csv")
16
+
17
+
18
  async def get_splits(dataset_name: str) -> Dict[str, List[Dict]]:
19
  URL = f"https://datasets-server.huggingface.co/splits?dataset={dataset_name}"
20
  async with httpx.AsyncClient() as session:
 
30
  # The one to watch: https://huggingface.co/rungalileo
31
  # rungalileo/medical_transcription_40
32
 
33
+ async def get_valid_datasets_old2() -> Dict[str, List[str]]:
34
  URL = f"https://datasets-server.huggingface.co/valid"
35
  async with httpx.AsyncClient() as session:
36
  response = await session.get(URL)