kidwaiaun commited on
Commit
200cb19
·
verified ·
1 Parent(s): ab30a7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
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
- doc_gui = gr.Interface(
72
- fn=process_pdf,
73
- inputs=gr.File(label="Upload PDF"),
74
- outputs=gr.Textbox(label="Processing Status"),
75
- title="Upload and Process PDF"
76
- )
77
-
78
- chat_gui = gr.Interface(
79
- fn=chat_with_pdf,
80
- inputs=gr.Textbox(label="Ask a Question"),
81
- outputs=gr.Textbox(label="Chatbot Response"),
82
- title="Chat with PDF",
83
- description="Ask questions based on the uploaded PDF. The chatbot will strictly use the document's context and rephrase the answer."
84
- )
 
 
85
 
86
  if __name__ == "__main__":
87
- gr.TabbedInterface([doc_gui, chat_gui], ["Upload PDF", "Chat with PDF"]).launch()
 
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()