Spaces:
Sleeping
Sleeping
Update src/rag_engine.py
Browse files- src/rag_engine.py +18 -7
src/rag_engine.py
CHANGED
|
@@ -129,10 +129,21 @@ def load_documents_from_directory(
|
|
| 129 |
|
| 130 |
return all_docs
|
| 131 |
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
#
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
return all_docs
|
| 131 |
|
| 132 |
+
def list_documents(username: str = "default") -> List[str]:
|
| 133 |
+
"""
|
| 134 |
+
Lists all supported documents for a specific user.
|
| 135 |
+
Adjust 'source_documents' if your folder is named differently.
|
| 136 |
+
"""
|
| 137 |
+
# Define your source directory (Update this path if you use a different one!)
|
| 138 |
+
base_dir = "source_documents"
|
| 139 |
+
user_dir = os.path.join(base_dir, username)
|
| 140 |
+
|
| 141 |
+
if not os.path.exists(user_dir):
|
| 142 |
+
return []
|
| 143 |
+
|
| 144 |
+
files = []
|
| 145 |
+
for f in os.listdir(user_dir):
|
| 146 |
+
if f.lower().endswith(('.pdf', '.txt', '.md')):
|
| 147 |
+
files.append(f)
|
| 148 |
+
|
| 149 |
+
return files
|