subashdvorak commited on
Commit
f0422e2
·
verified ·
1 Parent(s): fea8a2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -31,9 +31,11 @@ class PDFChatbot:
31
  def process_pdf(self, pdf_file):
32
  """Extract text from PDF and create FAISS index."""
33
  self.text_chunks = []
34
- doc = fitz.open(pdf_file)
35
- for page in doc:
36
- self.text_chunks.append(page.get_text("text"))
 
 
37
 
38
  # Embed the chunks
39
  embeddings = embedding_model.encode(self.text_chunks, convert_to_numpy=True)
 
31
  def process_pdf(self, pdf_file):
32
  """Extract text from PDF and create FAISS index."""
33
  self.text_chunks = []
34
+
35
+ # Read the uploaded file into memory
36
+ with fitz.open("pdf", pdf_file.read()) as doc: # Use "pdf" as format
37
+ for page in doc:
38
+ self.text_chunks.append(page.get_text("text"))
39
 
40
  # Embed the chunks
41
  embeddings = embedding_model.encode(self.text_chunks, convert_to_numpy=True)