0xharib commited on
Commit
722a291
·
1 Parent(s): 0f3e57f

Moving to tabs

Browse files
Files changed (1) hide show
  1. app.py +18 -11
app.py CHANGED
@@ -1,18 +1,25 @@
1
  import gradio as gr
2
 
 
 
3
 
4
- def process(choice,textFile,webLink):
5
- if choice == 'File':
6
- return 'File'
7
- else:
8
- return 'Weblink'
9
 
10
  with gr.Blocks() as demo:
11
- textFile = gr.File(file_count="multiple",file_types=["text"],label="Upload File")
12
- webLink = gr.Textbox(label="Enter URL")
13
- choice = gr.Radio(["File","Weblink"], label="Select source", info="Source is used to derive context")
14
- submitBtn = gr.Button("Submit")
15
- output = gr.Textbox(label="Response:")
16
- submitBtn.click(fn=process, inputs=[choice,textFile,webLink],outputs=output)
 
 
 
 
 
 
 
 
17
 
18
  demo.launch()
 
1
  import gradio as gr
2
 
3
+ def urlProcess(webLink):
4
+ return 'Weblink'
5
 
6
+ def uploadProcess(upload):
7
+ return 'File'
 
 
 
8
 
9
  with gr.Blocks() as demo:
10
+ gr.Markdown("Upload a text file or provide a URL")
11
+ with gr.Tab("URL")
12
+ with gr.Row()
13
+ url = gr.Textbox()
14
+ urlOutput = gr.Textbox()
15
+ urlButton = gr.Button("Submit")
16
+ with gr.Tab("Upload File")
17
+ with gr.Row()
18
+ upload = gr.File(file_count="multiple",file_types=["text"],label="Upload File")
19
+ uploadOutput = gr.Textbox()
20
+ uploadButton = gr.Button("Submit")
21
+
22
+ urlButton.click(fn=urlProcess, inputs=url,outputs=urlOutput)
23
+ uploadButton.click(fn=uploadProcess, inputs=upload,outputs=uploadOutput)
24
 
25
  demo.launch()