feat(ai-core): mood state machine and affection level
- new emotion package: rule-based sentiment (positive/negative lexicon) drives mood transitions (开心/平静/难过) with 30min inactivity decay; affection 0-100 grows with positive interaction, with 初识→熟悉→信赖→ 羁绊 tiers - pipeline records each user message and injects a mood line into the system prompt so the persona's tone follows her mood - mood changes broadcast over WS; frontend shows a mood badge with affection tooltip; also handles the 'reminder' message type from the reminder scheduler - tests: sentiment scoring, mood shift, affection bounds, prompt line, onChange callback
This commit is contained in:
1 parent
26d65dd6bb
commit
b8fb7feb86
8 files changed
+309
-3
No files matched your search
@@ -33,6 +33,7 @@ import (
|
||||
websearch "git.yeij.top/AskaEth/Cyrene_v2/plugins/web-search"
|
||||
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/services/ai-core/background"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/services/ai-core/emotion"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/services/ai-core/llm"
|
||||
llmlog "git.yeij.top/AskaEth/Cyrene_v2/services/ai-core/llm"
|
||||
tracepkg "git.yeij.top/AskaEth/Cyrene_v2/services/ai-core/trace"
|
||||
@@ -262,6 +263,11 @@ func main() {
|
||||
thinker.Start(context.Background())
|
||||
orch.SetPostChatHook(thinker.TriggerPostChat)
|
||||
|
||||
// === 12.6 Emotion tracker ===
|
||||
emotionTracker := emotion.NewTracker()
|
||||
orch.SetEmotionTracker(emotionTracker)
|
||||
logger.Infof("[emotion] tracker ready (mood=%s)", emotionTracker.Snapshot().Mood)
|
||||
|
||||
// === 12.6 Memory decay scheduler ===
|
||||
if memSvc != nil {
|
||||
go func() {
|
||||
@@ -307,6 +313,14 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
// Broadcast mood changes to web clients
|
||||
emotionTracker.OnChange(func(s emotion.Snapshot) {
|
||||
wsHub.Broadcast(map[string]any{
|
||||
"type": "mood", "mood": string(s.Mood),
|
||||
"intensity": s.Intensity, "affection": s.Affection,
|
||||
})
|
||||
})
|
||||
|
||||
// === 12.7 Automation engine ===
|
||||
autoEngine := engine.New(
|
||||
automationSourceAdapter{gwDeps.Automation},
|
||||
|
||||
Reference in new issue
Block a user