Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
-
def
|
5 |
-
if not query:
|
6 |
return []
|
7 |
url = f"https://huggingface.co/api/quicksearch?q={query}&type={type}&limit=20"
|
8 |
response = requests.get(url)
|
9 |
if response.status_code == 200:
|
10 |
data = response.json()
|
11 |
print(data)
|
12 |
-
|
13 |
-
return
|
14 |
else:
|
15 |
-
return ["Error fetching
|
16 |
|
17 |
def update_dropdown(query, type, key_up_data: gr.KeyUpData):
|
18 |
-
datasets =
|
19 |
return gr.update(choices=datasets, visible=True)
|
20 |
|
21 |
-
|
22 |
-
|
23 |
with gr.Blocks() as demo:
|
24 |
model_dropdown = gr.Dropdown(label="Models Auto-Complete", choices=[""], allow_custom_value=True)
|
25 |
dataset_dropdown = gr.Dropdown(label="Datasets Auto-Complete", choices=[""], allow_custom_value=True)
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
+
def quick_search_query(query, type):
|
5 |
+
if not query:
|
6 |
return []
|
7 |
url = f"https://huggingface.co/api/quicksearch?q={query}&type={type}&limit=20"
|
8 |
response = requests.get(url)
|
9 |
if response.status_code == 200:
|
10 |
data = response.json()
|
11 |
print(data)
|
12 |
+
repo_names = [d['id'] for d in data[type]]
|
13 |
+
return repo_names
|
14 |
else:
|
15 |
+
return ["Error fetching repo"]
|
16 |
|
17 |
def update_dropdown(query, type, key_up_data: gr.KeyUpData):
|
18 |
+
datasets = quick_search_query(key_up_data.input_value, type)
|
19 |
return gr.update(choices=datasets, visible=True)
|
20 |
|
|
|
|
|
21 |
with gr.Blocks() as demo:
|
22 |
model_dropdown = gr.Dropdown(label="Models Auto-Complete", choices=[""], allow_custom_value=True)
|
23 |
dataset_dropdown = gr.Dropdown(label="Datasets Auto-Complete", choices=[""], allow_custom_value=True)
|