Spaces:
Running
Running
Download scripts/ingest.py from samir12321/negoptimAi: direct link, hf CLI and curl.
- Browser
- Download file 837 Bytes
-
https://huggingface.co/spaces/samir12321/negoptimAi/resolve/main/scripts/ingest.py
- Command line
-
hf download hf://spaces/samir12321/negoptimAi/scripts/ingest.py
-
curl -L -o ingest.py https://huggingface.co/spaces/samir12321/negoptimAi/resolve/main/scripts/ingest.py
837 Bytes
| #!/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}") | |