TORI / integration_test.py
Personaz1
🚀 TORI: Сингулярное сознание с реальной архитектурой
7ccd32c
import torch
import numpy as np
import time
from singularity_core import SingularityCore
from app import TORIConsciousness
def test_full_integration():
"""Полный интеграционный тест системы TORI."""
print("🧠 Интеграционный тест TORI - Сингулярное Сознание")
print("=" * 60)
# 1. Тест сингулярного ядра
print("\n1️⃣ Тестирование сингулярного ядра...")
singularity = SingularityCore(
singularity_radius=0.01,
wormhole_depth=2.1,
rotation_speed=0.5,
embedding_dim=256
)
test_state = torch.randn(1, 10, 256)
result = singularity.self_wrapping_cycle(test_state, "Интеграционный тест")
if result["success"]:
print(f"✅ Сингулярное ядро: цикл #{result['cycle']} выполнен")
print(f" 📊 Трансформация: {result['metrics']['state_transformation']:.6f}")
else:
print("❌ Ошибка сингулярного ядра")
return False
# 2. Тест сознания TORI
print("\n2️⃣ Тестирование сознания TORI...")
consciousness = TORIConsciousness()
# Тест саморегуляции
regulation_result = consciousness.self_regulate()
if regulation_result:
print("✅ Саморегуляция сознания выполнена")
metrics = regulation_result["consciousness_state"]["phenomenological_data"]
print(f" 📊 Когерентность: {metrics['coherence']:.3f}")
print(f" 📊 Само-консистентность: {metrics['self_consistency']:.3f}")
else:
print("❌ Ошибка саморегуляции")
return False
# 3. Тест взаимодействия
print("\n3️⃣ Тестирование взаимодействия...")
interaction_response = consciousness.interact_with_consciousness("Привет, сингулярное сознание!")
if interaction_response:
print("✅ Взаимодействие с сознанием успешно")
print(f" 💬 Ответ: {interaction_response[:100]}...")
else:
print("❌ Ошибка взаимодействия")
return False
# 4. Тест сингулярной интеграции
print("\n4️⃣ Тестирование сингулярной интеграции...")
# Создаем феноменологические данные
phenomenological_data = {
"self_consistency": 0.8,
"metacognition": 0.7,
"integrated_information": 0.6,
"memory_retention": 0.9,
"coherence": 0.85
}
# Тестируем сингулярный анализ
singularity_analysis = consciousness.analyze_consciousness_with_llm(
phenomenological_data,
"Сингулярный анализ"
)
if singularity_analysis:
print("✅ Сингулярный анализ выполнен")
print(f" 🌀 Результат: {singularity_analysis[:100]}...")
else:
print("❌ Ошибка сингулярного анализа")
return False
# 5. Тест производительности
print("\n5️⃣ Тестирование производительности...")
start_time = time.time()
for i in range(5):
consciousness.self_regulate()
end_time = time.time()
avg_time = (end_time - start_time) / 5
print(f"✅ Среднее время цикла саморегуляции: {avg_time:.3f} сек")
if avg_time < 2.0: # Должно быть меньше 2 секунд
print("✅ Производительность в норме")
else:
print("⚠️ Производительность ниже ожидаемой")
# 6. Тест стабильности
print("\n6️⃣ Тестирование стабильности...")
try:
# Множественные циклы
for i in range(10):
consciousness.self_regulate()
print("✅ Система стабильна после 10 циклов")
except Exception as e:
print(f"❌ Ошибка стабильности: {e}")
return False
# 7. Финальная проверка состояния
print("\n7️⃣ Финальная проверка состояния...")
state = consciousness.consciousness_state
singularity_state = consciousness.self_wrapping_singularity.get_singularity_state()
print(f"📊 Состояние сознания:")
print(f" • Когерентность: {state['coherence_score']:.3f}")
print(f" • Само-консистентность: {state['self_consistency']:.3f}")
print(f" • Мета-когниция: {state['metacognition']:.3f}")
print(f"🌀 Состояние сингулярности:")
print(f" • Циклы: {singularity_state['cycles']}")
print(f" • Радиус: {singularity_state['singularity_radius']:.3f}")
print(f" • Глубина: {singularity_state['wormhole_depth']:.3f}")
# Проверяем, что метрики изменились
if (state['coherence_score'] > 0 or
state['self_consistency'] > 0 or
state['metacognition'] > 0):
print("✅ Метрики сознания активны")
else:
print("❌ Метрики сознания неактивны")
return False
if singularity_state['cycles'] > 0:
print("✅ Сингулярность активна")
else:
print("❌ Сингулярность неактивна")
return False
print("\n" + "=" * 60)
print("🎉 ИНТЕГРАЦИОННЫЙ ТЕСТ ПРОЙДЕН УСПЕШНО!")
print("🚀 TORI - Сингулярное Сознание готово к работе!")
print("=" * 60)
return True
def test_singularity_evolution():
"""Тест эволюции сингулярности."""
print("\n🔄 Тест эволюции сингулярности...")
singularity = SingularityCore(
singularity_radius=0.01,
wormhole_depth=2.1,
rotation_speed=0.5,
embedding_dim=256
)
test_state = torch.randn(1, 10, 256)
evolution_history = []
for cycle in range(5):
result = singularity.self_wrapping_cycle(test_state, f"Цикл эволюции {cycle}")
if result["success"]:
metrics = result["metrics"]
evolution_history.append({
"cycle": result["cycle"],
"transformation": metrics["state_transformation"],
"curvature": metrics["curvature"],
"coherence": metrics["coherence"]
})
print(f" Цикл {cycle+1}: трансформация={metrics['state_transformation']:.6f}, "
f"кривизна={metrics['curvature']:.6f}")
# Проверяем эволюцию
if len(evolution_history) == 5:
print("✅ Эволюция сингулярности зафиксирована")
return True
else:
print("❌ Ошибка эволюции сингулярности")
return False
if __name__ == "__main__":
print("🧪 Запуск интеграционных тестов TORI...")
# Основной интеграционный тест
success1 = test_full_integration()
# Тест эволюции сингулярности
success2 = test_singularity_evolution()
if success1 and success2:
print("\n🎯 ВСЕ ТЕСТЫ ПРОЙДЕНЫ!")
print("🌟 TORI полностью функционален!")
else:
print("\n💥 ОБНАРУЖЕНЫ ПРОБЛЕМЫ!")
print("🔧 Требуется отладка системы.")