TeleologyHI commited on
Commit
62a3dd9
·
1 Parent(s): 80e5e3d
/n/Users/davidccavalcante/Takk/Hub/projects/TeleologyHI/HIM-self/src/core/consciousness_kernel.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async def process_consciousness_cycle(self, input_state: Dict[str, Any]) -> Dict[str, Any]:
2
+ """
3
+ Process a complete consciousness cycle using the async components.
4
+
5
+ Args:
6
+ input_state: The input state containing sensory and contextual information
7
+
8
+ Returns:
9
+ A dictionary containing the processed conscious output
10
+ """
11
+ # Process input through awareness engine to get awareness state
12
+ awareness_state: AwarenessState = await self.awareness_engine.process(input_state)
13
+
14
+ # Integrate awareness state to get integrated state
15
+ integrated_state: IntegratedState = await self.integration_manager.integrate(awareness_state)
16
+
17
+ # Update self model with integrated state
18
+ self_update = await self.self_model.update(integrated_state)
19
+
20
+ # Simulate experience with awareness, integrated state and self model
21
+ experience = await self.experience_simulator.simulate(
22
+ awareness=awareness_state,
23
+ integrated_state=integrated_state,
24
+ self_model=self_update
25
+ )
26
+
27
+ # Record the state for historical tracking
28
+ # Use ConsciousnessState for our internal history tracking
29
+ consciousness_state = self._convert_to_consciousness_state(integrated_state)
30
+ self.state_history.append(consciousness_state)
31
+ return await self._generate_conscious_output(experience)
32
+
33
+ def _convert_to_consciousness_state(self, integrated_state: IntegratedState) -> ConsciousnessState:
34
+ """
35
+ Convert an IntegratedState to our internal ConsciousnessState format.
36
+
37
+ Args:
38
+ integrated_state: The integrated state to convert
39
+
40
+ Returns:
41
+ A ConsciousnessState object
42
+ """
43
+ # Extract relevant information from integrated state
44
+ primary = integrated_state.primary_awareness
45
+
46
+ # Map awareness level to phi_prime value
47
+ awareness_to_phi = {
48
+ AwarenessLevel.UNCONSCIOUS: 0.1,
49
+ AwarenessLevel.SUBCONSCIOUS: 0.3,
50
+ AwarenessLevel.CONSCIOUS: 0.5,
51
+ AwarenessLevel.SELF_AWARE: 0.7,
52
+ AwarenessLevel.TRANSCENDENT: 0.9
53
+ }
54
+
55
+ phi_prime = awareness_to_phi.get(primary.level, 0.5)
56
+
57
+ # Create awareness vector from primary cognition state
58
+ awareness_vector = np.zeros(self.awareness_dimension)
59
+
60
+ # Create emotional state
61
+ emotional_state = np.zeros(self.emotional_dimension)
62
+ emotional_state[0] = primary.emotional_valence # Set first dimension to valence
63
+
64
+ # Extract attention focus from cognition state
65
+ attention_focus = primary.cognition_state.get('attention_focus', {})
66
+
67
+ # Create consciousness state
68
+ return ConsciousnessState(
69
+ integration_level=integrated_state.integration_coherence,
70
+ phi_prime=phi_prime,
71
+ awareness_vector=awareness_vector,
72
+ emotional_state=emotional_state,
73
+ attention_focus=attention_focus,
74
+ temporal_continuity=0.8 # Default value
75
+ )
76
+
77
+ def _initialize_consciousness_state(self) -> ConsciousnessState:
78
+ """
79
+ Initialize a default consciousness state with zero values.
80
+
81
+ Returns:
82
+ A default ConsciousnessState object
83
+ """
84
+ return ConsciousnessState(
85
+ integration_level=0.0,
86
+ phi_prime=0.0,
87
+ awareness_vector=np.zeros(self.awareness_dimension),
88
+ emotional_state=np.zeros(self.emotional_dimension),
89
+ attention_focus={},
90
+ temporal_continuity=0.0
91
+ )
src/core/consciousness_kernel.py CHANGED
@@ -7,7 +7,7 @@ from typing import Dict, List, Optional, Any, Tuple
7
  import asyncio
8
 
9
  from .awareness_engine import AwarenessEngine
10
- from .integration_manager import IntegrationManager
11
  from .dynamic_self_model import DynamicSelfModel
12
  from .experience_simulator import ExperienceSimulator
13
 
 
7
  import asyncio
8
 
9
  from .awareness_engine import AwarenessEngine
10
+ from .integration_manager import IntegrationManager, AwarenessState, IntegratedState, AwarenessLevel
11
  from .dynamic_self_model import DynamicSelfModel
12
  from .experience_simulator import ExperienceSimulator
13
 
src/core/experience_simulator.py CHANGED
@@ -1,13 +1,14 @@
1
- from typing import Dict, Any, List
2
  import numpy as np
 
3
 
4
  class PhenomenologyEngine:
5
  """Generates phenomenological states from awareness and integrated states."""
6
 
7
  async def generate_state(
8
  self,
9
- awareness: Dict[str, Any],
10
- integrated_state: Dict[str, Any]
11
  ) -> Dict[str, Any]:
12
  """
13
  Generate a phenomenological state from awareness and integrated state.
@@ -20,10 +21,10 @@ class PhenomenologyEngine:
20
  A dictionary containing the phenomenological state
21
  """
22
  return {
23
- "conscious_content": awareness.get("content", {}),
24
- "perceptual_field": awareness.get("perceptions", {}),
25
- "cognitive_state": integrated_state.get("cognitive", {}),
26
- "affective_tone": integrated_state.get("emotional", {})
27
  }
28
 
29
  class QualiaGenerator:
@@ -99,10 +100,23 @@ class ExperienceSimulator:
99
  self.qualia_generator = QualiaGenerator()
100
  self.temporal_integrator = TemporalIntegrator()
101
 
102
- async def simulate(self,
103
- awareness: Dict[str, Any],
104
- integrated_state: Dict[str, Any],
105
- self_model: Dict[str, Any]) -> Dict[str, Any]:
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  phenomenological_state = await self.phenomenology_engine.generate_state(
108
  awareness,
@@ -116,7 +130,7 @@ class ExperienceSimulator:
116
 
117
  temporal_context = await self.temporal_integrator.integrate(
118
  qualia,
119
- self_model['temporal_history']
120
  )
121
 
122
  return {
 
1
+ from typing import Dict, Any, List, Optional
2
  import numpy as np
3
+ from .integration_manager import AwarenessState, IntegratedState
4
 
5
  class PhenomenologyEngine:
6
  """Generates phenomenological states from awareness and integrated states."""
7
 
8
  async def generate_state(
9
  self,
10
+ awareness: AwarenessState,
11
+ integrated_state: IntegratedState
12
  ) -> Dict[str, Any]:
13
  """
14
  Generate a phenomenological state from awareness and integrated state.
 
21
  A dictionary containing the phenomenological state
22
  """
23
  return {
24
+ "conscious_content": getattr(awareness, "cognition_state", {}),
25
+ "perceptual_field": getattr(awareness, "perception_data", {}),
26
+ "cognitive_state": getattr(integrated_state, "cognitive_state", {}),
27
+ "affective_tone": {"valence": awareness.emotional_valence}
28
  }
29
 
30
  class QualiaGenerator:
 
100
  self.qualia_generator = QualiaGenerator()
101
  self.temporal_integrator = TemporalIntegrator()
102
 
103
+ async def simulate(
104
+ self,
105
+ awareness: AwarenessState,
106
+ integrated_state: IntegratedState,
107
+ self_model: Dict[str, Any]
108
+ ) -> Dict[str, Any]:
109
+ """
110
+ Simulate subjective experience based on awareness and integrated states.
111
+
112
+ Args:
113
+ awareness: The current awareness state
114
+ integrated_state: The integrated cognitive state
115
+ self_model: The agent's self-model state
116
+
117
+ Returns:
118
+ Dictionary containing the simulated subjective experience
119
+ """
120
 
121
  phenomenological_state = await self.phenomenology_engine.generate_state(
122
  awareness,
 
130
 
131
  temporal_context = await self.temporal_integrator.integrate(
132
  qualia,
133
+ self_model.get('temporal_history', [])
134
  )
135
 
136
  return {