File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,16 @@ def get_ragchain(filter):
4343 temperature = 0.7
4444 )
4545
46+ # Check if vector database exists
47+ persist_dir = config_data ["persist_directory" ]
48+ index_path = os .path .join (persist_dir , "index.faiss" )
49+
50+ if not os .path .exists (index_path ):
51+ raise FileNotFoundError (
52+ f"Vector database not found at { index_path } . "
53+ "Please run 'python ingest.py' first to create the knowledge base."
54+ )
55+
4656 # Load local vector db
4757 docsearch = FAISS .load_local (config_data ["persist_directory" ], embeddings , allow_dangerous_deserialization = True )
4858
Original file line number Diff line number Diff line change 3131 filter = {"access" : {"$eq" : "public" }}
3232
3333
34- rag_chain = get_ragchain (filter )
34+ try :
35+ rag_chain = get_ragchain (filter )
36+ except FileNotFoundError as e :
37+ st .error ("⚠️ Knowledge base not initialized!" )
38+ st .info ("""
39+ The AI FAQ system needs to be set up first. Please:
40+
41+ 1. Add your documents/links to the Config public/private page first.
42+ 2. Then update the knowledge base from Build Knowledge Base page.
43+ 3. Then open this page again.
44+
45+ Or contact an administrator to set up the knowledge base.
46+ """ )
47+ st .stop ()
48+ except Exception as e :
49+ st .error (f"Error initializing the system: { str (e )} " )
50+ st .stop ()
51+
3552username = st .session_state .username
3653
3754# -------------------------------
You can’t perform that action at this time.
0 commit comments