Spaces:
Sleeping
Sleeping
| import os | |
| import runpy | |
| import subprocess | |
| INDEX_FLAG = "data/.faiss_built" | |
| def build_index_if_needed(): | |
| if not os.path.exists(INDEX_FLAG): | |
| print("[BOOTSTRAP] FAISS index not found. Building index...") | |
| subprocess.check_call( | |
| ["python", "app/rag/build_index.py"] | |
| ) | |
| os.makedirs("data", exist_ok=True) | |
| with open(INDEX_FLAG, "w") as f: | |
| f.write("built") | |
| print("[BOOTSTRAP] FAISS index built successfully.") | |
| else: | |
| print("[BOOTSTRAP] FAISS index already exists. Skipping rebuild.") | |
| if __name__ == "__main__": | |
| build_index_if_needed() | |
| runpy.run_module("ui.app", run_name="__main__") | |