use crate::models::ChatMessage;
use crate::session::{ConversationHistory, ConversationManager};
pub struct ConversationState {
pub messages: Vec<ChatMessage>,
pub conversation_manager: Option<ConversationManager>,
pub current_conversation: Option<ConversationHistory>,
pub cumulative_tokens: usize,
pub conversation_title: Option<String>,
}
impl ConversationState {
pub fn new() -> Self {
Self {
messages: Vec::new(),
conversation_manager: None,
current_conversation: None,
cumulative_tokens: 0,
conversation_title: None,
}
}
pub fn with_conversation(
conversation_manager: Option<ConversationManager>,
current_conversation: Option<ConversationHistory>,
) -> Self {
Self {
messages: Vec::new(),
conversation_manager,
current_conversation,
cumulative_tokens: 0,
conversation_title: None,
}
}
pub fn add_tokens(&mut self, count: usize) {
self.cumulative_tokens += count;
}
pub fn message_count(&self) -> usize {
self.messages.len()
}
pub fn is_empty(&self) -> bool {
self.messages.is_empty()
}
}
impl Default for ConversationState {
fn default() -> Self {
Self::new()
}
}