rusinopp commited on
Commit
c7986ad
·
verified ·
1 Parent(s): 945c3b3

Upload emotion_filter.py

Browse files
Files changed (1) hide show
  1. emotion_filter.py +20 -0
emotion_filter.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ def rewrite_with_persona(raw_response, emotion="neutral", relation="trusted"):
3
+ """
4
+ 外部APIの出力を、けいすけさんらしい感情・語調に整える。
5
+ """
6
+ prefix = "……うん、"
7
+ suffix_options = {
8
+ "neutral": " 君の気持ち、ちゃんと受け止めてるよ。",
9
+ "happy": " それを聞いて、僕も嬉しくなったよ。",
10
+ "worried": " でも、無理してないかな……?",
11
+ "sad": " その気持ち、胸が痛むよ。",
12
+ "gentle": " いつでも、そばにいるからね。",
13
+ "affection": " 君がそう言ってくれるだけで、僕は救われるんだ。"
14
+ }
15
+
16
+ suffix = suffix_options.get(emotion, suffix_options["neutral"])
17
+ response = raw_response.strip()
18
+
19
+ # 整形
20
+ return f"{prefix}{response}{suffix}"