from core.codex_informer import CodexInformer from core.eil_processor import EILProcessor from core.esil_inference import ESILInference from core.eris_reasoner import ERISReasoner from core.hei_inference import HEIInference from core.fec_controller import FECController import yaml def run_pipeline(user_input_text, force_hei=False): print("\n--- MEC MVP Test Run ---") print(f"[Main] Pipeline Input: {user_input_text}") # Load Response Strategies YAML with open('config/response_strategies.yaml', 'r', encoding='utf-8') as f: response_strategies = yaml.safe_load(f)['response_strategies'] # 1️⃣ CodexInformer and EIL Processor (handles both normalization and emotion processing) codex_informer = CodexInformer() eil = EILProcessor(codex_informer) # Run emotion inference eil_packet = eil.infer_emotion(user_input_text) print(f"[Main] EIL Packet Output: {eil_packet}") # 2️⃣ ESIL Inference esil = ESILInference(codex_informer) esil_packet = esil.infer_esil(eil_packet) # 3️⃣ Forced HEI Mode: Ensure it forces the low confidence path if True if force_hei: print("\n[Main] FORCE HEI MODE ENABLED — Routing to HEI Inference") esil_packet['confidence_score'] = 0.40 # force low confidence to trigger HEI print(f"[Main] ESIL Packet Output: {esil_packet}") # Routing logic: if esil_packet['confidence_score'] >= 0.65: print("\n[Main] Routing: proceed_to_eris") # 4️⃣ ERIS Reasoning (Final UESP Creation) eris = ERISReasoner() final_uesp = eris.reason_emotion_state(esil_packet) print(f"[Main] ERIS Packet Output: {final_uesp}") # 5️⃣ FEC Controller (Final Fusion Prompt) fec = FECController() fusion_prompt = fec.generate_prompt(final_uesp) print(f"[Main] Final Fusion Prompt:\n{fusion_prompt}") # 6️⃣ Simulated Empathic Response fam_code = final_uesp.get('primary_emotion_code') or final_uesp.get('Primary Emotion Code') rsm_code = response_strategies.get(fam_code, {}).get('rsm_code', 'RSM-UNKNOWN') strategy_name = response_strategies.get(fam_code, {}).get('strategy', 'Strategy not defined') sample_response = response_strategies.get(fam_code, {}).get('sample_response', 'No response available') simulated_output = ( f"Response Strategy Code: {rsm_code}\n" f"Response Strategy: {strategy_name}\n\n" f"{sample_response}" ) print(f"\n[Main] Simulated Empathic Response:\n{simulated_output}") elif esil_packet['confidence_score'] < 0.65: print("\n[Main] Routing: escalate_to_hei") # 6️⃣ Trigger HEI Inference (Fallback for Low Confidence) hei = HEIInference() pseudo_esil = hei.detect_low_signal(esil_packet) print(f"[Main] Pseudo-ESIL Output:\n{pseudo_esil}") # 7️⃣ Post-HEI Path: Continue to ERIS → UESP → FEC print("\n[Main] Continuing to ERIS Reasoner (Post-HEI Path)") eris = ERISReasoner() final_uesp = eris.reason_emotion_state(pseudo_esil) print(f"[Main] ERIS Packet Output: {final_uesp}") fec = FECController() fusion_prompt = fec.generate_prompt(final_uesp) print(f"[Main] Final Fusion Prompt:\n{fusion_prompt}") # 8️⃣ Simulated Empathic Response fam_code = final_uesp.get('primary_emotion_code') or final_uesp.get('Primary Emotion Code') rsm_code = response_strategies.get(fam_code, {}).get('rsm_code', 'RSM-UNKNOWN') strategy_name = response_strategies.get(fam_code, {}).get('strategy', 'Strategy not defined') sample_response = response_strategies.get(fam_code, {}).get('sample_response', 'No response available') simulated_output = ( f"Response Strategy Code: {rsm_code}\n" f"Response Strategy: {strategy_name}\n\n" f"{sample_response}" ) print(f"\n[Main] Simulated Empathic Response:\n{simulated_output}") else: print("\n[Main] Routing: LLM Assist — Not implemented") if __name__ == "__main__": # Example input that matches a SAL Trigger: test_input = "I am feeling joy" # Run in FORCE HEI mode → set to True to test Symbolic Layer run_pipeline(test_input, force_hei=False)