use crate::storage::Memory;
use std::sync::Arc;
#[derive(Clone)]
pub struct MemoryConfig {
pub backend: Arc<dyn Memory>,
pub agent_id: String,
pub session_id: Option<String>,
pub persist_conversations: bool,
pub enable_semantic: bool,
pub enable_episodic: bool,
pub enable_working: bool,
pub max_conversation_length: usize,
pub auto_generate_session_id: bool,
}
impl MemoryConfig {
pub fn new(backend: Arc<dyn Memory>, agent_id: impl Into<String>) -> Self {
Self {
backend,
agent_id: agent_id.into(),
session_id: None,
persist_conversations: false,
enable_semantic: false,
enable_episodic: false,
enable_working: false,
max_conversation_length: 50,
auto_generate_session_id: true,
}
}
pub fn with_session_id(mut self, session_id: impl Into<String>) -> Self {
self.session_id = Some(session_id.into());
self
}
pub fn with_persistence(mut self, persist: bool) -> Self {
self.persist_conversations = persist;
self
}
pub fn with_semantic_memory(mut self, enable: bool) -> Self {
self.enable_semantic = enable;
self
}
pub fn with_episodic_memory(mut self, enable: bool) -> Self {
self.enable_episodic = enable;
self
}
pub fn with_working_memory(mut self, enable: bool) -> Self {
self.enable_working = enable;
self
}
pub fn with_max_conversation_length(mut self, length: usize) -> Self {
self.max_conversation_length = length;
self
}
pub fn with_auto_session_id(mut self, auto: bool) -> Self {
self.auto_generate_session_id = auto;
self
}
}
impl Default for MemoryConfig {
fn default() -> Self {
use crate::storage::InMemoryStorage;
Self {
backend: Arc::new(InMemoryStorage::new()),
agent_id: "default".to_string(),
session_id: None,
persist_conversations: false,
enable_semantic: false,
enable_episodic: false,
enable_working: false,
max_conversation_length: 50,
auto_generate_session_id: true,
}
}
}