-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradio_app.py
49 lines (37 loc) · 1.64 KB
/
gradio_app.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
47
48
49
import gradio as gr
import os
## Gradio App
def create_gr_app():
with gr.Blocks(title = "ChatPDF-GPT",
theme="default") as app:
# Gradio Block
with gr.Column():
with gr.Row():
with gr.Column(scale = 0.75):
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=600)
show_img = gr.Image(label = 'PDF Preview', tool='select', height=600)
with gr.Row():
with gr.Column(scale=0.6):
text_input = gr.Textbox(
show_label = False,
placeholder='Type in your question here!',
container=False
)
with gr.Column(scale=0.2):
submit_button = gr.Button('Send')
with gr.Column(scale = 0.2):
upload_button = gr.UploadButton("Upload your PDF", file_types=[".pdf"])
return app, api_key, change_api_key, chatbot, show_img, text_input, submit_button, upload_button
if __name__ == '__main__':
app, api_key, change_api_key, chatbot, show_img, text_input, submit_button, upload_button = create_gr_app()
app.queue()
app.launch()