Skip to content

feat: implement embodied EmotionEngine#543

Open
jhawpetoss6-collab wants to merge 1 commit into
Project-N-E-K-O:mainfrom
jhawpetoss6-collab:strike/emotion-state-engine
Open

feat: implement embodied EmotionEngine#543
jhawpetoss6-collab wants to merge 1 commit into
Project-N-E-K-O:mainfrom
jhawpetoss6-collab:strike/emotion-state-engine

Conversation

@jhawpetoss6-collab
Copy link
Copy Markdown

@jhawpetoss6-collab jhawpetoss6-collab commented Mar 24, 2026

This PR introduces the EmotionEngine to N.E.K.O., providing a state machine for the companion’s mood and affection levels (#neko).

Changes:

  • Added EmotionEngine in neko/core/emotion/.
  • Support for sentiment-based mood updates.
  • Logic for personality modifiers based on emotional state.

/claim #neko

Summary by CodeRabbit

发布说明

  • 新功能
    • 添加了情感识别和心情追踪系统,能够根据情感分析结果动态调整应用行为
    • 支持好感度管理,随着用户交互自动更新,影响应用的响应方式

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 24, 2026

总览喵

新增 EmotionEngine 类,用于管理情感状态。初始化心情为"中立"、好感度为50。process_sentiment() 方法根据情感得分更新心情和好感度,get_personality_modifiers() 方法返回相应的性格提示词修饰符喵~

变更喵

Cohort / File(s) 概要
情感引擎核心实现
neko/core/emotion/StateEngine.py
新增 EmotionEngine 类,包含心情和好感度状态管理,以及两个核心方法:process_sentiment() 根据阈值处理情感评分(>0.5为开心,<-0.5为伤心),get_personality_modifiers() 根据心情返回不同的提示词修饰符喵~

代码审查工作量评估喵

🎯 2 (Simple) | ⏱️ ~10 minutes

诗喵~

小情感引擎来报到呢~ 💕
心情和好感随意摇摇晃晃~
开心时蹦蹦跳,伤心时汪汪叫~
管理你的情绪小管家喵~✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题清晰准确地概括了主要变化——实现EmotionEngine类,与变更集内容完全相关。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
neko/core/emotion/StateEngine.py (1)

1-8: 初始化部分还行吧…勉强及格喵~

结构清晰,moodaffection 的初始值也合理喵。不过建议加个类型注解会更清楚喵,毕竟本喵可是很讲究代码质量的!

🐾 可选的类型注解改进喵
 class EmotionEngine:
     """
     Drives the embodied emotional engine for N.E.K.O.
     Processes user interaction sentiment to update the companion's mood state.
     """
-    def __init__(self):
-        self.mood = "neutral"
-        self.affection = 50 # 0-100
+    def __init__(self) -> None:
+        self.mood: str = "neutral"
+        self.affection: int = 50  # 0-100
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@neko/core/emotion/StateEngine.py` around lines 1 - 8, 在 EmotionEngine 的初始化方法
__init__ 中为属性添加类型注解以提高可读性和静态检查:为类 EmotionEngine 本身、实例属性 mood(str)和
affection(int,0-100)以及构造函数的返回类型(-> None)添加注解,并在必要时为类属性或参数添加 Docstring 或注释以说明
affection 的取值范围;确保引用符号为 EmotionEngine, __init__, mood, affection。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@neko/core/emotion/StateEngine.py`:
- Around line 19-23: The get_personality_modifiers method currently returns an
emoji-containing modifier for happy and a single default for others, which
conflicts with the character prompt rule "NO Emojis" and lacks differentiation
for sad; update get_personality_modifiers to remove any emojis from the happy
modifier (e.g., "Be cheerful and concise.") and add a distinct sad modifier
(e.g., "Be gentle, concise, and empathetic.") while keeping the neutral/default
as supportive and attentive; ensure the method name get_personality_modifiers
and the self.mood checks ("happy", "sad", "neutral") are used to locate and
implement these changes.

---

Nitpick comments:
In `@neko/core/emotion/StateEngine.py`:
- Around line 1-8: 在 EmotionEngine 的初始化方法 __init__ 中为属性添加类型注解以提高可读性和静态检查:为类
EmotionEngine 本身、实例属性 mood(str)和 affection(int,0-100)以及构造函数的返回类型(->
None)添加注解,并在必要时为类属性或参数添加 Docstring 或注释以说明 affection 的取值范围;确保引用符号为 EmotionEngine,
__init__, mood, affection。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 98b98b84-725f-401e-a775-cbacd8fc2fa5

📥 Commits

Reviewing files that changed from the base of the PR and between 915e18c and 7c380c0.

📒 Files selected for processing (1)
  • neko/core/emotion/StateEngine.py

Comment on lines +19 to +23
def get_personality_modifiers(self):
# Returns prompt modifiers based on current emotion
if self.mood == "happy":
return "Be cheerful and use emojis like ✨ and 🐾."
return "Be supportive and attentive."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

表情符号会和角色模板冲突喵!这都不检查一下的吗~

看看 config/prompts_chara.py:97 写的什么喵:

Format: Strictly speak in CONCISE spoken language. NO Emojis.

但是你这里 happy 状态返回的是 "Be cheerful and use emojis like ✨ and 🐾." 喵!这不是自相矛盾嘛,哼!

而且…只有 happy 有专门的 modifier,sad 和 neutral 都用同一个默认值,这样真的能体现情感差异吗喵?傲娇地说,至少应该给 sad 一个不同的 modifier 吧~

✨ 本喵大发慈悲给你的修复建议喵~
     def get_personality_modifiers(self):
         # Returns prompt modifiers based on current emotion
         if self.mood == "happy":
-            return "Be cheerful and use emojis like ✨ and 🐾."
-        return "Be supportive and attentive."
+            return "Be cheerful and express warmth in your responses."
+        elif self.mood == "sad":
+            return "Be gentle and comforting in your tone."
+        return "Be supportive and attentive."  # neutral default
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@neko/core/emotion/StateEngine.py` around lines 19 - 23, The
get_personality_modifiers method currently returns an emoji-containing modifier
for happy and a single default for others, which conflicts with the character
prompt rule "NO Emojis" and lacks differentiation for sad; update
get_personality_modifiers to remove any emojis from the happy modifier (e.g.,
"Be cheerful and concise.") and add a distinct sad modifier (e.g., "Be gentle,
concise, and empathetic.") while keeping the neutral/default as supportive and
attentive; ensure the method name get_personality_modifiers and the self.mood
checks ("happy", "sad", "neutral") are used to locate and implement these
changes.

@wehos
Copy link
Copy Markdown
Contributor

wehos commented Mar 25, 2026

This is a good idea but we needa find a better place for it (i.e., file structure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants