Chandranshu Jain commited on
Commit
67fdf41
1 Parent(s): 601d32a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -9,6 +9,7 @@ from langchain.chains.question_answering import load_qa_chain
9
  from langchain.prompts import PromptTemplate
10
  from langchain_community.document_loaders import PyPDFLoader
11
  from langchain_chroma import Chroma
 
12
 
13
  st.set_page_config(page_title="Document Genie", layout="wide")
14
 
@@ -26,8 +27,20 @@ Follow these simple steps to interact with the chatbot:
26
  2. **Ask a Question**: After processing the documents, ask any question related to the content of your uploaded documents for a precise answer.
27
  """)
28
 
29
- def get_pdf(pdf_docs):
30
- loader = PyPDFLoader(pdf_docs)
 
 
 
 
 
 
 
 
 
 
 
 
31
  docs = loader.load()
32
  return docs
33
 
 
9
  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
 
 
27
  2. **Ask a Question**: After processing the documents, ask any question related to the content of your uploaded documents for a precise answer.
28
  """)
29
 
30
+ #def get_pdf(pdf_docs):
31
+ # loader = PyPDFLoader(pdf_docs)
32
+ # docs = loader.load()
33
+ # return docs
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