pub struct ConversationHistory {
pub turns: Vec<ConversationTurn>,
pub compacted: Vec<CompactedTurn>,
pub max_turns: usize,
}Expand description
Conversation history.
Fields§
§turns: Vec<ConversationTurn>Conversation turns.
compacted: Vec<CompactedTurn>Compacted (summarized) history.
max_turns: usizeMaximum turns to keep before compacting.
Implementations§
Source§impl ConversationHistory
impl ConversationHistory
Sourcepub fn recent(&self, n: usize) -> &[ConversationTurn]
pub fn recent(&self, n: usize) -> &[ConversationTurn]
Returns the most recent N turns.
Sourcepub fn search(&self, keyword: &str) -> Vec<&ConversationTurn>
pub fn search(&self, keyword: &str) -> Vec<&ConversationTurn>
Searches turns by keyword.
Sourcepub fn in_range(&self, start_ms: u64, end_ms: u64) -> Vec<&ConversationTurn>
pub fn in_range(&self, start_ms: u64, end_ms: u64) -> Vec<&ConversationTurn>
Filters turns by time range.
Sourcepub fn compact(&mut self, summarizer: impl Fn(&[ConversationTurn]) -> String)
pub fn compact(&mut self, summarizer: impl Fn(&[ConversationTurn]) -> String)
Compacts old turns using the provided summarizer.
If the number of turns exceeds max_turns, older turns are
summarized and moved to compacted.
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 · 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 ConversationHistory
impl Debug for ConversationHistory
Source§impl Default for ConversationHistory
impl Default for ConversationHistory
Source§fn default() -> ConversationHistory
fn default() -> ConversationHistory
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ConversationHistory
impl<'de> Deserialize<'de> for ConversationHistory
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ConversationHistory
impl RefUnwindSafe for ConversationHistory
impl Send for ConversationHistory
impl Sync for ConversationHistory
impl Unpin for ConversationHistory
impl UnsafeUnpin for ConversationHistory
impl UnwindSafe for ConversationHistory
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