Update app.py
Browse files
app.py
CHANGED
@@ -85,8 +85,14 @@ class AdvancedPdfChatbot:
|
|
85 |
def _call(self, inputs):
|
86 |
query = inputs['query']
|
87 |
chat_history = inputs.get('chat_history', [])
|
|
|
|
|
88 |
refined_query = self.refinement_chain.run({'query': query, 'chat_history': chat_history})
|
|
|
|
|
89 |
response = self.qa_chain.run({"question": refined_query, "chat_history": chat_history})
|
|
|
|
|
90 |
return {"answer": response}
|
91 |
|
92 |
def chat(self, query):
|
@@ -142,17 +148,9 @@ with gr.Blocks() as demo:
|
|
142 |
|
143 |
upload_status = gr.Textbox(label="Upload Status")
|
144 |
upload_button.click(upload_pdf, inputs=[pdf_upload], outputs=[upload_status])
|
145 |
-
|
146 |
-
path_button = gr.Button("Get PDF Path")
|
147 |
-
pdf_path_display = gr.Textbox(label="Current PDF Path")
|
148 |
-
|
149 |
chatbot_interface = gr.Chatbot()
|
150 |
-
msg = gr.Textbox(
|
151 |
-
clear = gr.Button("Clear Chat")
|
152 |
-
|
153 |
msg.submit(respond, inputs=[msg, chatbot_interface], outputs=[msg, chatbot_interface])
|
154 |
-
clear.click(clear_chatbot, outputs=[chatbot_interface])
|
155 |
-
path_button.click(get_pdf_path, outputs=[pdf_path_display])
|
156 |
|
157 |
if __name__ == "__main__":
|
158 |
demo.launch()
|
|
|
85 |
def _call(self, inputs):
|
86 |
query = inputs['query']
|
87 |
chat_history = inputs.get('chat_history', [])
|
88 |
+
|
89 |
+
# Run the refinement chain to refine the query
|
90 |
refined_query = self.refinement_chain.run({'query': query, 'chat_history': chat_history})
|
91 |
+
|
92 |
+
# Run the QA chain using the refined query and the chat history
|
93 |
response = self.qa_chain.run({"question": refined_query, "chat_history": chat_history})
|
94 |
+
|
95 |
+
# Return the answer
|
96 |
return {"answer": response}
|
97 |
|
98 |
def chat(self, query):
|
|
|
148 |
|
149 |
upload_status = gr.Textbox(label="Upload Status")
|
150 |
upload_button.click(upload_pdf, inputs=[pdf_upload], outputs=[upload_status])
|
|
|
|
|
|
|
|
|
151 |
chatbot_interface = gr.Chatbot()
|
152 |
+
msg = gr.Textbox()
|
|
|
|
|
153 |
msg.submit(respond, inputs=[msg, chatbot_interface], outputs=[msg, chatbot_interface])
|
|
|
|
|
154 |
|
155 |
if __name__ == "__main__":
|
156 |
demo.launch()
|