pub struct LLMCompactor { /* private fields */ }Expand description
LLM-based compactor that summarizes older conversation using an LLM. It replaces older messages with a single summary message while preserving recent turns.
Implementations§
Source§impl LLMCompactor
impl LLMCompactor
Sourcepub fn new(
client: LLMClient,
config: LLMCompactorConfig,
) -> Result<Self, CompactorConfigError>
pub fn new( client: LLMClient, config: LLMCompactorConfig, ) -> Result<Self, CompactorConfigError>
Trait Implementations§
Source§impl AsyncCompactor for LLMCompactor
impl AsyncCompactor for LLMCompactor
Source§fn compact_async<'a>(
&'a self,
conversation: Vec<Message>,
_compact_summaries: &'a HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<Message>, CompactionResult), CompactionError>> + Send + 'a>>
fn compact_async<'a>( &'a self, conversation: Vec<Message>, _compact_summaries: &'a HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<(Vec<Message>, CompactionResult), CompactionError>> + Send + 'a>>
Performs async compaction that may involve LLM calls.
Returns the new conversation and compaction statistics. Read more
Source§impl Compactor for LLMCompactor
impl Compactor for LLMCompactor
Source§fn should_compact(&self, context_used: i64, context_limit: i32) -> bool
fn should_compact(&self, context_used: i64, context_limit: i32) -> bool
Returns true if compaction should occur before this LLM call. Read more
Auto Trait Implementations§
impl Freeze for LLMCompactor
impl !RefUnwindSafe for LLMCompactor
impl Send for LLMCompactor
impl Sync for LLMCompactor
impl Unpin for LLMCompactor
impl !UnwindSafe for LLMCompactor
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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