File size: 2,983 Bytes
07ea386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
113
114
import sys
import os

print("=" * 60)
print("LEGAL RAG BACKEND - SETUP VERIFICATION")
print("=" * 60)

print("\n1. Checking Python version...")
print(f"   Python {sys.version}")

print("\n2. Checking required packages...")
required_packages = [
    "fastapi",
    "uvicorn",
    "transformers",
    "sentence_transformers",
    "torch",
    "huggingface_hub",
    "faiss",
    "google.generativeai",
    "numpy",
    "dotenv"
]

missing_packages = []
for package in required_packages:
    try:
        if package == "dotenv":
            __import__("dotenv")
        elif package == "google.generativeai":
            __import__("google.generativeai")
        else:
            __import__(package)
        print(f"   ✓ {package}")
    except ImportError:
        print(f"   ✗ {package} - MISSING")
        missing_packages.append(package)

print("\n3. Checking project files...")
project_files = [
    "main.py",
    "model_loader.py",
    "rag_loader.py",
    "rag_service.py",
    "prompt_builder.py",
    "utils.py",
    "requirements.txt",
    "Dockerfile",
    "start.sh",
    "README.md"
]

for file in project_files:
    if os.path.exists(file):
        size = os.path.getsize(file)
        print(f"   ✓ {file} ({size} bytes)")
    else:
        print(f"   ✗ {file} - MISSING")

print("\n4. Testing imports...")
try:
    print("   Testing model_loader...")
    from model_loader import predictVerdict, getConfidence
    print("   ✓ model_loader imports successful")
except Exception as e:
    print(f"   ✗ model_loader error: {e}")

try:
    print("   Testing rag_loader...")
    from rag_loader import retrieve
    print("   ✓ rag_loader imports successful")
except Exception as e:
    print(f"   ✗ rag_loader error: {e}")

try:
    print("   Testing rag_service...")
    from rag_service import evaluateCase
    print("   ✓ rag_service imports successful")
except Exception as e:
    print(f"   ✗ rag_service error: {e}")

try:
    print("   Testing prompt_builder...")
    from prompt_builder import buildPrompt
    print("   ✓ prompt_builder imports successful")
except Exception as e:
    print(f"   ✗ prompt_builder error: {e}")

print("\n5. Checking environment...")
env_file = ".env"
if os.path.exists(env_file):
    print(f"   ✓ .env file found")
    with open(env_file) as f:
        has_gemini = "GEMINI_API_KEY" in f.read()
        if has_gemini:
            print("   ✓ GEMINI_API_KEY configured")
        else:
            print("   ⚠ GEMINI_API_KEY not found in .env")
else:
    print("   ⚠ .env file not found (optional)")

print("\n" + "=" * 60)
if missing_packages:
    print("❌ SETUP INCOMPLETE")
    print(f"\nMissing packages: {', '.join(missing_packages)}")
    print("\nRun: pip install -r requirements.txt")
else:
    print("✅ ALL CHECKS PASSED")
    print("\nNext steps:")
    print("  1. Run: ./start.sh")
    print("  2. Open: http://localhost:7860/docs")
    print("  3. Test the API endpoints")
print("=" * 60)