File size: 3,171 Bytes
196ee96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
95
96
97
98
99
100
101
102
103
104
105
106
import sys
from pathlib import Path

# Add project root to path
project_root = Path(__file__).parent
sys.path.append(str(project_root))

from core.redis_client import redis_client
from core.session import session_manager
from core.llm import send_to_ollama
import os

def test_full_system():
    """Test the complete AI Life Coach system"""
    print("=== AI Life Coach Full System Test ===")
    print()
    
    # Test 1: Redis Connection
    print("Test 1: Redis Connection")
    try:
        client = redis_client.get_client()
        if client:
            result = client.ping()
            print(f"βœ… Redis ping successful: {result}")
            
            # Test set/get
            client.set('system_test_key', 'system_test_value')
            value = client.get('system_test_key')
            client.delete('system_test_key')
            
            if value == 'system_test_value':
                print("βœ… Redis set/get operations working")
            else:
                print("❌ Redis set/get operations failed")
        else:
            print("❌ Redis client is None")
            return False
    except Exception as e:
        print(f"❌ Redis test failed: {e}")
        return False
    
    print()
    
    # Test 2: Session Management
    print("Test 2: Session Management")
    try:
        session = session_manager.get_session("test_user")
        print("βœ… Session creation successful")
        
        # Test session update
        result = session_manager.update_session("test_user", {"test": "data"})
        if result:
            print("βœ… Session update successful")
        else:
            print("❌ Session update failed")
        
        # Clean up
        session_manager.clear_session("test_user")
        print("βœ… Session cleanup successful")
            
    except Exception as e:
        print(f"❌ Session management test failed: {e}")
        return False
    
    print()
    
    # Test 3: Ollama Integration
    print("Test 3: Ollama Integration")
    try:
        conversation_history = [
            {"role": "user", "content": "Hello! Please introduce yourself briefly."}
        ]
        
        ollama_url = "https://7bcc180dffd1.ngrok-free.app"
        model_name = "mistral:latest"
        
        response = send_to_ollama(
            "Hello! Please introduce yourself briefly.",
            conversation_history,
            ollama_url,
            model_name
        )
        
        if response:
            print("βœ… Ollama integration successful")
            print(f"Response: {response[:100]}{'...' if len(response) > 100 else ''}")
        else:
            print("❌ Ollama integration failed - no response")
            
    except Exception as e:
        print(f"❌ Ollama integration test failed: {e}")
        return False
    
    print()
    print("πŸŽ‰ All system tests passed!")
    print("Your AI Life Coach is ready to use!")
    return True

if __name__ == "__main__":
    success = test_full_system()
    if success:
        print("\nβœ… System is fully operational!")
    else:
        print("\n❌ System has issues that need attention!")
        sys.exit(1)