Pavan178 commited on
Commit
82e1dd9
·
verified ·
1 Parent(s): 08d8ad5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
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 = f"uploads/{pdf_file.name}"
110
- with open(file_path, "wb") as f:
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}"))