rexis_rag/agent/memory/
config.rs1use crate::storage::Memory;
4use std::sync::Arc;
5
6#[derive(Clone)]
8pub struct MemoryConfig {
9 pub backend: Arc<dyn Memory>,
11
12 pub agent_id: String,
14
15 pub session_id: Option<String>,
17
18 pub persist_conversations: bool,
20
21 pub enable_semantic: bool,
23
24 pub enable_episodic: bool,
26
27 pub enable_working: bool,
29
30 pub max_conversation_length: usize,
32
33 pub auto_generate_session_id: bool,
35}
36
37impl MemoryConfig {
38 pub fn new(backend: Arc<dyn Memory>, agent_id: impl Into<String>) -> Self {
40 Self {
41 backend,
42 agent_id: agent_id.into(),
43 session_id: None,
44 persist_conversations: false,
45 enable_semantic: false,
46 enable_episodic: false,
47 enable_working: false,
48 max_conversation_length: 50,
49 auto_generate_session_id: true,
50 }
51 }
52
53 pub fn with_session_id(mut self, session_id: impl Into<String>) -> Self {
55 self.session_id = Some(session_id.into());
56 self
57 }
58
59 pub fn with_persistence(mut self, persist: bool) -> Self {
61 self.persist_conversations = persist;
62 self
63 }
64
65 pub fn with_semantic_memory(mut self, enable: bool) -> Self {
67 self.enable_semantic = enable;
68 self
69 }
70
71 pub fn with_episodic_memory(mut self, enable: bool) -> Self {
73 self.enable_episodic = enable;
74 self
75 }
76
77 pub fn with_working_memory(mut self, enable: bool) -> Self {
79 self.enable_working = enable;
80 self
81 }
82
83 pub fn with_max_conversation_length(mut self, length: usize) -> Self {
85 self.max_conversation_length = length;
86 self
87 }
88
89 pub fn with_auto_session_id(mut self, auto: bool) -> Self {
91 self.auto_generate_session_id = auto;
92 self
93 }
94}
95
96impl Default for MemoryConfig {
97 fn default() -> Self {
98 use crate::storage::InMemoryStorage;
99
100 Self {
101 backend: Arc::new(InMemoryStorage::new()),
102 agent_id: "default".to_string(),
103 session_id: None,
104 persist_conversations: false,
105 enable_semantic: false,
106 enable_episodic: false,
107 enable_working: false,
108 max_conversation_length: 50,
109 auto_generate_session_id: true,
110 }
111 }
112}