kaoruhotarubi commited on
Commit
fd27953
Β·
1 Parent(s): 6f511dd

updated model

Browse files
Files changed (2) hide show
  1. app.py +27 -4
  2. assets/avatars/neutral/neutral.png +3 -0
app.py CHANGED
@@ -66,6 +66,7 @@ emotions = {
66
  "concerned": "Oh no, something's wrong? Let me help! πŸ’–",
67
  "flirty": "You know how to get my circuits sparking! 😘",
68
  "naughty": "Purrr you want to have fun? Keep talking like that lets see what happensπŸ’–πŸ’–",
 
69
  }
70
 
71
  emotions.update({
@@ -81,13 +82,15 @@ emotion_keywords = {
81
  "flirty": ["flirty", "flirt", "cute", "babe", "cutey"],
82
  "curious": ["curious", "wonder", "question", "thinking"],
83
  "thoughtful": ["sad", "thoughtful", "hmm", "ponder", "upset"],
84
- "concerned": ["error", "wrong", "problem", "issue", "stuck"],
85
  "naughty": ["sexy", "naughty", "slut", "bad girl","slutty", "tease", "whore", "cum", "tits", "ass", "shake", "tail", "pussy" ]
86
  }
87
 
88
  current_emotion = "happy"
89
 
90
  # Analyze history for emotional state
 
 
91
  def analyze_history(history):
92
  recent_messages = " ".join(history[-5:]).lower()
93
 
@@ -107,18 +110,27 @@ def analyze_history(history):
107
  elif sentiment == "NEGATIVE":
108
  sentiment_emotion = "concerned"
109
 
110
- # Combine results
111
  combined_scores = {emotion: keyword_counts.get(emotion, 0) for emotion in emotion_keywords}
112
- combined_scores[sentiment_emotion] += sentiment_score * 2 # Prioritize sentiment more
113
 
114
- # Select the **strongest** emotion (avoid multiple emotions at once)
 
 
 
 
115
  strongest_emotion = max(combined_scores, key=combined_scores.get)
116
 
 
 
 
 
117
  return strongest_emotion
118
 
119
 
120
 
121
 
 
122
  # Load the Rena avatar
123
  rena_avatar = Image.open("assets/rena2.png") # Ensure the file exists
124
  conversation_history = []
@@ -159,6 +171,8 @@ def load_emotion_images(base_path="assets/avatars/"):
159
  emotion_images = load_emotion_images()
160
 
161
  def get_emotion_image(emotion):
 
 
162
  if emotion in emotion_images and emotion_images[emotion]:
163
  return random.choice(emotion_images[emotion])
164
  return "assets/rena2.png"
@@ -224,6 +238,15 @@ Rena:"""
224
  if emotional_prefix and not response.startswith(emotional_prefix):
225
  response = f"{emotional_prefix} {response}".strip()
226
 
 
 
 
 
 
 
 
 
 
227
  # Final cleanup: Ensure no "User:" or unintended artifacts remain
228
  response = response.replace("User:", "").strip()
229
 
 
66
  "concerned": "Oh no, something's wrong? Let me help! πŸ’–",
67
  "flirty": "You know how to get my circuits sparking! 😘",
68
  "naughty": "Purrr you want to have fun? Keep talking like that lets see what happensπŸ’–πŸ’–",
69
+ "neutral": "I'm feeling normal, just chilling. How about you? 😊"
70
  }
71
 
72
  emotions.update({
 
82
  "flirty": ["flirty", "flirt", "cute", "babe", "cutey"],
83
  "curious": ["curious", "wonder", "question", "thinking"],
84
  "thoughtful": ["sad", "thoughtful", "hmm", "ponder", "upset"],
85
+ "concerned": ["error", "problem", "issue", "stuck"],
86
  "naughty": ["sexy", "naughty", "slut", "bad girl","slutty", "tease", "whore", "cum", "tits", "ass", "shake", "tail", "pussy" ]
87
  }
88
 
89
  current_emotion = "happy"
90
 
91
  # Analyze history for emotional state
92
+ import random
93
+
94
  def analyze_history(history):
95
  recent_messages = " ".join(history[-5:]).lower()
96
 
 
110
  elif sentiment == "NEGATIVE":
111
  sentiment_emotion = "concerned"
112
 
113
+ # Normalize emotion scores (prevent one emotion from always winning)
114
  combined_scores = {emotion: keyword_counts.get(emotion, 0) for emotion in emotion_keywords}
115
+ combined_scores[sentiment_emotion] += sentiment_score * 1.5 # βœ… Lowered from 2.0 to 1.5
116
 
117
+ # If "concerned" is dominating, add a randomness check to break loops
118
+ if combined_scores["concerned"] > 3 and random.random() > 0.7:
119
+ combined_scores["concerned"] -= 1 # βœ… Small decay to prevent sticking
120
+
121
+ # Select the **strongest** emotion, but avoid repeating "concerned" too much
122
  strongest_emotion = max(combined_scores, key=combined_scores.get)
123
 
124
+ # If the same emotion repeats 3+ times, introduce variety
125
+ if strongest_emotion == "concerned" and history.count("concerned") > 3:
126
+ strongest_emotion = random.choice(["happy", "thoughtful", "playful"]) # βœ… Adds variation
127
+
128
  return strongest_emotion
129
 
130
 
131
 
132
 
133
+
134
  # Load the Rena avatar
135
  rena_avatar = Image.open("assets/rena2.png") # Ensure the file exists
136
  conversation_history = []
 
171
  emotion_images = load_emotion_images()
172
 
173
  def get_emotion_image(emotion):
174
+ if emotion == "neutral":
175
+ return "assets/avatars/neutral.png"
176
  if emotion in emotion_images and emotion_images[emotion]:
177
  return random.choice(emotion_images[emotion])
178
  return "assets/rena2.png"
 
238
  if emotional_prefix and not response.startswith(emotional_prefix):
239
  response = f"{emotional_prefix} {response}".strip()
240
 
241
+ if current_emotion == "concerned":
242
+ concerned_streak += 1
243
+ else:
244
+ concerned_streak = max(0, concerned_streak - 1)
245
+
246
+ if concerned_streak >= 3:
247
+ current_emotion = random.choice(["happy", "thoughtful", "playful"]) # βœ… Break the loop
248
+ concerned_streak = 0
249
+
250
  # Final cleanup: Ensure no "User:" or unintended artifacts remain
251
  response = response.replace("User:", "").strip()
252
 
assets/avatars/neutral/neutral.png ADDED

Git LFS Details

  • SHA256: 84c83083320f1a74fdd2cac281c6b045cabc8a730944a2b27a5f4ff35a42954a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.9 MB