File size: 3,400 Bytes
2f95553
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""

Quick script to check if environment variables are set correctly.

Run: python check_env.py

"""
import os
import sys

def check_env():
    """Check and display environment variable status."""
    print("=" * 50)
    print("IITM LLM Quiz Solver - Environment Check")
    print("=" * 50)
    print()
    
    # Check QUIZ_SECRET
    quiz_secret = os.getenv("QUIZ_SECRET")
    if quiz_secret:
        # Show first and last 4 chars for security
        masked = f"{quiz_secret[:4]}...{quiz_secret[-4:]}" if len(quiz_secret) > 8 else "***"
        print(f"βœ“ QUIZ_SECRET: Set ({masked})")
        print(f"  Length: {len(quiz_secret)} characters")
    else:
        print("βœ— QUIZ_SECRET: NOT SET (Required)")
        print("  Set it with: export QUIZ_SECRET='your_secret' (Linux/Mac)")
        print("  Or: $env:QUIZ_SECRET = 'your_secret' (Windows PowerShell)")
    
    print()
    
    # Check OpenAI key
    openai_key = os.getenv("OPENAI_API_KEY")
    if openai_key:
        masked = f"{openai_key[:7]}...{openai_key[-4:]}" if len(openai_key) > 11 else "***"
        print(f"βœ“ OPENAI_API_KEY: Set ({masked})")
        print(f"  Length: {len(openai_key)} characters")
        if not openai_key.startswith("sk-"):
            print("  ⚠ Warning: OpenAI keys usually start with 'sk-'")
    else:
        print("βœ— OPENAI_API_KEY: NOT SET (Optional)")
        print("  Set it with: export OPENAI_API_KEY='sk-your-key' (Linux/Mac)")
        print("  Or: $env:OPENAI_API_KEY = 'sk-your-key' (Windows PowerShell)")
    
    print()
    
    # Check OpenRouter key
    openrouter_key = os.getenv("OPENROUTER_API_KEY")
    if openrouter_key:
        masked = f"{openrouter_key[:6]}...{openrouter_key[-4:]}" if len(openrouter_key) > 10 else "***"
        print(f"βœ“ OPENROUTER_API_KEY: Set ({masked})")
        print(f"  Length: {len(openrouter_key)} characters")
        if not openrouter_key.startswith("sk-or-"):
            print("  ⚠ Warning: OpenRouter keys usually start with 'sk-or-'")
        model = os.getenv("OPENROUTER_MODEL", "gpt-5-nano")
        print(f"  Model: {model}")
    else:
        print("βœ— OPENROUTER_API_KEY: NOT SET (Optional)")
        print("  Set it with: export OPENROUTER_API_KEY='sk-or-your-key' (Linux/Mac)")
        print("  Or: $env:OPENROUTER_API_KEY = 'sk-or-your-key' (Windows PowerShell)")
    
    print()
    
    # Check PORT (optional)
    port = os.getenv("PORT", "8000")
    print(f"PORT: {port} (default: 8000)")
    
    print()
    print("=" * 50)
    
    # Summary
    if quiz_secret:
        print("βœ“ Status: Ready to run (QUIZ_SECRET is set)")
        if openai_key or openrouter_key:
            provider = []
            if openai_key:
                provider.append("OpenAI")
            if openrouter_key:
                provider.append("OpenRouter")
            print(f"βœ“ LLM features: Enabled via {', '.join(provider)}")
        else:
            print("⚠ LLM features: Disabled (no LLM API keys set)")
    else:
        print("βœ— Status: NOT READY - QUIZ_SECRET is required")
        sys.exit(1)
    
    print("=" * 50)
    print()
    print("To start the server, run:")
    print("  python -m app.main")
    print("  or")
    print("  uvicorn app.main:app --host 0.0.0.0 --port 8000")

if __name__ == "__main__":
    check_env()