HeTalksInMaths commited on
Commit
41ec4e2
·
1 Parent(s): 90e3e68

Fix database info display when db is None

Browse files

- Handle NoneType error in get_database_info()
- Show helpful message explaining database initialization status
- Guide users to trigger retry by submitting a prompt
- Prevents 'NoneType' object has no attribute 'collection' error

Fixes the error in Database Management accordion when model download fails

Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -393,6 +393,27 @@ def expand_database(batch_size: int = 5000) -> str:
393
 
394
  def get_database_info() -> str:
395
  """Get current database statistics."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  try:
397
  current_count = db.collection.count()
398
 
 
393
 
394
  def get_database_info() -> str:
395
  """Get current database statistics."""
396
+ global db
397
+
398
+ # Check if database is initialized
399
+ if db is None:
400
+ return """### ⚠️ Database Not Initialized
401
+
402
+ **Status:** Waiting for initialization
403
+
404
+ The vector database is not yet ready. This can happen when:
405
+ 1. The embedding model is still downloading
406
+ 2. Network issues prevented model download during startup
407
+
408
+ **To initialize:**
409
+ 1. Try entering a prompt below and clicking "Analyze Difficulty"
410
+ 2. This will trigger the database initialization
411
+ 3. Wait a few moments for the model to download
412
+ 4. Then refresh this page
413
+
414
+ Or wait a few minutes and click the "🔄 Refresh Stats" button.
415
+ """
416
+
417
  try:
418
  current_count = db.collection.count()
419