File size: 3,498 Bytes
482aace
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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()