Rahatara commited on
Commit
02a466f
1 Parent(s): b1188d8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from interface import create_demo
2
+ from pdfchatbot import PDFChatBot
3
+
4
+ # Create Gradio interface
5
+ demo, chat_history, show_img, txt, submit_button, uploaded_pdf = create_demo()
6
+
7
+ # Create PDFChatBot instance
8
+ pdf_chatbot = PDFChatBot()
9
+
10
+ # Set up event handlers
11
+ with demo:
12
+ # Event handler for uploading a PDF
13
+ uploaded_pdf.upload(pdf_chatbot.render_file, inputs=[uploaded_pdf], outputs=[show_img])
14
+
15
+ # Event handler for submitting text and generating response
16
+ submit_button.click(pdf_chatbot.add_text, inputs=[chat_history, txt], outputs=[chat_history], queue=False).\
17
+ success(pdf_chatbot.generate_response, inputs=[chat_history, txt, uploaded_pdf], outputs=[chat_history, txt]).\
18
+ success(pdf_chatbot.render_file, inputs=[uploaded_pdf], outputs=[show_img])
19
+
20
+ if __name__ == "__main__":
21
+ demo.launch()