Skip to content

Commit ca99a03

Browse files
committed
fixed issue of Knowledge base not initialized
Signed-off-by: RAWx18 <rawx18.dev@gmail.com>
1 parent bc172e5 commit ca99a03

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/mvt/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/mvt/pages/chatbot.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,24 @@
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+
3552
username = st.session_state.username
3653

3754
# -------------------------------

0 commit comments

Comments
 (0)