TTOPM's picture
Upload 945 files
05b9f96 verified
Raw History Blame Contribute Delete
564 Bytes
from typing import List, Tuple
from .emotions import classify
def generate_reply(history:List[Tuple[str,str,str]], user_text:str, persona:str, emotion_hint:str=None)->str:
label,_=classify(user_text)
mood=emotion_hint or label
style={"sad":"gentle","nervous":"calm","anxious":"soothing","angry":"steady",
"frustrated":"reassuring","happy":"warm","excited":"enthusiastic","neutral":"clear"}.get(mood,"clear")
return f"I’m here with you, in a {style} way. You said: “{user_text}”. Let’s move forward together. (persona={persona})"