Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -42,7 +42,13 @@ class ChatInput(BaseModel):
|
|
| 42 |
@app.on_event("startup")
|
| 43 |
def startup_ingest():
|
| 44 |
try:
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|