Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,7 +63,7 @@ def process_pdf(pdf_doc):
|
|
| 63 |
return_source_documents=True
|
| 64 |
)
|
| 65 |
|
| 66 |
-
return "
|
| 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.
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|