Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Run from the backend directory: | |
| cd backend && python ../scripts/ingest.py [folder] | |
| Examples: | |
| python ../scripts/ingest.py # ingest all knowledge folders | |
| python ../scripts/ingest.py company # ingest only /knowledge/company | |
| python ../scripts/ingest.py legal # ingest only /knowledge/legal | |
| """ | |
| import sys | |
| import logging | |
| from pathlib import Path | |
| # Add backend to path | |
| sys.path.insert(0, str(Path(__file__).parent.parent / "backend")) | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format="%(asctime)s | %(levelname)-8s | %(message)s", | |
| ) | |
| from app.services.ingestion_service import ingest_folder # noqa: E402 | |
| folder = sys.argv[1] if len(sys.argv) > 1 else None | |
| count, message = ingest_folder(folder) | |
| print(f"\n✓ {message}") | |
| print(f" Total chunks indexed: {count}") | |