Update app.py
Browse files
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 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
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)
|