cryogenic22 commited on
Commit
6ab15d2
·
verified ·
1 Parent(s): 2329f67

Update utils/database.py

Browse files
Files changed (1) hide show
  1. utils/database.py +16 -0
utils/database.py CHANGED
@@ -122,6 +122,22 @@ def insert_document(conn, name, content):
122
  st.error(f"Error inserting document: {e}")
123
  return None
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  def initialize_qa_system(vector_store):
127
  """Initialize QA system with proper chat handling."""
 
122
  st.error(f"Error inserting document: {e}")
123
  return None
124
 
125
+ def verify_vector_store(vector_store):
126
+ """Verify that the vector store has documents loaded.
127
+
128
+ Args:
129
+ vector_store: FAISS vector store instance
130
+
131
+ Returns:
132
+ bool: True if vector store is properly initialized with documents
133
+ """
134
+ try:
135
+ # Try to perform a simple similarity search
136
+ test_results = vector_store.similarity_search("test", k=1)
137
+ return len(test_results) > 0
138
+ except Exception as e:
139
+ st.error(f"Vector store verification failed: {e}")
140
+ return False
141
 
142
  def initialize_qa_system(vector_store):
143
  """Initialize QA system with proper chat handling."""