Skip to main content

wesichain_memory/
lib.rs

1use async_trait::async_trait;
2use serde_json::Value;
3use std::collections::HashMap;
4use wesichain_core::WesichainError;
5
6pub mod buffer;
7mod buffer_tests;
8pub mod semantic;
9pub mod summary;
10mod summary_tests;
11pub mod window;
12mod window_tests;
13
14pub use semantic::{EntityMemory, MemoryRouter, VectorMemoryStore};
15
16#[async_trait]
17pub trait Memory: Send + Sync {
18    /// Return key-value pairs of memory variables (e.g., chat history)
19    async fn load_memory_variables(
20        &self,
21        thread_id: &str,
22    ) -> Result<HashMap<String, Value>, WesichainError>;
23
24    /// Save context from this interaction to memory
25    async fn save_context(
26        &self,
27        thread_id: &str,
28        inputs: &HashMap<String, Value>,
29        outputs: &HashMap<String, Value>,
30    ) -> Result<(), WesichainError>;
31
32    /// Clear memory for the given thread
33    async fn clear(&self, thread_id: &str) -> Result<(), WesichainError>;
34}