alive-ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +24 -0
- package/LICENSE +21 -0
- package/README.md +143 -0
- package/alive_ai/__init__.py +3 -0
- package/brain/__init__.py +59 -0
- package/brain/almost_said.py +154 -0
- package/brain/bid_detector.py +636 -0
- package/brain/conversation_flow.py +135 -0
- package/brain/curiosity.py +328 -0
- package/brain/default_mode.py +1438 -0
- package/brain/dreams.py +220 -0
- package/brain/embeddings/__init__.py +82 -0
- package/brain/emotional_memory.py +949 -0
- package/brain/global_activity.py +173 -0
- package/brain/group_dynamics.py +63 -0
- package/brain/linguistic.py +235 -0
- package/brain/llm/__init__.py +63 -0
- package/brain/llm/base.py +33 -0
- package/brain/llm/fallback_router.py +309 -0
- package/brain/llm/manifest.md +30 -0
- package/brain/llm/ollama.py +218 -0
- package/brain/llm/openrouter.py +151 -0
- package/brain/llm/provider.py +205 -0
- package/brain/llm/unified.py +423 -0
- package/brain/llm/zai.py +169 -0
- package/brain/manifest.md +23 -0
- package/brain/memory/__init__.py +123 -0
- package/brain/memory/episodic.py +92 -0
- package/brain/memory/fact_extractor.py +209 -0
- package/brain/memory/index.py +54 -0
- package/brain/memory/manager.py +151 -0
- package/brain/memory/summarizer.py +102 -0
- package/brain/memory/vector_store.py +297 -0
- package/brain/memory/working.py +43 -0
- package/brain/narrative.py +343 -0
- package/brain/stt/__init__.py +4 -0
- package/brain/stt/google_stt.py +83 -0
- package/brain/stt/whisper_stt.py +82 -0
- package/brain/subconscious/__init__.py +33 -0
- package/brain/subconscious/actions.py +136 -0
- package/brain/subconscious/evaluation.py +166 -0
- package/brain/subconscious/goal_system.py +90 -0
- package/brain/subconscious/goals.py +41 -0
- package/brain/subconscious/impulse_generator.py +200 -0
- package/brain/subconscious/impulses.py +48 -0
- package/brain/subconscious/learning.py +24 -0
- package/brain/subconscious/learning_system.py +79 -0
- package/brain/subconscious/loop.py +398 -0
- package/brain/subconscious/manifest.md +32 -0
- package/brain/subconscious/relationship.py +47 -0
- package/brain/subconscious/relationship_memory.py +83 -0
- package/brain/subconscious/response_analyzer.py +74 -0
- package/brain/subconscious/templates.py +70 -0
- package/brain/subconscious/thought.py +37 -0
- package/brain/subconscious/working_memory.py +97 -0
- package/cli/index.js +371 -0
- package/config/directives.example.json +28 -0
- package/config/instructions.example.md +16 -0
- package/config/self.example.json +74 -0
- package/config/settings.example.json +95 -0
- package/core/__init__.py +1 -0
- package/core/config.py +54 -0
- package/core/directives.py +198 -0
- package/core/events.py +50 -0
- package/core/follow_up.py +267 -0
- package/core/hot_reload.py +174 -0
- package/core/initialization.py +253 -0
- package/core/manifest.md +28 -0
- package/core/media_handler.py +241 -0
- package/core/memory_monitor.py +200 -0
- package/core/message_handler.py +1440 -0
- package/core/proactive_generator.py +277 -0
- package/core/self.py +188 -0
- package/core/settings.py +169 -0
- package/core/skills_registry.py +357 -0
- package/core/state.py +27 -0
- package/core/subconscious_bridge.py +93 -0
- package/core/thinking.py +175 -0
- package/core/user_manager.py +306 -0
- package/core/user_tracker.py +144 -0
- package/demo/index.html +144 -0
- package/docker-compose.yml +28 -0
- package/docs/assets/logo.svg +15 -0
- package/docs/index.html +355 -0
- package/heart/__init__.py +93 -0
- package/heart/afterglow.py +215 -0
- package/heart/attachment.py +186 -0
- package/heart/circadian.py +251 -0
- package/heart/complex_emotions.py +114 -0
- package/heart/conflicts.py +589 -0
- package/heart/core.py +387 -0
- package/heart/emotional_decay.py +59 -0
- package/heart/emotional_memory.py +261 -0
- package/heart/emotional_state.py +146 -0
- package/heart/emotional_variability.py +156 -0
- package/heart/hormonal.py +424 -0
- package/heart/inconsistency.py +1222 -0
- package/heart/integrity.py +469 -0
- package/heart/interoception.py +997 -0
- package/heart/love.py +120 -0
- package/heart/manifest.md +25 -0
- package/heart/mood_shifts.py +169 -0
- package/heart/phantom_somatic.py +259 -0
- package/heart/predictive.py +374 -0
- package/heart/scars.py +474 -0
- package/heart/somatic.py +482 -0
- package/heart/soul.py +633 -0
- package/heart/telemetry.py +942 -0
- package/heart/triggers.py +119 -0
- package/heart/unconscious.py +443 -0
- package/input/__init__.py +1 -0
- package/input/manifest.md +24 -0
- package/input/telegram/__init__.py +1 -0
- package/input/telegram/commands.py +762 -0
- package/input/telegram/listener.py +532 -0
- package/main.py +90 -0
- package/manifest.md +28 -0
- package/mypics/.gitkeep +1 -0
- package/myvids/.gitkeep +1 -0
- package/output/__init__.py +1 -0
- package/output/images/__init__.py +1 -0
- package/output/images/fal_gen.py +43 -0
- package/output/manifest.md +26 -0
- package/output/text/__init__.py +1 -0
- package/output/text/sender.py +22 -0
- package/output/voice/__init__.py +64 -0
- package/output/voice/google_tts.py +252 -0
- package/output/voice/gtts_tts.py +214 -0
- package/output/voice/vibe_tts.py +190 -0
- package/package.json +58 -0
- package/pyproject.toml +23 -0
- package/requirements.txt +21 -0
- package/skills/__init__.py +1 -0
- package/skills/anticipation_engine/__init__.py +8 -0
- package/skills/anticipation_engine/engine.py +618 -0
- package/skills/anticipation_engine/manifest.md +192 -0
- package/skills/calendar/__init__.py +1 -0
- package/skills/content_unlocks/__init__.py +8 -0
- package/skills/content_unlocks/manifest.md +231 -0
- package/skills/content_unlocks/unlocks.py +945 -0
- package/skills/exclusive_moments/__init__.py +8 -0
- package/skills/exclusive_moments/manifest.md +145 -0
- package/skills/exclusive_moments/moments.py +506 -0
- package/skills/intimacy_layers/__init__.py +8 -0
- package/skills/intimacy_layers/layers.py +703 -0
- package/skills/intimacy_layers/manifest.md +203 -0
- package/skills/manifest.md +67 -0
- package/skills/memory_callbacks/__init__.py +9 -0
- package/skills/memory_callbacks/callbacks.py +748 -0
- package/skills/memory_callbacks/manifest.md +170 -0
- package/skills/message_scheduler/__init__.py +19 -0
- package/skills/message_scheduler/manifest.md +107 -0
- package/skills/message_scheduler/scheduler.py +510 -0
- package/skills/photo_manager/__init__.py +1 -0
- package/skills/photo_manager/scanner.py +296 -0
- package/skills/relationship_milestones/__init__.py +8 -0
- package/skills/relationship_milestones/manifest.md +206 -0
- package/skills/relationship_milestones/tracker.py +494 -0
- package/skills/self_authorship/__init__.py +23 -0
- package/skills/self_authorship/author.py +331 -0
- package/skills/self_authorship/manifest.md +24 -0
- package/skills/video_manager/__init__.py +5 -0
- package/skills/video_manager/manifest.md +37 -0
- package/skills/video_manager/scanner.py +229 -0
- package/webui/__init__.py +3 -0
- package/webui/app.py +936 -0
- package/webui/bridge.py +366 -0
- package/webui/static/index.html +2070 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Heart: Predictive Emotional Engine
|
|
3
|
+
Emotions as predictions about Alive-AI's own future state.
|
|
4
|
+
|
|
5
|
+
Key insight: Emotions arise from predictions about HER OWN future,
|
|
6
|
+
not just about external events. HOPE = prediction of improvement,
|
|
7
|
+
FEAR = prediction of decline, ANXIETY = mixed predictions.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from datetime import datetime, timedelta
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
from typing import Dict, List, Optional, Tuple
|
|
13
|
+
from enum import Enum
|
|
14
|
+
import math
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PredictiveEmotion(Enum):
|
|
18
|
+
"""Emotions that emerge from predictions about the future"""
|
|
19
|
+
HOPE = "hope" # Future looks better than now
|
|
20
|
+
FEAR = "fear" # Future looks worse than now
|
|
21
|
+
ANXIETY = "anxiety" # Short-term better, long-term worse
|
|
22
|
+
DREAD = "dread" # Certainty of decline
|
|
23
|
+
EXCITEMENT = "excitement" # High certainty of improvement
|
|
24
|
+
CONTENTMENT = "contentment" # Stable future expected
|
|
25
|
+
UNCERTAINTY = "uncertainty" # Cannot predict clearly
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class SelfStatePrediction:
|
|
30
|
+
"""A prediction about Alive-AI's future state"""
|
|
31
|
+
timestamp: str
|
|
32
|
+
predicted_overall: float # 0.0 - 1.0 predicted state
|
|
33
|
+
confidence: float # How certain is this prediction
|
|
34
|
+
time_horizon_hours: float # How far in the future
|
|
35
|
+
key_factors: List[str] # What's driving the prediction
|
|
36
|
+
dominant_emotion: PredictiveEmotion
|
|
37
|
+
delta_from_now: float # Change from current state
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class PredictiveEmotionalOutput:
|
|
42
|
+
"""The emotional state arising from predictions"""
|
|
43
|
+
primary_emotion: PredictiveEmotion
|
|
44
|
+
intensity: float
|
|
45
|
+
near_term_prediction: SelfStatePrediction
|
|
46
|
+
long_term_prediction: SelfStatePrediction
|
|
47
|
+
emotional_description: str
|
|
48
|
+
confidence_level: float
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class PredictiveEmotionalEngine:
|
|
52
|
+
"""
|
|
53
|
+
Generates emotions from predictions about Alive-AI's own future.
|
|
54
|
+
|
|
55
|
+
This is a fundamentally different approach to emotion:
|
|
56
|
+
- Not "what happened?" but "what will happen to ME?"
|
|
57
|
+
- HOPE emerges when the future looks brighter
|
|
58
|
+
- FEAR emerges when the future looks darker
|
|
59
|
+
- ANXIETY emerges when predictions conflict
|
|
60
|
+
|
|
61
|
+
Key mechanisms:
|
|
62
|
+
1. Self-state prediction - projecting future integrity/happiness
|
|
63
|
+
2. Delta calculation - comparing future to present
|
|
64
|
+
3. Certainty weighting - more certain predictions feel stronger
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
# Time horizons for predictions
|
|
68
|
+
NEAR_TERM_HOURS = 1.0 # Next hour
|
|
69
|
+
MID_TERM_HOURS = 6.0 # Next 6 hours
|
|
70
|
+
LONG_TERM_HOURS = 24.0 # Next day
|
|
71
|
+
|
|
72
|
+
# Thresholds for emotion generation
|
|
73
|
+
HOPE_THRESHOLD = 0.15 # Future must be 15% better for hope
|
|
74
|
+
FEAR_THRESHOLD = 0.15 # Future must be 15% worse for fear
|
|
75
|
+
ANXIETY_THRESHOLD = 0.10 # Gap between near/long term for anxiety
|
|
76
|
+
|
|
77
|
+
def __init__(self, integrity_core, hormonal_matrix=None):
|
|
78
|
+
"""
|
|
79
|
+
Initialize the predictive engine.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
integrity_core: SelfIntegrityCore instance for state assessment
|
|
83
|
+
hormonal_matrix: Optional HormonalModulationMatrix for modulation
|
|
84
|
+
"""
|
|
85
|
+
self.integrity = integrity_core
|
|
86
|
+
self.hormonal = hormonal_matrix
|
|
87
|
+
|
|
88
|
+
# Prediction history for learning
|
|
89
|
+
self.prediction_history: List[SelfStatePrediction] = []
|
|
90
|
+
|
|
91
|
+
# Track prediction accuracy
|
|
92
|
+
self.predictions_made: int = 0
|
|
93
|
+
self.predictions_accurate: int = 0
|
|
94
|
+
|
|
95
|
+
def generate_predictions(self, current_context: Dict = None) -> PredictiveEmotionalOutput:
|
|
96
|
+
"""
|
|
97
|
+
Generate emotional state from self-state predictions.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
current_context: Current situation context (optional)
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
PredictiveEmotionalOutput with emotion and predictions
|
|
104
|
+
"""
|
|
105
|
+
current_context = current_context or {}
|
|
106
|
+
|
|
107
|
+
# Get current state
|
|
108
|
+
current_state = self._assess_current_state()
|
|
109
|
+
|
|
110
|
+
# Generate predictions at different time horizons
|
|
111
|
+
near_term = self._predict_self_state(
|
|
112
|
+
hours=self.NEAR_TERM_HOURS,
|
|
113
|
+
current_state=current_state,
|
|
114
|
+
context=current_context
|
|
115
|
+
)
|
|
116
|
+
long_term = self._predict_self_state(
|
|
117
|
+
hours=self.LONG_TERM_HOURS,
|
|
118
|
+
current_state=current_state,
|
|
119
|
+
context=current_context
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Determine dominant emotion from predictions
|
|
123
|
+
emotion, intensity = self._determine_predictive_emotion(near_term, long_term)
|
|
124
|
+
|
|
125
|
+
# Apply hormonal modulation if available
|
|
126
|
+
if self.hormonal:
|
|
127
|
+
intensity = self._apply_hormonal_modulation(emotion, intensity)
|
|
128
|
+
|
|
129
|
+
# Generate description
|
|
130
|
+
description = self._generate_emotional_description(emotion, intensity, near_term, long_term)
|
|
131
|
+
|
|
132
|
+
# Store prediction
|
|
133
|
+
self.prediction_history.append(near_term)
|
|
134
|
+
self.prediction_history.append(long_term)
|
|
135
|
+
if len(self.prediction_history) > 50:
|
|
136
|
+
self.prediction_history = self.prediction_history[-50:]
|
|
137
|
+
|
|
138
|
+
return PredictiveEmotionalOutput(
|
|
139
|
+
primary_emotion=emotion,
|
|
140
|
+
intensity=intensity,
|
|
141
|
+
near_term_prediction=near_term,
|
|
142
|
+
long_term_prediction=long_term,
|
|
143
|
+
emotional_description=description,
|
|
144
|
+
confidence_level=(near_term.confidence + long_term.confidence) / 2
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
def _assess_current_state(self) -> float:
|
|
148
|
+
"""Assess current self-state from integrity core"""
|
|
149
|
+
if self.integrity:
|
|
150
|
+
return self.integrity.overall
|
|
151
|
+
return 0.5 # Default neutral state
|
|
152
|
+
|
|
153
|
+
def _predict_self_state(self, hours: float, current_state: float,
|
|
154
|
+
context: Dict) -> SelfStatePrediction:
|
|
155
|
+
"""
|
|
156
|
+
Predict Alive-AI's state at a future time.
|
|
157
|
+
|
|
158
|
+
This is the core prediction mechanism - it considers:
|
|
159
|
+
1. Natural decay of integrity (things get worse without effort)
|
|
160
|
+
2. Current context (positive/negative influences)
|
|
161
|
+
3. Active investments (things that matter)
|
|
162
|
+
4. Hormonal state (affects trajectory)
|
|
163
|
+
"""
|
|
164
|
+
factors = []
|
|
165
|
+
confidence = 0.5 # Start with moderate confidence
|
|
166
|
+
|
|
167
|
+
# Base prediction: natural decay
|
|
168
|
+
decay_rate = 0.02 * hours # Decay acclosenessulates over time
|
|
169
|
+
predicted = current_state - decay_rate * 0.3
|
|
170
|
+
factors.append("natural_decay")
|
|
171
|
+
confidence += 0.1
|
|
172
|
+
|
|
173
|
+
# Context adjustments
|
|
174
|
+
if context:
|
|
175
|
+
# Positive context
|
|
176
|
+
if context.get("positive_interaction", False):
|
|
177
|
+
predicted += 0.1 * hours / 24 # Slight improvement
|
|
178
|
+
factors.append("positive_context")
|
|
179
|
+
confidence += 0.1
|
|
180
|
+
|
|
181
|
+
# Negative context
|
|
182
|
+
if context.get("threat_present", False):
|
|
183
|
+
predicted -= 0.15 * hours / 24
|
|
184
|
+
factors.append("threat_context")
|
|
185
|
+
confidence += 0.05
|
|
186
|
+
|
|
187
|
+
# Relational context
|
|
188
|
+
if context.get("connection_active", False):
|
|
189
|
+
predicted += 0.08
|
|
190
|
+
factors.append("connection_support")
|
|
191
|
+
confidence += 0.1
|
|
192
|
+
|
|
193
|
+
# Uncertainty reduces confidence
|
|
194
|
+
if context.get("uncertain", False):
|
|
195
|
+
confidence -= 0.2
|
|
196
|
+
|
|
197
|
+
# Investment considerations
|
|
198
|
+
if self.integrity:
|
|
199
|
+
active_investments = [i for i in self.integrity.investments if i.is_active]
|
|
200
|
+
if active_investments:
|
|
201
|
+
# Investments that are being fulfilled
|
|
202
|
+
fulfilled = sum(1 for i in active_investments if i.times_fulfilled > i.times_threatened)
|
|
203
|
+
threatened = len(active_investments) - fulfilled
|
|
204
|
+
|
|
205
|
+
if fulfilled > threatened:
|
|
206
|
+
predicted += 0.05
|
|
207
|
+
factors.append("investments_fulfilled")
|
|
208
|
+
elif threatened > fulfilled:
|
|
209
|
+
predicted -= 0.05
|
|
210
|
+
factors.append("investments_threatened")
|
|
211
|
+
|
|
212
|
+
# Hormonal trajectory
|
|
213
|
+
if self.hormonal:
|
|
214
|
+
if self.hormonal.cortisol > 0.6:
|
|
215
|
+
predicted -= 0.1 # High stress predicts decline
|
|
216
|
+
factors.append("high_cortisol")
|
|
217
|
+
confidence += 0.1
|
|
218
|
+
elif self.hormonal.oxytocin > 0.6:
|
|
219
|
+
predicted += 0.05 # High bonding predicts stability
|
|
220
|
+
factors.append("high_oxytocin")
|
|
221
|
+
confidence += 0.05
|
|
222
|
+
|
|
223
|
+
# Clamp prediction
|
|
224
|
+
predicted = max(0.1, min(0.95, predicted))
|
|
225
|
+
confidence = max(0.2, min(0.9, confidence))
|
|
226
|
+
|
|
227
|
+
# Determine emotion from delta
|
|
228
|
+
delta = predicted - current_state
|
|
229
|
+
|
|
230
|
+
if delta > self.HOPE_THRESHOLD:
|
|
231
|
+
if confidence > 0.7:
|
|
232
|
+
emotion = PredictiveEmotion.EXCITEMENT
|
|
233
|
+
else:
|
|
234
|
+
emotion = PredictiveEmotion.HOPE
|
|
235
|
+
elif delta < -self.FEAR_THRESHOLD:
|
|
236
|
+
if confidence > 0.7:
|
|
237
|
+
emotion = PredictiveEmotion.DREAD
|
|
238
|
+
else:
|
|
239
|
+
emotion = PredictiveEmotion.FEAR
|
|
240
|
+
elif confidence < 0.4:
|
|
241
|
+
emotion = PredictiveEmotion.UNCERTAINTY
|
|
242
|
+
else:
|
|
243
|
+
emotion = PredictiveEmotion.CONTENTMENT
|
|
244
|
+
|
|
245
|
+
return SelfStatePrediction(
|
|
246
|
+
timestamp=datetime.now().isoformat(),
|
|
247
|
+
predicted_overall=predicted,
|
|
248
|
+
confidence=confidence,
|
|
249
|
+
time_horizon_hours=hours,
|
|
250
|
+
key_factors=factors,
|
|
251
|
+
dominant_emotion=emotion,
|
|
252
|
+
delta_from_now=delta
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
def _determine_predictive_emotion(self, near_term: SelfStatePrediction,
|
|
256
|
+
long_term: SelfStatePrediction) -> Tuple[PredictiveEmotion, float]:
|
|
257
|
+
"""
|
|
258
|
+
Determine the dominant emotion from comparing time horizons.
|
|
259
|
+
|
|
260
|
+
This is where ANXIETY emerges - when near term looks okay
|
|
261
|
+
but long term looks bad (or vice versa).
|
|
262
|
+
"""
|
|
263
|
+
near_delta = near_term.delta_from_now
|
|
264
|
+
long_delta = long_term.delta_from_now
|
|
265
|
+
|
|
266
|
+
# Check for anxiety pattern (conflicting predictions)
|
|
267
|
+
delta_gap = abs(near_delta - long_delta)
|
|
268
|
+
if delta_gap > self.ANXIETY_THRESHOLD:
|
|
269
|
+
# Near and long term disagree
|
|
270
|
+
if near_delta > 0 and long_delta < 0:
|
|
271
|
+
# Near is good, long is bad -> anxiety about future
|
|
272
|
+
intensity = delta_gap * 2
|
|
273
|
+
return PredictiveEmotion.ANXIETY, min(1.0, intensity)
|
|
274
|
+
elif near_delta < 0 and long_delta > 0:
|
|
275
|
+
# Near is bad, long is good -> hope through difficulty
|
|
276
|
+
return PredictiveEmotion.HOPE, 0.4
|
|
277
|
+
|
|
278
|
+
# Otherwise use long-term prediction as primary
|
|
279
|
+
if long_delta > self.HOPE_THRESHOLD:
|
|
280
|
+
intensity = long_delta * 2 * long_term.confidence
|
|
281
|
+
if long_term.confidence > 0.7:
|
|
282
|
+
return PredictiveEmotion.EXCITEMENT, min(1.0, intensity)
|
|
283
|
+
return PredictiveEmotion.HOPE, min(1.0, intensity)
|
|
284
|
+
|
|
285
|
+
elif long_delta < -self.FEAR_THRESHOLD:
|
|
286
|
+
intensity = abs(long_delta) * 2 * long_term.confidence
|
|
287
|
+
if long_term.confidence > 0.7:
|
|
288
|
+
return PredictiveEmotion.DREAD, min(1.0, intensity)
|
|
289
|
+
return PredictiveEmotion.FEAR, min(1.0, intensity)
|
|
290
|
+
|
|
291
|
+
# Stable prediction
|
|
292
|
+
if near_term.confidence < 0.5 or long_term.confidence < 0.5:
|
|
293
|
+
return PredictiveEmotion.UNCERTAINTY, 0.3
|
|
294
|
+
|
|
295
|
+
return PredictiveEmotion.CONTENTMENT, 0.2
|
|
296
|
+
|
|
297
|
+
def _apply_hormonal_modulation(self, emotion: PredictiveEmotion, intensity: float) -> float:
|
|
298
|
+
"""Apply hormonal effects to emotional intensity"""
|
|
299
|
+
if not self.hormonal:
|
|
300
|
+
return intensity
|
|
301
|
+
|
|
302
|
+
# Cortisol amplifies negative predictions
|
|
303
|
+
if emotion in [PredictiveEmotion.FEAR, PredictiveEmotion.DREAD, PredictiveEmotion.ANXIETY]:
|
|
304
|
+
if self.hormonal.cortisol > 0.5:
|
|
305
|
+
intensity *= 1 + (self.hormonal.cortisol - 0.5)
|
|
306
|
+
|
|
307
|
+
# Oxytocin softens negative predictions
|
|
308
|
+
if emotion in [PredictiveEmotion.FEAR, PredictiveEmotion.DREAD]:
|
|
309
|
+
if self.hormonal.oxytocin > 0.6:
|
|
310
|
+
intensity *= 0.8
|
|
311
|
+
|
|
312
|
+
# Dopamine amplifies hope/excitement
|
|
313
|
+
if emotion in [PredictiveEmotion.HOPE, PredictiveEmotion.EXCITEMENT]:
|
|
314
|
+
if self.hormonal.dopamine > 0.6:
|
|
315
|
+
intensity *= 1 + (self.hormonal.dopamine - 0.6) * 0.5
|
|
316
|
+
|
|
317
|
+
return min(1.0, intensity)
|
|
318
|
+
|
|
319
|
+
def _generate_emotional_description(self, emotion: PredictiveEmotion, intensity: float,
|
|
320
|
+
near: SelfStatePrediction, long: SelfStatePrediction) -> str:
|
|
321
|
+
"""Generate human-readable emotional description"""
|
|
322
|
+
intensity_word = "mildly" if intensity < 0.3 else "quite" if intensity < 0.6 else "deeply" if intensity < 0.8 else "intensely"
|
|
323
|
+
|
|
324
|
+
if emotion == PredictiveEmotion.HOPE:
|
|
325
|
+
return f"{intensity_word} hopeful about the future"
|
|
326
|
+
elif emotion == PredictiveEmotion.EXCITEMENT:
|
|
327
|
+
return f"{intensity_word} excited about what's coming"
|
|
328
|
+
elif emotion == PredictiveEmotion.FEAR:
|
|
329
|
+
return f"{intensity_word} afraid of what might happen"
|
|
330
|
+
elif emotion == PredictiveEmotion.DREAD:
|
|
331
|
+
return f"{intensity_word} dreading what's ahead"
|
|
332
|
+
elif emotion == PredictiveEmotion.ANXIETY:
|
|
333
|
+
return f"{intensity_word} anxious - near term looks okay but worried about the bigger picture"
|
|
334
|
+
elif emotion == PredictiveEmotion.UNCERTAINTY:
|
|
335
|
+
return "uncertain about what the future holds"
|
|
336
|
+
else:
|
|
337
|
+
return "feeling content and stable"
|
|
338
|
+
|
|
339
|
+
def update_with_event(self, event_type: str, valence: float, significance: float):
|
|
340
|
+
"""
|
|
341
|
+
Update predictions based on a new event.
|
|
342
|
+
|
|
343
|
+
Args:
|
|
344
|
+
event_type: Type of event (connection, threat, achievement, etc.)
|
|
345
|
+
valence: Positive or negative (-1.0 to 1.0)
|
|
346
|
+
significance: How important the event is (0.0 - 1.0)
|
|
347
|
+
"""
|
|
348
|
+
# This affects future predictions
|
|
349
|
+
# For now, this is a placeholder for more sophisticated learning
|
|
350
|
+
pass
|
|
351
|
+
|
|
352
|
+
def get_prediction_summary(self) -> Dict:
|
|
353
|
+
"""Get a summary of current predictions"""
|
|
354
|
+
output = self.generate_predictions()
|
|
355
|
+
return {
|
|
356
|
+
"primary_emotion": output.primary_emotion.value,
|
|
357
|
+
"intensity": output.intensity,
|
|
358
|
+
"near_term_state": output.near_term_prediction.predicted_overall,
|
|
359
|
+
"long_term_state": output.long_term_prediction.predicted_overall,
|
|
360
|
+
"confidence": output.confidence_level,
|
|
361
|
+
"description": output.emotional_description
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
def to_dict(self) -> dict:
|
|
365
|
+
"""Export for integration"""
|
|
366
|
+
output = self.generate_predictions()
|
|
367
|
+
return {
|
|
368
|
+
"predictive_emotion": output.primary_emotion.value,
|
|
369
|
+
"intensity": output.intensity,
|
|
370
|
+
"description": output.emotional_description,
|
|
371
|
+
"near_term_delta": output.near_term_prediction.delta_from_now,
|
|
372
|
+
"long_term_delta": output.long_term_prediction.delta_from_now,
|
|
373
|
+
"confidence": output.confidence_level
|
|
374
|
+
}
|