pub struct MemoryCompressor { /* private fields */ }Expand description
Memory compressor
Implementations§
Source§impl MemoryCompressor
impl MemoryCompressor
Sourcepub fn new(storage: Arc<dyn Memory>, config: CompressionConfig) -> Self
pub fn new(storage: Arc<dyn Memory>, config: CompressionConfig) -> Self
Create a new memory compressor
Sourcepub fn needs_compression(&self, stats: &MemoryStats) -> bool
pub fn needs_compression(&self, stats: &MemoryStats) -> bool
Check if compression is needed based on stats
Sourcepub async fn calculate_stats(&self, namespace: &str) -> RragResult<MemoryStats>
pub async fn calculate_stats(&self, namespace: &str) -> RragResult<MemoryStats>
Calculate memory statistics for a namespace
Sourcepub async fn compress_conversation_memory(
&self,
namespace: &str,
llm_client: &Client,
keep_recent_count: usize,
) -> RragResult<usize>
Available on crate feature rexis-llm-client only.
pub async fn compress_conversation_memory( &self, namespace: &str, llm_client: &Client, keep_recent_count: usize, ) -> RragResult<usize>
rexis-llm-client only.Compress conversation memory by summarizing old messages (requires ‘rsllm-client’ feature)
Sourcepub async fn remove_old_items(
&self,
namespace: &str,
older_than: DateTime<Utc>,
) -> RragResult<usize>
pub async fn remove_old_items( &self, namespace: &str, older_than: DateTime<Utc>, ) -> RragResult<usize>
Remove old items based on timestamp
Sourcepub async fn remove_least_important(
&self,
namespace: &str,
min_importance: f64,
max_to_remove: usize,
) -> RragResult<usize>
pub async fn remove_least_important( &self, namespace: &str, min_importance: f64, max_to_remove: usize, ) -> RragResult<usize>
Remove least important items
Auto Trait Implementations§
impl Freeze for MemoryCompressor
impl !RefUnwindSafe for MemoryCompressor
impl Send for MemoryCompressor
impl Sync for MemoryCompressor
impl Unpin for MemoryCompressor
impl !UnwindSafe for MemoryCompressor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more