Skip to main content

LongTermMemory

Trait LongTermMemory 

Source
pub trait LongTermMemory: Send + Sync {
    // Required methods
    fn remember<'life0, 'async_trait>(
        &'life0 self,
        scope: Scope,
        fact: Fact,
    ) -> Pin<Box<dyn Future<Output = Result<FactId, MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn recall<'life0, 'life1, 'async_trait>(
        &'life0 self,
        scope: Scope,
        query: &'life1 str,
        k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Fact>, MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn forget<'life0, 'async_trait>(
        &'life0 self,
        id: FactId,
    ) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Long-term semantic memory.

use klieo_core::test_utils::InMemoryLongTerm;
use klieo_core::{Fact, LongTermMemory, Scope};

let m = InMemoryLongTerm::default();
let scope = Scope::Workspace("ws".into());
m.remember(scope.clone(), Fact::new("the sky is blue")).await.unwrap();
let hits = m.recall(scope, "sky", 1).await.unwrap();
assert_eq!(hits.len(), 1);

Required Methods§

Source

fn remember<'life0, 'async_trait>( &'life0 self, scope: Scope, fact: Fact, ) -> Pin<Box<dyn Future<Output = Result<FactId, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a fact under scope. Returns a stable id.

Source

fn recall<'life0, 'life1, 'async_trait>( &'life0 self, scope: Scope, query: &'life1 str, k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Fact>, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Top-k semantic recall under scope for the supplied query.

Source

fn forget<'life0, 'async_trait>( &'life0 self, id: FactId, ) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a stored fact.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§