tykiww commited on
Commit
3bd828b
·
verified ·
1 Parent(s): 950e3db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -15
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="Upload Your Own")
37
- dataset_predefined = gr.Dropdown(label="Predefined Dataset", choices=['1', '2', '3'], value='1', visible=False)
38
- dataset_upload = gr.UploadButton(label="Upload Dataset", file_types=[".pdf",".csv",".doc"], visible=True) # gr.File(label="Upload Dataset", visible=False)
 
 
 
 
 
 
39
 
 
40
 
41
- # Function to update visibility based on user choice
42
- def update_dataset_visibility(choice):
43
- if choice == "Predefined Dataset":
44
- dataset_predefined.visible = True
45
- dataset_upload.visible = False
46
- elif choice == "Upload Your Own":
47
- dataset_predefined.visible = False
48
- dataset_upload.visible = True
49
- return dataset_predefined, dataset_upload # Return both components
 
 
 
 
 
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