File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ def main():
188188 if not rag_path .is_dir ():
189189 console .print (f"[bold red]Error: RAG path is not a directory: { args .rag_dir } [/]" )
190190 sys .exit (1 )
191-
191+
192192 try :
193193 index , store = build_or_load (
194194 rag_path ,
@@ -198,6 +198,12 @@ def main():
198198 args .debug ,
199199 args .embed_batch_size ,
200200 )
201+ # If no documents found, switch to non-RAG mode
202+ if index is None :
203+ console .print (
204+ "[yellow]📄 Switching to non-RAG mode due to no documents found.[/]"
205+ )
206+ index , store = None , {}
201207 except RuntimeError as e :
202208 console .print (f"[bold red]Error: { e } [/]" )
203209 sys .exit (1 )
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ def build_or_load(
159159 rebuild : bool ,
160160 debug : bool ,
161161 batch_size : int = 32 ,
162- ) -> Tuple [Any , Dict [str , Any ]]:
162+ ) -> Tuple [Any | None , Dict [str , Any ]]:
163163 """Build or load FAISS index and document store"""
164164 # Save index files in the target directory
165165 db_path = root / "faiss_index.bin"
@@ -189,8 +189,8 @@ def build_or_load(
189189 docs = scan_docs (root )
190190
191191 if not docs :
192- console .print ("[bold red]💀 No documents found![/bold red ]" )
193- raise RuntimeError ( "No documents found" )
192+ console .print ("[bold yellow]⚠️ No documents found in directory ![/bold yellow ]" )
193+ return None , {}
194194
195195 chunks : List [str ] = []
196196 meta : List [Dict [str , str ]] = []
You can’t perform that action at this time.
0 commit comments