feat(ai-core): mood state machine and affection level
Cyrene CI / backend (push) Has been cancelled
Cyrene CI / frontend (push) Has been cancelled

- 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:
Aska committed 2026-08-21 18:13:23 +08:00
1 parent 26d65dd6bb
commit b8fb7feb86
8 files changed
+309 -3

No files matched your search

+10
View File
@@ -1,16 +1,24 @@
import { create } from 'zustand'
import type { Message, IotDevice } from '../types/chat'
interface MoodState {
mood: string
intensity: number
affection: number
}
interface ChatState {
messages: Message[]
isStreaming: boolean
currentSessionId: string | null
iotDevices: IotDevice[]
inputText: string
mood: MoodState | null
setInput: (text: string) => void
setSessionId: (id: string) => void
setMessages: (msgs: Message[]) => void
setMood: (m: MoodState) => void
addMessage: (msg: Message) => void
appendToLast: (content: string) => void
setStreaming: (v: boolean) => void
@@ -24,10 +32,12 @@ export const useChatStore = create<ChatState>((set, get) => ({
currentSessionId: null,
iotDevices: [],
inputText: '',
mood: null,
setInput: (text) => set({ inputText: text }),
setSessionId: (id) => set({ currentSessionId: id }),
setMessages: (msgs) => set({ messages: msgs }),
setMood: (m) => set({ mood: m }),
setStreaming: (v) => set({ isStreaming: v }),
setIotDevices: (d) => set({ iotDevices: d }),