Chandranshu Jain commited on
Commit
7a9dcc4
1 Parent(s): 91044c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -32,12 +32,13 @@ Follow these simple steps to interact with the chatbot:
32
  # docs = loader.load()
33
  # return docs
34
 
35
- def get_pdf(pdf_file):
36
- if pdf_file:
37
- temp_dir = tempfile.mkdtemp()
38
- path = os.path.join(temp_dir, pdf_file.name)
39
- # Extract file path from UploadedFile object
40
- loader = PyPDFLoader(path)
 
41
  docs = loader.load()
42
  return docs
43
 
 
32
  # docs = loader.load()
33
  # return docs
34
 
35
+ def get_pdf(uploaded_file):
36
+ if uploaded_file :
37
+ temp_file = "./temp.pdf"
38
+ with open(temp_file, "wb") as file:
39
+ file.write(uploaded_file.getvalue())
40
+ file_name = uploaded_file.name
41
+ loader = PyPDFLoader(temp_file)
42
  docs = loader.load()
43
  return docs
44