Update app.py
Browse files
app.py
CHANGED
|
@@ -15,10 +15,8 @@ retrieval_chain = None
|
|
| 15 |
def process_pdf(file):
|
| 16 |
global vectorstore, retrieval_chain
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
tmp.write(file.read())
|
| 21 |
-
tmp_path = tmp.name
|
| 22 |
|
| 23 |
# Load PDF
|
| 24 |
loader = PyPDFLoader(tmp_path)
|
|
@@ -32,7 +30,7 @@ def process_pdf(file):
|
|
| 32 |
embeddings = HuggingFaceEmbeddings()
|
| 33 |
vectorstore = FAISS.from_documents(docs, embeddings)
|
| 34 |
|
| 35 |
-
# Setup retrieval chain
|
| 36 |
retriever = vectorstore.as_retriever()
|
| 37 |
retriever.search_kwargs["k"] = 4
|
| 38 |
|
|
|
|
| 15 |
def process_pdf(file):
|
| 16 |
global vectorstore, retrieval_chain
|
| 17 |
|
| 18 |
+
# `file` is a gradio.NamedString → use file.name to get the path
|
| 19 |
+
tmp_path = file.name
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Load PDF
|
| 22 |
loader = PyPDFLoader(tmp_path)
|
|
|
|
| 30 |
embeddings = HuggingFaceEmbeddings()
|
| 31 |
vectorstore = FAISS.from_documents(docs, embeddings)
|
| 32 |
|
| 33 |
+
# Setup retrieval chain
|
| 34 |
retriever = vectorstore.as_retriever()
|
| 35 |
retriever.search_kwargs["k"] = 4
|
| 36 |
|