-
Notifications
You must be signed in to change notification settings - Fork 9
/
user_interface.py
47 lines (35 loc) · 1.55 KB
/
user_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import gradio as gr
# Gradio application setup
def create_demo():
with gr.Blocks(title= " PDF Chatbot",
theme = "Soft" # Change the theme here
) as demo:
# Create a Gradio block
with gr.Column():
with gr.Row():
with gr.Column(scale=0.8):
api_key = gr.Textbox(
placeholder='Enter your OpenAI API key',
show_label=False,
interactive=True,
container=False)
with gr.Column(scale=0.2):
change_api_key = gr.Button('Update API Key')
with gr.Row():
chatbot = gr.Chatbot(value=[], elem_id='chatbot', height=680)
show_img = gr.Image(label='PDF Preview', tool='select', height=680)
with gr.Row():
with gr.Column(scale=0.60):
text_input = gr.Textbox(
show_label=False,
placeholder="Ask your pdf?",
container=False)
with gr.Column(scale=0.20):
submit_btn = gr.Button('Send')
with gr.Column(scale=0.20):
upload_btn = gr.UploadButton("📁 Upload PDF", file_types=[".pdf"])
return demo, api_key, change_api_key, chatbot, show_img, text_input, submit_btn, upload_btn
if __name__ == '__main__':
demo, api_key, change_api_key, chatbot, show_img, text_input, submit_btn, upload_btn = create_demo()
demo.queue()
demo.launch()