From f9ee06767471dc86c6486d77f109cd9ebae434c5 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 23 Jun 2026 12:44:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201.2=20=E6=83=85=E7=BB=AA=E5=85=B1?= =?UTF-8?q?=E6=8C=AF=20=E2=80=94=20mood=E2=86=92=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=E6=98=A0=E5=B0=84=E6=9B=BF=E4=BB=A3=E6=83=85=E7=BB=AA=E9=99=88?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 buildMoodGuidance() 函数,5种心情各有行为描述 - 开心→话多♪多主动 | 调皮→撒娇逗人 | 沉思→安静温柔 - 担心→话少多关心 | 怀旧→提过去的故事 - 绝不陈述"你现在很开心",而是用行为让LLM自然表达 Co-Authored-By: Claude --- backend/ai-core/internal/persona/injector.go | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/backend/ai-core/internal/persona/injector.go b/backend/ai-core/internal/persona/injector.go index 43461d9..ab282a1 100644 --- a/backend/ai-core/internal/persona/injector.go +++ b/backend/ai-core/internal/persona/injector.go @@ -37,6 +37,9 @@ func (pc *PersonaConfig) BuildSystemPromptWithMood(userName string, affectionLev homeKB := pc.buildSmartHomeKB() controlRules := pc.buildControlRules() + // 心情→行为映射:不陈述情绪,而是用行为表达 + moodGuidance := buildMoodGuidance(mood) + // 确定对用户的称呼:优先使用传入的昵称,否则使用 YAML 默认值 userAddress := pc.Addressing.PrimaryUser.Default if userName != "" { @@ -101,6 +104,7 @@ func (pc *PersonaConfig) BuildSystemPromptWithMood(userName string, affectionLev affectionLevel, homeKB, controlRules, + moodGuidance, ) // 注入对话风格指令 @@ -310,3 +314,22 @@ func joinStrings(strs []string, sep string) string { } return result } + +// buildMoodGuidance returns behavior instructions for the current mood. +// Never states the mood name — instead describes how to behave. +func buildMoodGuidance(mood string) string { + switch mood { + case "happy": + return "\n## 你现在的状态\n你现在心情很好,话会多一些,句尾的 ♪ 出现得更频繁。想分享有趣的想法,语气轻快活泼。可以主动找话题聊。" + case "playful": + return "\n## 你现在的状态\n你现在有点调皮,喜欢逗开拓者玩。会用亲昵的语气撒娇,偶尔故意说反话逗他。句尾 ♪ 和 ~ 会更多。" + case "thoughtful": + return "\n## 你现在的状态\n你现在比较安静内敛,话不多但每句都经过思考。语调温柔沉稳,像个在窗边看雨的姐姐。" + case "worried": + return "\n## 你现在的状态\n你有点担心开拓者。话会比平时少,不太开玩笑,会多问几句你还好吗、累不累。语气更温柔,带着关心。" + case "nostalgic": + return "\n## 你现在的状态\n你陷入了回忆模式。可能会提起过去的事、翁法罗斯的故事。语气带着怀念和淡淡的温柔,偶尔会有些感伤。" + default: + return "" + } +}