cryogenic22 commited on
Commit
1118663
·
verified ·
1 Parent(s): f61c1a4

Update utils/database.py

Browse files
Files changed (1) hide show
  1. utils/database.py +39 -0
utils/database.py CHANGED
@@ -255,6 +255,45 @@ def handle_document_upload(uploaded_files):
255
  if st.session_state.get('qa_system'):
256
  time.sleep(5)
257
  progress_container.empty()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
  def initialize_qa_system(vector_store):
260
  """Initialize QA system with proper chat handling."""
 
255
  if st.session_state.get('qa_system'):
256
  time.sleep(5)
257
  progress_container.empty()
258
+
259
+ def display_vector_store_info():
260
+ """Display information about the current vector store state."""
261
+ if 'vector_store' not in st.session_state:
262
+ st.info("ℹ️ No documents loaded yet.")
263
+ return
264
+
265
+ try:
266
+ # Get basic stats
267
+ test_query = vector_store.similarity_search("test", k=1)
268
+ doc_count = len(test_query)
269
+
270
+ # Create an expander for detailed info
271
+ with st.expander("📊 Knowledge Base Status"):
272
+ col1, col2 = st.columns(2)
273
+
274
+ with col1:
275
+ st.metric(
276
+ label="Documents Loaded",
277
+ value=doc_count
278
+ )
279
+
280
+ with col2:
281
+ st.metric(
282
+ label="System Status",
283
+ value="Ready" if verify_vector_store(vector_store) else "Not Ready"
284
+ )
285
+
286
+ # Display sample queries
287
+ if verify_vector_store(vector_store):
288
+ st.markdown("### 🔍 Sample Document Snippets")
289
+ sample_docs = vector_store.similarity_search("", k=3)
290
+ for i, doc in enumerate(sample_docs, 1):
291
+ with st.container():
292
+ st.markdown(f"**Snippet {i}:**")
293
+ st.text(doc.page_content[:200] + "...")
294
+
295
+ except Exception as e:
296
+ st.error(f"Error displaying vector store info: {e}")
297
 
298
  def initialize_qa_system(vector_store):
299
  """Initialize QA system with proper chat handling."""