Upload app.py
Browse files
app.py
CHANGED
@@ -110,6 +110,9 @@ def load_pdf(files):
|
|
110 |
global vector_store
|
111 |
documents = []
|
112 |
|
|
|
|
|
|
|
113 |
# Load the PDFs
|
114 |
for file in files:
|
115 |
loader = PyPDFLoader(file.name)
|
@@ -134,13 +137,9 @@ def load_pdf(files):
|
|
134 |
if hasattr(vector_store, 'index') and hasattr(vector_store.index, 'ntotal'):
|
135 |
num_indexed_vectors = vector_store.index.ntotal
|
136 |
|
137 |
-
num_documents_in_docstore = 0
|
138 |
-
if hasattr(vector_store, 'docstore') and hasattr(vector_store.docstore, 'lc_kwargs'):
|
139 |
-
num_documents_in_docstore = len(vector_store.docstore._dict)
|
140 |
-
|
141 |
status_message = (
|
142 |
f"PDF(s) indexed successfully!\n"
|
143 |
-
f"Total chunks processed: {len(texts)}, Vectors indexed: {num_indexed_vectors}
|
144 |
)
|
145 |
|
146 |
return status_message
|
|
|
110 |
global vector_store
|
111 |
documents = []
|
112 |
|
113 |
+
if not files:
|
114 |
+
return """Choose at least one PDF file, then click the "Load and Index Documents" button."""
|
115 |
+
|
116 |
# Load the PDFs
|
117 |
for file in files:
|
118 |
loader = PyPDFLoader(file.name)
|
|
|
137 |
if hasattr(vector_store, 'index') and hasattr(vector_store.index, 'ntotal'):
|
138 |
num_indexed_vectors = vector_store.index.ntotal
|
139 |
|
|
|
|
|
|
|
|
|
140 |
status_message = (
|
141 |
f"PDF(s) indexed successfully!\n"
|
142 |
+
f"Total chunks processed: {len(texts)}, Vectors indexed: {num_indexed_vectors}.\n"
|
143 |
)
|
144 |
|
145 |
return status_message
|