|
|
"""
|
|
|
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()
|
|
|
|
|
|
|
|
|
quiz_secret = os.getenv("QUIZ_SECRET")
|
|
|
if quiz_secret:
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
port = os.getenv("PORT", "8000")
|
|
|
print(f"PORT: {port} (default: 8000)")
|
|
|
|
|
|
print()
|
|
|
print("=" * 50)
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|