mec-functional-empathy-demo / core /fec_controller.py
ThreatLevelD
Launch frontend demo: Implemented live MEC MVP demo with dynamic emotion processing
7b8b1dc
class FECController:
def __init__(self):
pass
def generate_prompt(self, final_uesp):
# Validate required keys
required_keys = [
'emotion_family',
'primary_emotion_code',
'emotion_arc_trajectory',
'resonance_pattern'
]
for key in required_keys:
if key not in final_uesp:
raise KeyError(f"Missing required key: {key}")
# Map human-readable emotion label from code
emotion_code = final_uesp['primary_emotion_code']
if emotion_code.startswith("VAR-"):
emotion_label = emotion_code.replace("VAR-", "").split('-')[0].title()
elif emotion_code.startswith("FAM-"):
emotion_label = emotion_code.replace("FAM-", "").title()
else:
emotion_label = "Unknown"
# Base fields
arc = final_uesp['emotion_arc_trajectory']
resonance = final_uesp['resonance_pattern']
# Optional fields with fallbacks
blend_states = final_uesp.get('blend_states', 'None detected')
response_strategy = final_uesp.get('response_strategy', 'RSM-DEFAULT')
tone_classification = final_uesp.get('tone_classification', 'TBD')
# Build Fusion Prompt
fusion_prompt = f"""
Contextual Emotional State:
- Primary Emotion: {emotion_label}
- Emotional Arc: {arc}
- Resonance: {resonance}
- Tone: {tone_classification}
- Blend States: {blend_states}
- Intervention Strategy: {response_strategy}
Empathic Objective:
Align your response tone and content with the above emotional context. Prioritize emotional authenticity, HEART-compliant care, and safety. Do not merely reflect emotion — respond in an emotionally aligned and supportive manner that honors the user’s lived experience.
HEART Compliance: Response must align with HEART™ ethical principles — transparency, alignment, contextuality, traceability, and emotional safety.
""".strip()
return fusion_prompt