Update app.py
Browse files
app.py
CHANGED
@@ -106,15 +106,14 @@ pdf_chatbot = AdvancedPdfChatbot(openai_api_key)
|
|
106 |
def upload_pdf(pdf_file):
|
107 |
if pdf_file is None:
|
108 |
return "Please upload a PDF file."
|
109 |
-
file_path =
|
110 |
-
|
111 |
-
shutil.copyfileobj(pdf_file, f)
|
112 |
-
pdf_chatbot.memory.clear() # Clears past memory before loading a new file
|
113 |
pdf_chatbot.load_and_process_pdf(file_path)
|
114 |
return "PDF uploaded and processed successfully. You can now start chatting!"
|
115 |
|
116 |
|
117 |
|
|
|
118 |
def respond(message, history):
|
119 |
bot_message = pdf_chatbot.chat(message)
|
120 |
history.append((f"User: {message}", f"Bot: {bot_message}"))
|
|
|
106 |
def upload_pdf(pdf_file):
|
107 |
if pdf_file is None:
|
108 |
return "Please upload a PDF file."
|
109 |
+
file_path = pdf_file.name # This is the full path, e.g., /tmp/tmp1234.pdf
|
110 |
+
pdf_chatbot.memory.clear() # Clears chat history
|
|
|
|
|
111 |
pdf_chatbot.load_and_process_pdf(file_path)
|
112 |
return "PDF uploaded and processed successfully. You can now start chatting!"
|
113 |
|
114 |
|
115 |
|
116 |
+
|
117 |
def respond(message, history):
|
118 |
bot_message = pdf_chatbot.chat(message)
|
119 |
history.append((f"User: {message}", f"Bot: {bot_message}"))
|