rivapereira123 commited on
Commit
61a5c8e
·
verified ·
1 Parent(s): 8e6feb9

Create ludus_chat.py

Browse files
Files changed (1) hide show
  1. ludus_chat.py +25 -0
ludus_chat.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def should_soften_response(response: str, emotions: list) -> bool:
2
+ short = len(response.strip()) < 8
3
+ unsure = any(e[0] in ["confusion", "fear", "nervousness"] for e in emotions)
4
+ vague = response.strip().lower() in ["idk", "not sure", "nah", "maybe", "hmm"]
5
+ return short or unsure or vague
6
+
7
+ def build_reflection(user_input, emotions, memory=None):
8
+ base_emotion = emotions[0][0] if emotions else "something soft"
9
+ intro = random.choice([
10
+ f"What I hear is… there's a sense of {base_emotion}.",
11
+ f"Your words carry a feeling of {base_emotion}.",
12
+ f"It feels like you're gently holding something {base_emotion}-tinged."
13
+ ])
14
+
15
+ memory_tag = ""
16
+ if memory:
17
+ memory_tag = f"\nEarlier you mentioned feeling **{memory}**… does that still linger?"
18
+
19
+ follow_up = random.choice([
20
+ "Would you say this comes from past experience?",
21
+ "Can you tell me what makes that feel so true?",
22
+ "No rush — you can describe it however feels easiest.",
23
+ ])
24
+
25
+ return f"{intro}{memory_tag}\n{follow_up}"