reworked document adding and most of the project
This commit is contained in:
+11
-1
@@ -5,13 +5,23 @@ from pathlib import Path
|
||||
|
||||
from local_rag import LocalRAG
|
||||
|
||||
# Folder to scan for PDFs (recursively).
|
||||
DATA_ROOT = Path("/Users/Philipp/Desktop/workspace/python/gpt_publikationen/data_vs")
|
||||
|
||||
# Must match server.py so the chat loads the same index.
|
||||
VECTORSTORE_PATH = "./vectorstore"
|
||||
|
||||
# If True: delete the existing vector store folder, then index all PDFs from scratch.
|
||||
# If False: load the existing index (if any) and merge new chunks from these PDFs into it.
|
||||
CLEAR_VECTORSTORE_FIRST = True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if Path(VECTORSTORE_PATH).exists():
|
||||
if CLEAR_VECTORSTORE_FIRST and Path(VECTORSTORE_PATH).exists():
|
||||
shutil.rmtree(VECTORSTORE_PATH)
|
||||
print(f"Cleared existing vector store: {VECTORSTORE_PATH}")
|
||||
elif not CLEAR_VECTORSTORE_FIRST:
|
||||
print(f"Appending to existing vector store (if any): {VECTORSTORE_PATH}")
|
||||
|
||||
pdfs = sorted(p for p in DATA_ROOT.rglob("*") if p.suffix.lower() == ".pdf")
|
||||
print(f"Found {len(pdfs)} PDF(s) under {DATA_ROOT}")
|
||||
|
||||
Reference in New Issue
Block a user