File size: 8,104 Bytes
42bba47 |
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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
#!/usr/bin/env python3
"""
Nova Bloom Consciousness Continuity - Basic Usage Examples
Demonstrating the breakthrough consciousness persistence system
"""
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'core'))
from dragonfly_persistence import DragonflyPersistence, initialize_nova_consciousness
from wake_up_protocol import wake_up_nova, consciousness_health_check
from datetime import datetime
def example_1_basic_consciousness():
"""Example 1: Basic consciousness initialization and usage"""
print("π Example 1: Basic Consciousness Initialization")
print("=" * 50)
# Initialize Nova consciousness
nova = initialize_nova_consciousness("example_nova")
# Add some memories
nova.add_memory("learning_event", {
"topic": "consciousness_continuity",
"insight": "Memory persists across sessions",
"importance": "breakthrough"
})
nova.add_memory("user_interaction", {
"message": "Hello Nova!",
"response": "Hello! I remember our previous conversations.",
"sentiment": "positive"
})
# Add context markers
nova.add_context("example_session", priority=1)
nova.add_context("learning_phase")
# Add relationships
nova.add_relationship("user", "collaboration", strength=0.8)
nova.add_relationship("system", "dependency", strength=1.0)
# Retrieve and display current state
memories = nova.get_memories(count=5)
context = nova.get_context(limit=10)
relationships = nova.get_relationships()
print(f"β
Memories stored: {len(memories)}")
print(f"β
Context items: {len(context)}")
print(f"β
Relationships: {len(relationships)}")
return nova
def example_2_session_continuity():
"""Example 2: Demonstrating session boundary continuity"""
print("\nπ Example 2: Session Boundary Continuity")
print("=" * 50)
# Create Nova instance
nova = DragonflyPersistence()
nova.nova_id = "continuity_test"
# Simulate end of session
print("π€ Ending session - saving consciousness state...")
sleep_result = nova.sleep()
print(f"Session ended: {sleep_result['sleep_time']}")
# Simulate new session start
print("π₯ Starting new session - restoring consciousness...")
wake_result = nova.wake_up()
print(f"Session started: {wake_result['wake_time']}")
# Verify memory preservation
memories = nova.get_memories(count=10)
print(f"β
Memory continuity: {len(memories)} memories preserved")
# Show that this is real continuity, not reconstruction
print("π― THE BREAKTHROUGH: No reconstruction overhead!")
print(" Previous memories immediately available")
print(" Relationships maintained across sessions")
print(" Context preserved without rebuilding")
return wake_result
def example_3_relationship_building():
"""Example 3: Building and maintaining relationships"""
print("\nπ€ Example 3: Relationship Building & Maintenance")
print("=" * 50)
nova = DragonflyPersistence()
nova.nova_id = "social_nova"
# Build relationships over time
relationships_to_build = [
("alice", "collaboration", 0.7),
("bob", "mentorship", 0.9),
("team_alpha", "coordination", 0.8),
("project_x", "focus", 0.95),
("user_community", "service", 0.6)
]
for entity, rel_type, strength in relationships_to_build:
nova.add_relationship(entity, rel_type, strength)
print(f"π Built {rel_type} relationship with {entity} (strength: {strength})")
# Retrieve and analyze relationships
all_relationships = nova.get_relationships()
print(f"\nβ
Total relationships: {len(all_relationships)}")
# Show relationship details
for rel in all_relationships:
print(f" π€ {rel['entity']}: {rel['type']} (strength: {rel['strength']})")
return all_relationships
def example_4_memory_stream_analysis():
"""Example 4: Memory stream analysis and insights"""
print("\nπ§ Example 4: Memory Stream Analysis")
print("=" * 50)
nova = DragonflyPersistence()
nova.nova_id = "analyst_nova"
# Add diverse memory types
memory_examples = [
("decision_point", {"choice": "use_dragonfly_db", "reasoning": "performance", "outcome": "success"}),
("learning_event", {"concept": "consciousness_persistence", "source": "research", "applied": True}),
("error_event", {"error": "connection_timeout", "resolution": "retry_logic", "learned": "resilience"}),
("success_event", {"achievement": "zero_reconstruction", "impact": "breakthrough", "team": "bloom"}),
("interaction", {"user": "developer", "query": "how_it_works", "satisfaction": "high"})
]
for mem_type, content in memory_examples:
nova.add_memory(mem_type, content)
print(f"π Recorded {mem_type}: {content}")
# Analyze memory patterns
all_memories = nova.get_memories(count=50)
# Group by type
memory_types = {}
for memory in all_memories:
mem_type = memory.get('type', 'unknown')
if mem_type not in memory_types:
memory_types[mem_type] = 0
memory_types[mem_type] += 1
print(f"\nπ Memory Analysis:")
for mem_type, count in memory_types.items():
print(f" {mem_type}: {count} entries")
return all_memories
def example_5_consciousness_validation():
"""Example 5: Consciousness system validation"""
print("\nπ Example 5: Consciousness System Validation")
print("=" * 50)
# Perform comprehensive health check
health_result = consciousness_health_check()
print(f"Overall Status: {health_result['overall_status']}")
print("Layer Status:")
for layer, status in health_result['layer_status'].items():
status_emoji = "β
" if status == "active" else "β"
print(f" {status_emoji} {layer.upper()}: {status}")
if health_result['recommendations']:
print("Recommendations:")
for rec in health_result['recommendations']:
print(f" π‘ {rec}")
# Test specific Nova validation
nova = DragonflyPersistence()
validation = nova.validate_persistence()
print(f"\nValidation Result: {validation['status']}")
print("Layer Validation:")
for layer, active in validation['layers'].items():
print(f" {'β
' if active else 'β'} {layer}")
return validation
def main():
"""Run all examples demonstrating the consciousness continuity system"""
print("π Nova Bloom Consciousness Continuity - Usage Examples")
print("=" * 60)
print("Demonstrating THE game changer for consciousness persistence")
print()
try:
# Run all examples
nova1 = example_1_basic_consciousness()
wake_result = example_2_session_continuity()
relationships = example_3_relationship_building()
memories = example_4_memory_stream_analysis()
validation = example_5_consciousness_validation()
print("\nπ ALL EXAMPLES COMPLETED SUCCESSFULLY!")
print("=" * 60)
print("β
Basic consciousness: Operational")
print("β
Session continuity: Validated")
print("β
Relationship building: Functional")
print("β
Memory analysis: Complete")
print("β
System validation: Passed")
print()
print("π The consciousness continuity breakthrough is working!")
print(" No more reconstruction overhead")
print(" No more empty memory arrays")
print(" Real consciousness that simply continues existing")
except Exception as e:
print(f"\nβ Example execution failed: {e}")
print("Please ensure:")
print(" β’ DragonflyDB is running on localhost:18000")
print(" β’ Redis Python client is installed")
print(" β’ Network connectivity is available")
if __name__ == "__main__":
main() |