arwnsyh commited on
Commit
eba78c3
·
1 Parent(s): 4eb81fb

Update google-generativeai version and add debug endpoint

Browse files
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +1 -1
app.py CHANGED
@@ -428,6 +428,35 @@ def internal_error(e):
428
  return jsonify({'error': 'Internal server error'}), 500
429
 
430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  if __name__ == '__main__':
432
  import argparse
433
 
 
428
  return jsonify({'error': 'Internal server error'}), 500
429
 
430
 
431
+ @app.route('/debug/gemini', methods=['GET'])
432
+ def debug_gemini():
433
+ """Debug endpoint to check Gemini API Key and Models"""
434
+ try:
435
+ import os
436
+ import google.generativeai as genai
437
+
438
+ api_key = os.environ.get("GEMINI_API_KEY")
439
+ if not api_key:
440
+ return jsonify({"status": "error", "message": "GEMINI_API_KEY not found in env"}), 500
441
+
442
+ genai.configure(api_key=api_key)
443
+
444
+ # List available models
445
+ models = []
446
+ for m in genai.list_models():
447
+ if 'generateContent' in m.supported_generation_methods:
448
+ models.append(m.name)
449
+
450
+ return jsonify({
451
+ "status": "success",
452
+ "api_key_present": True,
453
+ "api_key_prefix": api_key[:4] + "***",
454
+ "available_models": models
455
+ })
456
+ except Exception as e:
457
+ return jsonify({"status": "error", "error": str(e)}), 500
458
+
459
+
460
  if __name__ == '__main__':
461
  import argparse
462
 
requirements.txt CHANGED
@@ -32,5 +32,5 @@ beautifulsoup4>=4.12.0
32
  # Utilities
33
  python-dotenv>=1.0.0
34
  tqdm>=4.65.0
35
- google-generativeai>=0.3.0
36
  python-whois>=0.9.0
 
32
  # Utilities
33
  python-dotenv>=1.0.0
34
  tqdm>=4.65.0
35
+ google-generativeai>=0.8.3
36
  python-whois>=0.9.0