Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,26 +33,36 @@ with gr.Blocks() as demo:
|
|
33 |
# Prompt Input
|
34 |
name_input = gr.Textbox(label="Your Name")
|
35 |
# Dataset choice
|
36 |
-
dataset_choice = gr.Radio(label="Choose Dataset", choices=["Predefined Dataset", "Upload Your Own"], value="
|
37 |
-
dataset_predefined = gr.Dropdown(label="Predefined Dataset", choices=['1', '2', '3'], value='1', visible=
|
38 |
-
dataset_upload = gr.UploadButton(label="Upload Dataset", file_types=[".pdf",".csv",".
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
|
|
40 |
|
41 |
-
#
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
# Initial call to set visibility based on default choice
|
52 |
-
dataset_predefined, dataset_upload = update_dataset_visibility(dataset_choice.value)
|
53 |
|
54 |
# Update visibility based on user choice
|
55 |
-
dataset_choice.change(update_dataset_visibility, inputs=[dataset_choice], outputs=[dataset_predefined, dataset_upload])
|
56 |
|
57 |
##### Model Outputs #####
|
58 |
|
|
|
33 |
# Prompt Input
|
34 |
name_input = gr.Textbox(label="Your Name")
|
35 |
# Dataset choice
|
36 |
+
dataset_choice = gr.Radio(label="Choose Dataset", choices=["Predefined Dataset", "Upload Your Own"], value="Predefined Dataset")
|
37 |
+
dataset_predefined = gr.Dropdown(label="Predefined Dataset", choices=['1', '2', '3'], value='1', visible=True)
|
38 |
+
dataset_upload = gr.UploadButton(label="Upload Dataset", file_types=[".pdf",".csv",".jsonl"], visible=False) # gr.File(label="Upload Dataset", visible=False)
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
radio = gr.Radio(["show", "hide"], label="Choose")
|
44 |
+
text = gr.Textbox(label="This text only shows when 'show' is selected.", visible=False)
|
45 |
|
46 |
+
|
47 |
|
48 |
+
def update_visibility(radio): # Accept the event argument, even if not used
|
49 |
+
value = radio.value # Get the selected value from the radio button
|
50 |
+
|
51 |
+
if value == "Predefined Dataset":
|
52 |
+
predef = gr.Dropdown.update(visible=visible=bool(1))
|
53 |
+
upload = gr.UploadButton.update(visible=visible=bool(0))
|
54 |
+
elif value == "Upload Your Own":
|
55 |
+
predef = gr.Dropdown.update(visible=visible=bool(0))
|
56 |
+
upload = gr.UploadButton.update(visible=visible=bool(1))
|
57 |
+
return predef, upload # Return both components
|
58 |
+
|
59 |
+
dataset_predefined, dataset_upload = dataset_choice.change(update_visibility, dataset_choice, dataset_upload)
|
60 |
+
|
61 |
+
|
62 |
|
|
|
|
|
63 |
|
64 |
# Update visibility based on user choice
|
65 |
+
#dataset_predefined, dataset_upload = dataset_choice.change(update_dataset_visibility, inputs=[dataset_choice], outputs=[dataset_predefined, dataset_upload])
|
66 |
|
67 |
##### Model Outputs #####
|
68 |
|