Download backend/verify_setup.py from StillWorking/sentinel-face-recognition: direct link, hf CLI and curl.
- Browser
- Download file 3.84 kB
-
https://huggingface.co/StillWorking/sentinel-face-recognition/resolve/main/backend/verify_setup.py
- Command line
-
hf download hf://StillWorking/sentinel-face-recognition/backend/verify_setup.py
-
curl -L -o verify_setup.py https://huggingface.co/StillWorking/sentinel-face-recognition/resolve/main/backend/verify_setup.py
3.84 kB
| """ | |
| Verification script for Sentinel-AI semantic search feature. | |
| Run this to verify all components are correctly configured. | |
| """ | |
| import sys | |
| from pathlib import Path | |
| def check_file(path: str, description: str) -> bool: | |
| """Check if a file exists.""" | |
| p = Path(path) | |
| if p.exists(): | |
| print(f" β {description}: {path}") | |
| return True | |
| else: | |
| print(f" β {description} NOT FOUND: {path}") | |
| return False | |
| def check_env_var(var_name: str, description: str) -> bool: | |
| """Check if an environment variable is set.""" | |
| import os | |
| value = os.getenv(var_name) | |
| if value: | |
| # Mask API keys for security | |
| if "KEY" in var_name or "SECRET" in var_name: | |
| display = value[:10] + "..." if len(value) > 10 else "***" | |
| else: | |
| display = value | |
| print(f" β {description}: {display}") | |
| return True | |
| else: | |
| print(f" β {description} NOT SET") | |
| return False | |
| def main(): | |
| print("=" * 70) | |
| print("SENTINEL-AI SEMANTIC SEARCH VERIFICATION") | |
| print("=" * 70) | |
| all_checks_passed = True | |
| # Check backend files | |
| print("\nπ Backend Files:") | |
| all_checks_passed &= check_file("api/routes/search.py", "Search router") | |
| all_checks_passed &= check_file("core/gemini_agent.py", "Gemini agent") | |
| all_checks_passed &= check_file("core/faiss_store.py", "FAISS store") | |
| all_checks_passed &= check_file("api/schemas.py", "API schemas") | |
| all_checks_passed &= check_file("main.py", "Main entry point") | |
| # Check index artifacts | |
| print("\nπΎ Index Artifacts:") | |
| all_checks_passed &= check_file("index_artifacts/celeb_index.faiss", "FAISS index") | |
| all_checks_passed &= check_file("index_artifacts/metadata.json", "Metadata file") | |
| # Check environment | |
| print("\nπ§ Environment Configuration:") | |
| from dotenv import load_dotenv | |
| load_dotenv("../.env") | |
| all_checks_passed &= check_env_var("GOOGLE_API_KEY", "Gemini API key") | |
| all_checks_passed &= check_env_var("GEMINI_MODEL", "Gemini model") | |
| # Test imports | |
| print("\nπ¦ Python Imports:") | |
| try: | |
| from api.routes.search import router | |
| print(" β Search router imports successfully") | |
| except Exception as e: | |
| print(f" β Search router import failed: {e}") | |
| all_checks_passed = False | |
| try: | |
| from core.gemini_agent import extract_attributes_from_query | |
| print(" β Gemini agent imports successfully") | |
| except Exception as e: | |
| print(f" β Gemini agent import failed: {e}") | |
| all_checks_passed = False | |
| try: | |
| from core.faiss_store import search_by_attributes | |
| print(" β FAISS store imports successfully") | |
| except Exception as e: | |
| print(f" β FAISS store import failed: {e}") | |
| all_checks_passed = False | |
| # Check cascadeflow | |
| print("\nπ‘οΈ Cascadeflow:") | |
| try: | |
| import cascadeflow | |
| print(f" β Cascadeflow version: {cascadeflow.__version__}") | |
| except Exception as e: | |
| print(f" β Cascadeflow not available: {e}") | |
| all_checks_passed = False | |
| # Final summary | |
| print("\n" + "=" * 70) | |
| if all_checks_passed: | |
| print("β ALL CHECKS PASSED - System ready for semantic search!") | |
| print("\nStart the backend with:") | |
| print(" python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload") | |
| print("\nThen test the endpoint:") | |
| print(' curl -X POST http://localhost:8000/api/v1/semantic-search \\') | |
| print(' -H "Content-Type: application/json" \\') | |
| print(' -d \'{"query": "smiling woman with blond hair", "top_k": 5}\'') | |
| else: | |
| print("β SOME CHECKS FAILED - Review errors above") | |
| sys.exit(1) | |
| print("=" * 70) | |
| if __name__ == "__main__": | |
| main() | |