Update app.py
Browse files
app.py
CHANGED
@@ -67,21 +67,23 @@ def chat_with_pdf(user_input):
|
|
67 |
|
68 |
return f"{answer}\n\n(Cited from: {relevant_passage})"
|
69 |
|
70 |
-
# Gradio Interfaces
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
)
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
-
|
|
|
67 |
|
68 |
return f"{answer}\n\n(Cited from: {relevant_passage})"
|
69 |
|
70 |
+
# Gradio Interfaces with Chatbot UI
|
71 |
+
with gr.Blocks() as chat_ui:
|
72 |
+
gr.Markdown("# 📄 Chat with Your PDF Document 🤖")
|
73 |
+
with gr.Row():
|
74 |
+
with gr.Column(scale=2):
|
75 |
+
file_upload = gr.File(label="Upload PDF")
|
76 |
+
upload_btn = gr.Button("Process PDF")
|
77 |
+
status = gr.Textbox(label="Processing Status", interactive=False)
|
78 |
+
|
79 |
+
with gr.Row():
|
80 |
+
chatbot = gr.Chatbot()
|
81 |
+
with gr.Row():
|
82 |
+
user_input = gr.Textbox(label="Ask a Question", placeholder="Type your message here...")
|
83 |
+
send_btn = gr.Button("Send")
|
84 |
+
|
85 |
+
upload_btn.click(process_pdf, inputs=[file_upload], outputs=[status])
|
86 |
+
send_btn.click(chat_with_pdf, inputs=[user_input], outputs=[chatbot])
|
87 |
|
88 |
if __name__ == "__main__":
|
89 |
+
chat_ui.launch()
|