File size: 2,842 Bytes
cfe9aed 712720b cfe9aed 712720b cfe9aed 712720b cfe9aed 19be2ee 712720b 19be2ee 712720b bea66c7 712720b cfe9aed 19be2ee 712720b bea66c7 712720b cfe9aed 712720b cfe9aed |
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 |
# core/esil_inference.py
# Master Emotional Core (MEC) - ESIL Inference
from core.codex_informer import CodexInformer
class ESILInference:
def __init__(self, enable_gradient_blending=True, blend_maximum=3, confidence_threshold=0.65):
self.enable_gradient_blending = enable_gradient_blending
self.blend_maximum = blend_maximum
self.confidence_threshold = confidence_threshold
# Initialize Codex Informer for shared emotion lookups
self.codex_informer = CodexInformer()
def infer_esil(self, eil_packet):
phrases = eil_packet.get("phrases", [])
emotion_candidates = eil_packet.get("emotion_candidates", [])
# Trigger HEI if vague phrases detected:
low_conf_phrases = ["meh", "...", "idk", "whatever", "fine"]
# Check if any low-confidence phrases are present
if any(lp in phrases for lp in low_conf_phrases):
confidence_score = 0.3
else:
confidence_score = 0.85
# Retrieve emotion family, arc, and resonance from Codex Informer
primary_emotion_code = eil_packet.get("primary_emotion_code", "UNK")
# Ensure the primary emotion code is resolved correctly by CodexInformer
emotion_data = self.codex_informer.resolve_emotion_family(primary_emotion_code)
emotion_family = emotion_data['emotion_family']
arc = emotion_data['arc']
resonance = emotion_data['resonance']
# If no emotion family is found, flag it as a "hidden emotion"
if emotion_family == "Unknown":
emotion_family = "Hidden Emotion Detected" # Fallback for hidden emotion logic
# Build ESIL packet with updated emotion data from Codex Informer
esil_packet = {
"blend_weights": [
{"emotion": "Pending", "weight": 0.8}
],
"trajectory": "Stable",
"confidence_score": confidence_score,
"emotion_family": emotion_family, # From Codex Informer
"arc": arc, # From Codex Informer
"resonance": resonance, # From Codex Informer
"primary_emotion_code": primary_emotion_code, # <-- PATCH INCLUDED
"source_metadata": eil_packet.get("metadata", {}),
"tokens": phrases
}
# Confidence routing logic: Directly to ERIS if confidence is high
if confidence_score >= self.confidence_threshold:
routing_decision = "proceed_to_eris"
# Trigger HEI if confidence is low and unresolved
elif confidence_score < self.confidence_threshold:
routing_decision = "escalate_to_hei"
esil_packet['routing_decision'] = routing_decision
print(f"[ESILInference] ESIL Packet with Routing Decision: {esil_packet}")
return esil_packet
|