Files
mayfly-go/server/internal/ai/memory/store.go
2026-04-21 17:22:21 +08:00

30 lines
1.1 KiB
Go
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.
package memory
import (
"context"
"time"
)
// MemoryItem 记忆项(长期记忆)
type MemoryItem struct {
ID string `json:"id"` // 唯一标识
UserID string `json:"userId"` // 用户ID
Type string `json:"type"` // 记忆类型: preference/fact/skill/experience
Content string `json:"content"` // 记忆内容(自然语言描述)
Tags []string `json:"tags"` // 标签,用于分类和检索
CreatedAt time.Time `json:"createdAt"` // 创建时间
UpdatedAt time.Time `json:"updatedAt"` // 更新时间
Metadata map[string]string `json:"metadata,omitempty"` // 元数据来源会话ID、提取时间等
}
// Store 记忆存储接口
type Store interface {
// 长期记忆操作
GetByUser(ctx context.Context, userID string, tags []string) ([]*MemoryItem, error)
Save(ctx context.Context, items []*MemoryItem) error
Delete(ctx context.Context, userID string, ids []string) error
// 向量检索(用于语义搜索)
Search(ctx context.Context, userID string, query string, limit int) ([]*MemoryItem, error)
}