File size: 564 Bytes
05b9f96
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
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})"