Your Name Claude commited on
Commit
a96cb39
·
1 Parent(s): 7320408

Add detailed environment variable debugging for HF Spaces

Browse files

- Log whether GEMINI_API_KEY is found at startup
- Show first 10 characters of key if found (for verification)
- List all GEMINI/GOOGLE env vars if key is missing
- This will help diagnose why HF Spaces isn't picking up secrets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -12,6 +12,22 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(
12
  # Load environment variables
13
  load_dotenv()
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Download required NLTK data on startup
16
  def download_nltk_data():
17
  """Download all required NLTK data for the application"""
 
12
  # Load environment variables
13
  load_dotenv()
14
 
15
+ # Debug: Log environment variable status
16
+ logging.info("=" * 60)
17
+ logging.info("ENVIRONMENT VARIABLES CHECK")
18
+ logging.info("=" * 60)
19
+ gemini_key = os.environ.get('GEMINI_API_KEY')
20
+ if gemini_key:
21
+ logging.info(f"✓ GEMINI_API_KEY found (length: {len(gemini_key)} chars)")
22
+ logging.info(f" First 10 chars: {gemini_key[:10]}...")
23
+ else:
24
+ logging.error("✗ GEMINI_API_KEY not found in environment!")
25
+ logging.info("Available env vars starting with 'GEMINI': " +
26
+ str([k for k in os.environ.keys() if 'GEMINI' in k.upper()]))
27
+ logging.info("Available env vars starting with 'GOOGLE': " +
28
+ str([k for k in os.environ.keys() if 'GOOGLE' in k.upper()]))
29
+ logging.info("=" * 60)
30
+
31
  # Download required NLTK data on startup
32
  def download_nltk_data():
33
  """Download all required NLTK data for the application"""