Manglik-R commited on
Commit
15255e8
·
verified ·
1 Parent(s): 35f1b77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -63,7 +63,7 @@ def process_pdf(pdf_doc):
63
  return_source_documents=True
64
  )
65
 
66
- return "Ready"
67
 
68
  # Function to handle user queries
69
  def query(history, text):
@@ -87,15 +87,20 @@ def pdf_changes(pdf_doc):
87
  result = process_pdf(pdf_doc)
88
  return result
89
 
90
- with gr.Interface(
91
- fn=query,
92
- inputs=[gr.Textbox(label="History", type="text", placeholder="History"),
93
- gr.Textbox(label="Question", placeholder="Type your question and hit Enter")],
94
- outputs=gr.Textbox(label="Answer", type="text", placeholder="Answer"),
95
- live=True,
96
- title="PDF Chatbot",
97
- description="Ask questions based on uploaded PDF content.",
98
- theme="compact",
99
- css=css
100
- ) as iface:
101
- iface.launch()
 
 
 
 
 
 
63
  return_source_documents=True
64
  )
65
 
66
+ return "PDF processed and ready for queries."
67
 
68
  # Function to handle user queries
69
  def query(history, text):
 
87
  result = process_pdf(pdf_doc)
88
  return result
89
 
90
+ with gr.Blocks(css=css) as iface:
91
+ with gr.Column(elem_id="col-container"):
92
+ gr.Markdown(title)
93
+ pdf_upload = gr.File(label="Upload PDF", file_types=['.pdf'])
94
+ process_button = gr.Button("Process PDF")
95
+ process_status = gr.Textbox(label="Status", interactive=False)
96
+ history = gr.State([])
97
+ with gr.Row():
98
+ chatbot = gr.Chatbot(label="PDF Chatbot")
99
+ user_input = gr.Textbox(label="Your Question", placeholder="Type your question and hit Enter")
100
+ clear_button = gr.Button("Clear History")
101
+
102
+ process_button.click(pdf_changes, inputs=pdf_upload, outputs=process_status)
103
+ user_input.submit(query, [history, user_input], [chatbot, user_input])
104
+ clear_button.click(lambda: [], None, chatbot)
105
+
106
+ iface.launch()