pub struct ConversationHistory { /* private fields */ }Expand description
Conversation history manager with compaction support
Implementations§
Source§impl ConversationHistory
impl ConversationHistory
pub fn new() -> Self
Sourcepub fn with_threshold(
max_context_tokens: usize,
threshold_fraction: f32,
) -> Self
pub fn with_threshold( max_context_tokens: usize, threshold_fraction: f32, ) -> Self
Create with custom compression threshold
Sourcepub fn add_turn(
&mut self,
user_message: String,
assistant_response: String,
tool_calls: Vec<ToolCallRecord>,
)
pub fn add_turn( &mut self, user_message: String, assistant_response: String, tool_calls: Vec<ToolCallRecord>, )
Add a new conversation turn
Sourcepub fn needs_compaction(&self) -> bool
pub fn needs_compaction(&self) -> bool
Check if compaction is needed
Sourcepub fn token_count(&self) -> usize
pub fn token_count(&self) -> usize
Get current token count
Sourcepub fn turn_count(&self) -> usize
pub fn turn_count(&self) -> usize
Get number of turns
Sourcepub fn compact(&mut self) -> Option<String>
pub fn compact(&mut self) -> Option<String>
Perform compaction - summarize older turns and keep recent ones Returns the summary that was created (for logging/display)
Sourcepub fn to_messages(&self) -> Vec<Message>
pub fn to_messages(&self) -> Vec<Message>
Convert history to Rig Message format for the agent
Trait Implementations§
Source§impl Clone for ConversationHistory
impl Clone for ConversationHistory
Source§fn clone(&self) -> ConversationHistory
fn clone(&self) -> ConversationHistory
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConversationHistory
impl Debug for ConversationHistory
Auto Trait Implementations§
impl Freeze for ConversationHistory
impl RefUnwindSafe for ConversationHistory
impl Send for ConversationHistory
impl Sync for ConversationHistory
impl Unpin for ConversationHistory
impl UnwindSafe for ConversationHistory
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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> 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