Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Entry point para HuggingFace Spaces. | |
| Roda ingest automaticamente na primeira inicializacao se o indice estiver vazio. | |
| """ | |
| import sys | |
| import subprocess | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| # Auto-ingestao se indice vazio | |
| from src.labdaps.retrieval.vector_store import collection_count | |
| if collection_count() == 0: | |
| print("[INFO] Indice vazio - iniciando ingestao automatica...") | |
| subprocess.run([sys.executable, str(Path(__file__).parent / "ingest.py")], check=True) | |
| # Import direto: __file__ fica definido corretamente e o launch nao roda (esta em if __name__) | |
| import app # noqa: E402 | |
| app.demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True, show_api=False) | |