""" 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()