Changeset 0.30.1 (#200)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit is contained in:
@@ -285,3 +285,36 @@ func (s *MemoryStore) UpsertExtractionLog(ctx context.Context, channelID, userID
|
||||
`, store.NewID(), channelID, userID, lastMessageID, count)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── v0.30.1 — Memory Compaction ────────────────────────────────────────
|
||||
|
||||
func (s *MemoryStore) DecayConfidence(ctx context.Context, olderThan string, decayFactor float64) (int, error) {
|
||||
res, err := DB.ExecContext(ctx, `
|
||||
UPDATE memories
|
||||
SET confidence = confidence * ?,
|
||||
updated_at = datetime('now')
|
||||
WHERE status = 'active'
|
||||
AND updated_at < ?
|
||||
AND confidence > 0.1
|
||||
`, decayFactor, olderThan)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
n, _ := res.RowsAffected()
|
||||
return int(n), nil
|
||||
}
|
||||
|
||||
func (s *MemoryStore) Prune(ctx context.Context, belowConfidence float64) (int, error) {
|
||||
res, err := DB.ExecContext(ctx, `
|
||||
UPDATE memories
|
||||
SET status = 'archived',
|
||||
updated_at = datetime('now')
|
||||
WHERE status = 'active'
|
||||
AND confidence < ?
|
||||
`, belowConfidence)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
n, _ := res.RowsAffected()
|
||||
return int(n), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user