nikhmr1235 commited on
Commit
886337d
·
verified ·
1 Parent(s): fb9812a

fix to handle state.db being intied properly in process_pdf function

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -54,9 +54,12 @@ class PDFChatbot:
54
  shutil.rmtree(self.state.vector_store_path)
55
  gr.Error(f"An error occurred: {str(e)}")
56
 
 
 
 
57
  def chat_with_pdf(self, message, history):
58
- if not self.state.is_db_ready():
59
- yield "Please upload a PDF first to begin the conversation."
60
  return
61
 
62
  retriever = self.state.db.as_retriever()
 
54
  shutil.rmtree(self.state.vector_store_path)
55
  gr.Error(f"An error occurred: {str(e)}")
56
 
57
+ def is_db_ready(self):
58
+ return self.state.db is not None
59
+
60
  def chat_with_pdf(self, message, history):
61
+ if not self.is_db_ready():
62
+ yield "Error: Database not ready."
63
  return
64
 
65
  retriever = self.state.db.as_retriever()