69 lines
2.2 KiB
Go
69 lines
2.2 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
// MemoryPriority 记忆优先级
|
|
type MemoryPriority int
|
|
|
|
const (
|
|
MemoryTemp MemoryPriority = 0 // 临时记忆 (会话内)
|
|
MemoryNormal MemoryPriority = 1 // 普通记忆
|
|
MemoryImportant MemoryPriority = 2 // 重要记忆
|
|
MemoryCore MemoryPriority = 3 // 核心记忆 (永远保留)
|
|
)
|
|
|
|
// String 返回优先级的中文描述
|
|
func (p MemoryPriority) String() string {
|
|
switch p {
|
|
case MemoryCore:
|
|
return "核心"
|
|
case MemoryImportant:
|
|
return "重要"
|
|
case MemoryNormal:
|
|
return "普通"
|
|
case MemoryTemp:
|
|
return "临时"
|
|
default:
|
|
return "未知"
|
|
}
|
|
}
|
|
|
|
// MemoryCategory 记忆分类
|
|
type MemoryCategory string
|
|
|
|
const (
|
|
CategoryPreference MemoryCategory = "preference" // 喜好/偏好
|
|
CategoryFact MemoryCategory = "fact" // 事实信息
|
|
CategoryEvent MemoryCategory = "event" // 事件/经历
|
|
CategoryRelationship MemoryCategory = "relationship" // 关系/情感
|
|
CategoryHabit MemoryCategory = "habit" // 习惯
|
|
CategoryOther MemoryCategory = "other" // 其他
|
|
)
|
|
|
|
// MemoryEntry 记忆条目
|
|
type MemoryEntry struct {
|
|
ID string `json:"id" db:"id"`
|
|
UserID string `json:"user_id" db:"user_id"`
|
|
Content string `json:"content" db:"content"`
|
|
Summary string `json:"summary" db:"summary"` // 简短摘要
|
|
Category MemoryCategory `json:"category" db:"category"`
|
|
Priority MemoryPriority `json:"priority" db:"priority"`
|
|
SessionID string `json:"session_id" db:"session_id"` // 来源会话
|
|
Source string `json:"source" db:"source"` // 来源文本片断
|
|
Embedding []float32 `json:"-" db:"embedding"` // 向量 (pgvector)
|
|
AccessCount int `json:"access_count" db:"access_count"`
|
|
LastAccess time.Time `json:"last_access" db:"last_access"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
ExpiresAt *time.Time `json:"expires_at,omitempty" db:"expires_at"` // 临时记忆过期时间
|
|
}
|
|
|
|
// MemoryQuery 记忆查询参数
|
|
type MemoryQuery struct {
|
|
UserID string
|
|
Query string // 查询文本
|
|
Category MemoryCategory
|
|
Priority MemoryPriority
|
|
Limit int
|
|
Offset int
|
|
}
|