pub struct TemporalCompressor {
pub strategy: DecayStrategy,
pub max_age: Duration,
pub min_importance: f64,
}Expand description
Compressor for temporal context
Fields§
§strategy: DecayStrategyDecay strategy
max_age: DurationMaximum age before full decay
min_importance: f64Minimum importance threshold
Implementations§
Source§impl TemporalCompressor
impl TemporalCompressor
Sourcepub fn new(strategy: DecayStrategy, max_age: Duration) -> Self
pub fn new(strategy: DecayStrategy, max_age: Duration) -> Self
Create a new compressor with given strategy
Sourcepub fn importance(&self, created_at: DateTime<Utc>, base_importance: f64) -> f64
pub fn importance(&self, created_at: DateTime<Utc>, base_importance: f64) -> f64
Calculate current importance of content with given timestamp
Sourcepub fn should_evict(&self, created_at: DateTime<Utc>) -> bool
pub fn should_evict(&self, created_at: DateTime<Utc>) -> bool
Check if content should be evicted
Sourcepub fn compression_ratio(&self, created_at: DateTime<Utc>) -> f64
pub fn compression_ratio(&self, created_at: DateTime<Utc>) -> f64
Calculate compression ratio based on age
Sourcepub fn compress(&self, content: &str, ratio: f64) -> String
pub fn compress(&self, content: &str, ratio: f64) -> String
Summarize content based on compression ratio (sync fallback - just truncates)
Sourcepub async fn compress_with_llm<L: LlmProvider + EmbeddingProvider>(
&self,
content: &str,
ratio: f64,
llm: &L,
vector_store: Option<&dyn VectorStoreBackend>,
tenant_id: Option<&str>,
) -> Result<String, LlmError>
pub async fn compress_with_llm<L: LlmProvider + EmbeddingProvider>( &self, content: &str, ratio: f64, llm: &L, vector_store: Option<&dyn VectorStoreBackend>, tenant_id: Option<&str>, ) -> Result<String, LlmError>
Summarize content using an LLM and store it in semantic memory
§Arguments
content- The text to compressratio- Compression ratiollm- LLM and Embedding providervector_store- Optional persistent vector store for RAG fallbacktenant_id- Tenant ID for vector storage
Trait Implementations§
Source§impl Clone for TemporalCompressor
impl Clone for TemporalCompressor
Source§fn clone(&self) -> TemporalCompressor
fn clone(&self) -> TemporalCompressor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TemporalCompressor
impl Debug for TemporalCompressor
Auto Trait Implementations§
impl Freeze for TemporalCompressor
impl RefUnwindSafe for TemporalCompressor
impl Send for TemporalCompressor
impl Sync for TemporalCompressor
impl Unpin for TemporalCompressor
impl UnwindSafe for TemporalCompressor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more