innofacisteven commited on
Commit
d8d0501
·
verified ·
1 Parent(s): 6263152

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +6 -1
rag.py CHANGED
@@ -1,5 +1,5 @@
1
  import os
2
- import shutil
3
  from llama_index.core import (
4
  VectorStoreIndex,
5
  SimpleDirectoryReader,
@@ -60,6 +60,11 @@ def add_document(file_path: str):
60
 
61
  # Move the uploaded file to the persistent data folder
62
  dest = os.path.join(DATA_DIR, os.path.basename(file_path))
 
 
 
 
 
63
  shutil.move(file_path, dest)
64
 
65
  # Reload all documents and rebuild index
 
1
  import os
2
+ import shutil # <-- Added this missing import
3
  from llama_index.core import (
4
  VectorStoreIndex,
5
  SimpleDirectoryReader,
 
60
 
61
  # Move the uploaded file to the persistent data folder
62
  dest = os.path.join(DATA_DIR, os.path.basename(file_path))
63
+
64
+ # Ensure the destination doesn't exist or handle it (shutil.move requires this)
65
+ if os.path.exists(dest):
66
+ os.remove(dest)
67
+
68
  shutil.move(file_path, dest)
69
 
70
  # Reload all documents and rebuild index