Documentation
¶
Index ¶
- func WithCompactThreshold(n int) memoryConfigFunc
- func WithCompactTokenThreshold(n int) memoryConfigFunc
- func WithLongTermMemoryTTL(v time.Duration) memoryConfigFunc
- func WithShortTermMemoryTTL(v time.Duration) memoryConfigFunc
- type Conversation
- type TempMemory
- func (m *TempMemory) Append(rail miso.Rail, c Conversation) error
- func (m *TempMemory) Load(rail miso.Rail) (_longTerm string, shortTerm []Conversation, _err error)
- func (m *TempMemory) LoadFormatted(rail miso.Rail, lock bool) (_longTerm string, _shortTerm string, _err error)
- func (m *TempMemory) LoadLocked(rail miso.Rail) (_longTerm string, shortTerm []Conversation, _err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCompactThreshold ¶
func WithCompactThreshold(n int) memoryConfigFunc
WithCompactThreshold triggers memory compaction when the number of conversations is greater than or equal to n. On compaction all but the two most recent conversations are summarised and merged into long-term memory.
func WithCompactTokenThreshold ¶ added in v0.0.24
func WithCompactTokenThreshold(n int) memoryConfigFunc
WithCompactTokenThreshold triggers memory compaction when the total approximate token count of short-term memory reaches or exceeds n tokens. When triggered, the oldest conversations totaling approximately n/2 tokens are summarized and merged into long-term memory.
This option takes precedence over WithCompactThreshold when both are set.
func WithLongTermMemoryTTL ¶
Set long term memory TTL to v.
func WithShortTermMemoryTTL ¶
Set short term memory TTL to v.
Types ¶
type Conversation ¶
type TempMemory ¶
type TempMemory struct {
// contains filtered or unexported fields
}
func NewTempMemory ¶
func NewTempMemory(key string, agent *agents.MemorySummarizer, ops ...memoryConfigFunc) *TempMemory
NewTempMemory creates a TempMemory backed by Redis.
Default compaction policy: token-based at 4000 tokens (~4–6 typical customer-support exchanges). This threshold keeps recent detail without bloating the model's context window. On compaction the oldest conversations totalling ~2000 tokens are summarised and merged into long-term memory, leaving ~2000 tokens of recent context intact.
Override with WithCompactTokenThreshold (recommended) or WithCompactThreshold (round-based, legacy). Both the short-term and long-term stores default to a 30-day TTL.
func (*TempMemory) Append ¶
func (m *TempMemory) Append(rail miso.Rail, c Conversation) error
func (*TempMemory) Load ¶
func (m *TempMemory) Load(rail miso.Rail) (_longTerm string, shortTerm []Conversation, _err error)
func (*TempMemory) LoadFormatted ¶
func (*TempMemory) LoadLocked ¶
func (m *TempMemory) LoadLocked(rail miso.Rail) (_longTerm string, shortTerm []Conversation, _err error)