Documentation
¶
Overview ¶
Package memory 实现 Golem 的记忆管理系统,包括长期记忆 (MEMORY.md) 和基于日记的短期记忆。
Index ¶
- type DiaryEntry
- type Manager
- func (m *Manager) AppendDiary(entry string) (string, error)
- func (m *Manager) AppendDiaryAt(ts time.Time, entry string) (string, error)
- func (m *Manager) Ensure() error
- func (m *Manager) ReadDiary(date string) (string, error)
- func (m *Manager) ReadLongTerm() (string, error)
- func (m *Manager) ReadRecentDiaries(limit int) ([]DiaryEntry, error)
- func (m *Manager) RecallContext(query string, recentLimit, keywordLimit int) (RecallResult, error)
- func (m *Manager) WriteLongTerm(content string) error
- type RecallItem
- type RecallResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiaryEntry ¶
type DiaryEntry struct {
Date string // 日期 (YYYY-MM-DD)
Path string // 文件路径
Content string // 分录内容
}
DiaryEntry 表示单条日记分录。
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 负责管理工作区内的记忆文件读写与上下文召回。
func (*Manager) AppendDiary ¶
AppendDiary 在当前日期的日记文件中追加一条记录。
func (*Manager) AppendDiaryAt ¶
AppendDiaryAt 在指定时间的日记文件中追加一条记录。
func (*Manager) ReadLongTerm ¶
ReadLongTerm 读取长期记忆文件的全文内容。
func (*Manager) ReadRecentDiaries ¶
func (m *Manager) ReadRecentDiaries(limit int) ([]DiaryEntry, error)
ReadRecentDiaries 读取最近几天的日记分录。
func (*Manager) RecallContext ¶ added in v0.5.0
func (m *Manager) RecallContext(query string, recentLimit, keywordLimit int) (RecallResult, error)
RecallContext 使用“最近优先 + 关键词命中”策略从记忆中检索相关的上下文片段。
func (*Manager) WriteLongTerm ¶
WriteLongTerm 覆盖写入长期记忆文件。
type RecallItem ¶ added in v0.5.0
type RecallItem struct {
Source string // 来源(如 "diary_recent", "long_term")
Date string // 关联日期(可选)
Path string // 来源文件路径
Excerpt string // 摘录内容
}
RecallItem 表示带来源归属的单条回忆片段。
type RecallResult ¶ added in v0.5.0
type RecallResult struct {
Query string // 原始查询
RecallCount int // 召回的总片段数
SourceHits map[string]int // 各来源的命中统计
Items []RecallItem // 召回的具体片段列表
}
RecallResult 总结了上下文回忆的质量和来源分布。
Click to show internal directories.
Click to hide internal directories.