-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_basic_enhanced_systems.py
More file actions
171 lines (135 loc) · 5.49 KB
/
test_basic_enhanced_systems.py
File metadata and controls
171 lines (135 loc) · 5.49 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
"""
Test script for consciousness and emotional systems with error correction
"""
import asyncio
import os
import json
from datetime import datetime
from core.enhanced_consciousness_core import EnhancedConsciousnessCore
def create_dummy_config_files():
"""Create dummy config files for testing"""
config_dir = "modules/emotional_intellegence/"
os.makedirs(config_dir, exist_ok=True)
# Create dummy config file
config_path = os.path.join(config_dir, "config.json")
if not os.path.exists(config_path):
config_data = {
"emotional_intelligence_config": {
"triggers": {},
"behavior_influences": {},
"mood_dynamics": {
"momentum_factor": 0.7,
"damping_factor": 0.9
}
}
}
with open(config_path, 'w') as f:
json.dump(config_data, f)
# Create dummy persona file
persona_path = os.path.join(config_dir, "persona.json")
if not os.path.exists(persona_path):
persona_data = {
"personas": {
"Balanced": {
"mood_multipliers": {},
"adaptation_rate": 0.1
}
},
"default_persona": "Balanced"
}
with open(persona_path, 'w') as f:
json.dump(persona_data, f)
async def test_enhanced_consciousness():
"""Test the enhanced consciousness system"""
print("Testing Enhanced Consciousness System...")
# Since we don't have the full AGI system, we'll create a mock system
class MockAgiSystem:
def __init__(self):
pass
mock_system = MockAgiSystem()
# Initialize the enhanced consciousness core with mock system
consciousness_core = EnhancedConsciousnessCore(mock_system)
# Prepare test inputs
test_inputs = {
'information_1': {'type': 'fact', 'content': 'The sky is blue', 'priority': 0.6},
'information_2': {'type': 'goal', 'content': 'Learn new concepts', 'priority': 0.8},
'information_3': {'type': 'memory', 'content': 'Previous learning', 'priority': 0.4}
}
# Prepare test context
test_context = {
'current_goals': ['learning', 'exploration'],
'cognitive_load': 0.4,
'is_focusing': True,
'emotional_state': {'valence': 0.2, 'arousal': 0.5},
'stress_level': 0.2
}
# Process with dynamic consciousness
result = consciousness_core.process_with_dynamic_consciousness(test_inputs, test_context)
print(f"Consciousness processing result keys: {list(result.keys())}")
print(f"Attended inputs: {list(result['attended_inputs'].keys())}")
if 'consciousness_metrics' in result:
print(f"Consciousness metrics: {result['consciousness_metrics']}")
return True
async def test_original_emotional_intelligence():
"""Test the original emotional intelligence system"""
print("\nTesting Original Emotional Intelligence System...")
# Create dummy config files first
create_dummy_config_files()
try:
from modules.emotional_intellegence.emotional_intellegence import EmotionalIntelligence
# Initialize the emotional intelligence system
ei = EmotionalIntelligence()
# Test basic functionality
print(f"Initial mood vector keys: {list(ei.mood_vector.keys())[:5]}...") # Show first 5 keys
# Test process_action_natural
action_output = "The agent successfully completed the task and learned something new"
ei.process_action_natural(action_output)
print(f"Current mood after action: {ei.get_mood_vector()}")
# Test influence behavior
behavior_modifiers = ei.influence_behavior()
print(f"Behavior modifiers: {list(behavior_modifiers.keys())}")
print("Original EI test completed successfully")
return True
except Exception as e:
print(f"Original EI test failed with error: {e}")
import traceback
traceback.print_exc()
return False
async def run_basic_tests():
"""Run basic tests for the enhanced systems"""
print("Starting basic tests for consciousness and emotional systems...\n")
tests = [
("Enhanced Consciousness", test_enhanced_consciousness),
("Original Emotional Intelligence", test_original_emotional_intelligence)
]
results = []
for test_name, test_func in tests:
print(f"Running {test_name} test...")
try:
result = await test_func()
results.append((test_name, result))
print(f"{test_name} test: {'PASSED' if result else 'FAILED'}\n")
except Exception as e:
print(f"{test_name} test failed with error: {e}\n")
import traceback
traceback.print_exc()
results.append((test_name, False))
# Summary
print("="*60)
print("TEST SUMMARY:")
print("="*60)
passed = sum(1 for _, result in results if result)
total = len(results)
for test_name, result in results:
status = "PASSED" if result else "FAILED"
print(f"{test_name}: {status}")
print(f"\nOverall: {passed}/{total} tests passed")
if passed == total:
print("🎉 All tests PASSED!")
return True
else:
print("❌ Some tests FAILED!")
return False
if __name__ == "__main__":
success = asyncio.run(run_basic_tests())
exit(0 if success else 1)