Jaita commited on
Commit
511b5ff
·
verified ·
1 Parent(s): 58264f5

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -1
main.py CHANGED
@@ -42,7 +42,13 @@ class ChatInput(BaseModel):
42
  @app.on_event("startup")
43
  def startup_ingest():
44
  try:
45
- ingest_documents()
 
 
 
 
 
 
46
  except Exception as e:
47
  print(f"KB ingestion failed: {e}")
48
 
 
42
  @app.on_event("startup")
43
  def startup_ingest():
44
  try:
45
+ folder_path = os.path.join(os.getcwd(), "documents")
46
+ if collection.count() == 0:
47
+ print("🔍 KB empty. Running ingestion...")
48
+ ingest_documents(folder_path)
49
+ else:
50
+ print(f"✅ KB already populated with {collection.count()} entries. Skipping ingestion.")
51
+
52
  except Exception as e:
53
  print(f"KB ingestion failed: {e}")
54