Chandranshu Jain commited on
Commit
b7a7568
·
verified ·
1 Parent(s): 04e2965

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -10,6 +10,7 @@ from langchain.prompts import PromptTemplate
10
  from langchain_community.document_loaders import PyPDFLoader
11
  from langchain_chroma import Chroma
12
  import io
 
13
 
14
  st.set_page_config(page_title="Document Genie", layout="wide")
15
 
@@ -34,14 +35,8 @@ Follow these simple steps to interact with the chatbot:
34
 
35
  def get_pdf(pdf_file):
36
  # Extract file path from UploadedFile object
37
- file_path = pdf_file.name
38
- # Read the content of the uploaded PDF file
39
- pdf_content = pdf_file.read()
40
- # Close the file object
41
- pdf_file.close()
42
- # Load the PDF content using PyPDFLoader
43
- loader = PyPDFLoader(io.BytesIO(pdf_content))
44
- docs = loader.load()
45
  return docs
46
 
47
  def text_splitter(text):
 
10
  from langchain_community.document_loaders import PyPDFLoader
11
  from langchain_chroma import Chroma
12
  import io
13
+ import fitz
14
 
15
  st.set_page_config(page_title="Document Genie", layout="wide")
16
 
 
35
 
36
  def get_pdf(pdf_file):
37
  # Extract file path from UploadedFile object
38
+ file_pdf = fitz.open(stream=pdf_file.read(), filetype="pdf")
39
+ docs = file_pdf.load()
 
 
 
 
 
 
40
  return docs
41
 
42
  def text_splitter(text):