Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,9 +21,7 @@ db = None
|
|
| 21 |
|
| 22 |
def process_pdf(file):
|
| 23 |
global db
|
| 24 |
-
|
| 25 |
-
tmp_file.write(file.read())
|
| 26 |
-
tmp_path = tmp_file.name
|
| 27 |
|
| 28 |
loader = PyPDFLoader(tmp_path)
|
| 29 |
documents = loader.load()
|
|
@@ -32,6 +30,7 @@ def process_pdf(file):
|
|
| 32 |
db = FAISS.from_documents(docs, embedding)
|
| 33 |
return "PDF processed successfully! You can now start asking questions."
|
| 34 |
|
|
|
|
| 35 |
def ask_question(question):
|
| 36 |
global db
|
| 37 |
if not db:
|
|
|
|
| 21 |
|
| 22 |
def process_pdf(file):
|
| 23 |
global db
|
| 24 |
+
tmp_path = file.name # directly use the file path
|
|
|
|
|
|
|
| 25 |
|
| 26 |
loader = PyPDFLoader(tmp_path)
|
| 27 |
documents = loader.load()
|
|
|
|
| 30 |
db = FAISS.from_documents(docs, embedding)
|
| 31 |
return "PDF processed successfully! You can now start asking questions."
|
| 32 |
|
| 33 |
+
|
| 34 |
def ask_question(question):
|
| 35 |
global db
|
| 36 |
if not db:
|