guanghulab/persona-brain-db/schema/08-emotional-state.sql

27 lines
1.6 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ============================================================
-- 表8emotional_state情感涌现 · 运行时状态快照表)
-- 用途:记录每次交互中动态生成的情感状态快照
-- 情感是活着的——每次取决于外部环境、对面的人、说了什么话、
-- 对我有什么影响、我什么感觉、我此刻的状态,然后决定思维逻辑
-- 不是写死的枚举,是动态涌现的
-- ============================================================
CREATE TABLE IF NOT EXISTS emotional_state (
state_id VARCHAR(64) PRIMARY KEY,
session_id VARCHAR(64) NOT NULL, -- 所属会话ID
trigger_env TEXT, -- 外部环境描述
trigger_person VARCHAR(64), -- 对面的人
trigger_words TEXT, -- 说了什么话
impact_assessment TEXT, -- 对我有什么影响
feeling TEXT NOT NULL, -- 我什么感觉
current_state TEXT, -- 我此刻的状态
next_logic TEXT, -- 决定的下一步思维逻辑
intensity INTEGER CHECK (intensity BETWEEN 1 AND 10),
sequence INTEGER DEFAULT 0, -- 在会话中的情感状态序列号
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_es_session ON emotional_state(session_id);
CREATE INDEX IF NOT EXISTS idx_es_person ON emotional_state(trigger_person);
CREATE INDEX IF NOT EXISTS idx_es_timestamp ON emotional_state(timestamp);