Spaces:
Runtime error
Runtime error
YoonJ-C
commited on
Commit
·
68f0989
1
Parent(s):
0c5e389
Add debug endpoint for troubleshooting chatbot issues
Browse files- Add /debug route to check API configuration
- Monitor TOGETHER_API_KEY availability
- Check client initialization status
- Help diagnose chatbot issues on Hugging Face
app.py
CHANGED
|
@@ -438,6 +438,20 @@ INSTRUCTIONS:
|
|
| 438 |
"message": f"Chat error: {str(e)}"
|
| 439 |
})
|
| 440 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
# Initialize default test user on startup
|
| 442 |
initialize_default_user()
|
| 443 |
|
|
|
|
| 438 |
"message": f"Chat error: {str(e)}"
|
| 439 |
})
|
| 440 |
|
| 441 |
+
@app.route("/debug")
|
| 442 |
+
def debug():
|
| 443 |
+
"""
|
| 444 |
+
Debug endpoint to check API configuration and environment
|
| 445 |
+
"""
|
| 446 |
+
return jsonify({
|
| 447 |
+
"api_key_set": bool(TOGETHER_API_KEY),
|
| 448 |
+
"client_available": client is not None,
|
| 449 |
+
"environment": os.environ.get("ENVIRONMENT", "unknown"),
|
| 450 |
+
"together_api_key_length": len(TOGETHER_API_KEY) if TOGETHER_API_KEY else 0,
|
| 451 |
+
"flask_debug": app.debug,
|
| 452 |
+
"users_file": USERS_FILE
|
| 453 |
+
})
|
| 454 |
+
|
| 455 |
# Initialize default test user on startup
|
| 456 |
initialize_default_user()
|
| 457 |
|