File size: 3,843 Bytes
3ac937f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
"""
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()