Pavan178 commited on
Commit
79b3458
·
verified ·
1 Parent(s): 63c378a

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +19 -12
gradio_app.py CHANGED
@@ -88,16 +88,23 @@ def chat_function(message, history):
88
  history.append((message, response))
89
  return history
90
 
91
- demo = gr.Interface(
92
- fn=chat_function,
93
- inputs=[
94
- gr.Textbox(label="Your question"),
95
- gr.State([])
96
- ],
97
- outputs=[gr.Chatbot()],
98
- title="(PDF) Information and Inference🗞️",
99
- description="Retrieval-Augmented Generation",
100
- allow_flagging="never"
101
- )
 
 
 
 
 
 
102
 
103
- demo.launch()
 
 
88
  history.append((message, response))
89
  return history
90
 
91
+ with gr.Blocks() as demo:
92
+ gr.Markdown("# (PDF) Information and Inference🗞️")
93
+ gr.Markdown("Retrieval-Augmented Generation")
94
+
95
+ with gr.Row():
96
+ with gr.Column(scale=1):
97
+ file_output = gr.Textbox(label="Upload Status")
98
+ upload_button = gr.UploadButton("Upload PDF", file_types=[".pdf"])
99
+
100
+ with gr.Column(scale=2):
101
+ chatbot = gr.Chatbot()
102
+ msg = gr.Textbox(label="Ask me anything about the content of the PDF:")
103
+ clear = gr.Button("Clear")
104
+
105
+ upload_button.upload(process_file, upload_button, file_output)
106
+ msg.submit(chat_function, [msg, chatbot], chatbot)
107
+ clear.click(lambda: None, None, chatbot, queue=False)
108
 
109
+ if __name__ == "__main__":
110
+ demo.launch()