pub struct UnifiedMemorySystem { /* private fields */ }Expand description
统一记忆系统
整合 Working, Session, Project, LongTerm 四层记忆。
Implementations§
Source§impl UnifiedMemorySystem
impl UnifiedMemorySystem
Sourcepub fn with_project(self, project: Arc<dyn MemoryStore>) -> Self
pub fn with_project(self, project: Arc<dyn MemoryStore>) -> Self
设置项目记忆存储
Sourcepub fn with_long_term(self, long_term: Arc<dyn MemoryStore>) -> Self
pub fn with_long_term(self, long_term: Arc<dyn MemoryStore>) -> Self
设置长期记忆存储
Sourcepub fn working(&self) -> &WorkingMemory
pub fn working(&self) -> &WorkingMemory
获取工作记忆
Sourcepub fn session(&self) -> &SessionMemory
pub fn session(&self) -> &SessionMemory
获取会话记忆
Sourcepub async fn store_at(
&self,
tier: MemoryTier,
content: impl Into<String>,
) -> Layer3Result<String>
pub async fn store_at( &self, tier: MemoryTier, content: impl Into<String>, ) -> Layer3Result<String>
存储到指定层级
Sourcepub async fn query_all(
&self,
query: &MemoryQuery,
) -> Layer3Result<Vec<MemoryEntry>>
pub async fn query_all( &self, query: &MemoryQuery, ) -> Layer3Result<Vec<MemoryEntry>>
跨层级查询
按 Working -> Session -> Project -> LongTerm 顺序查询
Sourcepub async fn stats(&self) -> Layer3Result<HashMap<MemoryTier, usize>>
pub async fn stats(&self) -> Layer3Result<HashMap<MemoryTier, usize>>
获取层级统计
Sourcepub async fn clear_tier(&self, tier: MemoryTier) -> Layer3Result<usize>
pub async fn clear_tier(&self, tier: MemoryTier) -> Layer3Result<usize>
清空指定层级
Trait Implementations§
Source§impl MemorySystem for UnifiedMemorySystem
MemorySystem trait 实现
impl MemorySystem for UnifiedMemorySystem
MemorySystem trait 实现
Source§fn store<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
content: String,
) -> Pin<Box<dyn Future<Output = Layer3Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
content: String,
) -> Pin<Box<dyn Future<Output = Layer3Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
存储记忆到指定层级
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<Option<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<Option<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
从指定层级获取记忆
Source§fn query_all<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query_all<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
跨层级查询记忆 Read more
Source§fn query<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
在指定层级查询
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
删除指定层级记忆
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
) -> Pin<Box<dyn Future<Output = Layer3Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
) -> Pin<Box<dyn Future<Output = Layer3Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
清空指定层级
Auto Trait Implementations§
impl !RefUnwindSafe for UnifiedMemorySystem
impl !UnwindSafe for UnifiedMemorySystem
impl Freeze for UnifiedMemorySystem
impl Send for UnifiedMemorySystem
impl Sync for UnifiedMemorySystem
impl Unpin for UnifiedMemorySystem
impl UnsafeUnpin for UnifiedMemorySystem
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more