NavyDevilDoc commited on
Commit
99043ee
·
verified ·
1 Parent(s): bc373db

Update src/rag_engine.py

Browse files
Files changed (1) hide show
  1. 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
- # Quick test block
133
- if __name__ == "__main__":
134
- # Example usage
135
- print("--- Testing Rag Engine ---")
136
- # You can point this to a dummy file to test
137
- # docs = process_file("test_data/navy_manual.pdf", chunking_strategy="paragraph")
138
- # print(f"Loaded {len(docs)} chunks.")
 
 
 
 
 
 
 
 
 
 
 
 
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