AI-Life-Coach-Streamlit2 / test_enhanced_debug.py
rdune71's picture
Implement enhanced debug panel with comprehensive system monitoring and controls
482aace
import sys
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent
sys.path.append(str(project_root))
from utils.config import config
from core.session import session_manager
import os
def test_enhanced_debug_features():
"""Test the enhanced debug panel features"""
print("=== Enhanced Debug Panel Feature Test ===")
print()
# Test System Controls Configuration
print("1. Testing System Controls Configuration:")
print(f" Fallback Mode: {config.use_fallback}")
print(f" HF Token Available: {bool(config.hf_token)}")
print(f" Tavily API Key: {bool(os.getenv('TAVILY_API_KEY'))}")
print(f" OpenWeather API Key: {bool(config.openweather_api_key)}")
print()
# Test Provider Status
print("2. Testing Provider Status:")
try:
from services.ollama_monitor import check_ollama_status
ollama_status = check_ollama_status()
print(f" Ollama Running: {ollama_status.get('running', 'Unknown')}")
print(f" Ollama Model: {ollama_status.get('model_loaded', 'Unknown')}")
except Exception as e:
print(f" Ollama Status Check Failed: {e}")
try:
from services.hf_endpoint_monitor import hf_monitor
hf_status = hf_monitor.check_endpoint_status()
print(f" HF Available: {hf_status.get('available', 'Unknown')}")
print(f" HF Initialized: {hf_status.get('initialized', 'Unknown')}")
print(f" HF Status Code: {hf_status.get('status_code', 'Unknown')}")
except Exception as e:
print(f" HF Status Check Failed: {e}")
print()
# Test External Services
print("3. Testing External Services:")
print(f" Tavily API: {'βœ… Configured' if os.getenv('TAVILY_API_KEY') else '❌ Not configured'}")
print(f" Weather API: {'βœ… Configured' if config.openweather_api_key else '❌ Not configured'}")
print()
# Test Session Statistics
print("4. Testing Session Statistics:")
try:
user_session = session_manager.get_session("default_user")
conversation = user_session.get("conversation", [])
print(f" Conversation Length: {len(conversation)} messages")
coord_stats = user_session.get('ai_coordination', {})
if coord_stats:
print(f" AI Requests: {coord_stats.get('requests_processed', 0)}")
print(f" Ollama Responses: {coord_stats.get('ollama_responses', 0)}")
print(f" HF Responses: {coord_stats.get('hf_responses', 0)}")
else:
print(" AI Coordination: Not active")
except Exception as e:
print(f" Session Stats Failed: {e}")
print()
# Test Configuration Summary
print("5. Testing Configuration Summary:")
print(f" Environment: {'HF Space' if config.is_hf_space else 'Local'}")
print(f" Primary Model: {config.local_model_name or 'Not set'}")
# Feature Flags Summary
features = []
if config.use_fallback:
features.append("Fallback")
if config.hf_token:
features.append("HF Deep Analysis")
if os.getenv("TAVILY_API_KEY"):
features.append("Web Search")
if config.openweather_api_key:
features.append("Weather")
print(f" Active Features: {', '.join(features) if features else 'None'}")
print()
print("πŸŽ‰ Enhanced Debug Panel Feature Test Completed!")
if __name__ == "__main__":
test_enhanced_debug_features()