pub struct Session {
pub key: String,
pub messages: Vec<ChatMessage>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub metadata: Value,
pub last_consolidated: usize,
}Expand description
A conversation session
Fields§
§key: StringSession key (channel:chat_id)
messages: Vec<ChatMessage>Messages in the session
created_at: DateTime<Utc>Session creation time
updated_at: DateTime<Utc>Last update time
metadata: ValueSession metadata
last_consolidated: usizeIndex of last consolidated message (for memory consolidation)
Implementations§
Source§impl Session
impl Session
Sourcepub fn add_message(
&mut self,
role: impl Into<String>,
content: impl Into<String>,
)
pub fn add_message( &mut self, role: impl Into<String>, content: impl Into<String>, )
Add a message to the session
Sourcepub fn add_full_message(&mut self, msg: ChatMessage)
pub fn add_full_message(&mut self, msg: ChatMessage)
Add a complete ChatMessage to the session
Sourcepub fn get_history(&self, max_messages: usize) -> Vec<ChatMessage>
pub fn get_history(&self, max_messages: usize) -> Vec<ChatMessage>
Get message history for LLM context
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
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 Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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