Spaces:
Running
Running
Chandranshu Jain
commited on
Commit
•
834ae1c
1
Parent(s):
eb0ec92
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +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 |
|
14 |
st.set_page_config(page_title="Document Genie", layout="wide")
|
15 |
|
@@ -33,8 +33,11 @@ Follow these simple steps to interact with the chatbot:
|
|
33 |
# return docs
|
34 |
|
35 |
def get_pdf(pdf_file):
|
|
|
|
|
|
|
36 |
# Extract file path from UploadedFile object
|
37 |
-
loader = PyPDFLoader(
|
38 |
docs = loader.load()
|
39 |
return docs
|
40 |
|
|
|
9 |
from langchain.prompts import PromptTemplate
|
10 |
from langchain_community.document_loaders import PyPDFLoader
|
11 |
from langchain_chroma import Chroma
|
12 |
+
import tempfile
|
13 |
|
14 |
st.set_page_config(page_title="Document Genie", layout="wide")
|
15 |
|
|
|
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 |
|