Skip to main content

LocalMemory

Trait LocalMemory 

Source
pub trait LocalMemory {
    // Required methods
    async fn remember(
        &self,
        scope: &MemoryScope,
        payload: Vec<u8>,
    ) -> Result<MemoryId, LaserError>;
    async fn recall(
        &self,
        scope: &MemoryScope,
        query: &MemoryQuery,
    ) -> Result<Vec<MemoryItem>, LaserError>;
    async fn improve(
        &self,
        scope: &MemoryScope,
        feedback: Feedback,
    ) -> Result<MemoryId, LaserError>;
    async fn forget(
        &self,
        scope: &MemoryScope,
        id: MemoryId,
    ) -> Result<(), LaserError>;

    // Provided method
    fn append(
        &self,
        scope: &MemoryScope,
        id: MemoryId,
        kind: MemoryKind,
        payload: Vec<u8>,
    ) -> impl Future<Output = Result<MemoryId, LaserError>>
       where Self: Sync { ... }
}
Expand description

Agent memory: remember / recall / improve / forget. (Memory is the Send variant.)

Required Methods§

Source

async fn remember( &self, scope: &MemoryScope, payload: Vec<u8>, ) -> Result<MemoryId, LaserError>

Append payload to the memory under scope. The body is opaque bytes, so encode it with whatever codec you like before calling.

Source

async fn recall( &self, scope: &MemoryScope, query: &MemoryQuery, ) -> Result<Vec<MemoryItem>, LaserError>

Source

async fn improve( &self, scope: &MemoryScope, feedback: Feedback, ) -> Result<MemoryId, LaserError>

Record feedback on a recalled item, the log-native signal a ranking backend folds into future recall. Returns the feedback record’s id.

Source

async fn forget( &self, scope: &MemoryScope, id: MemoryId, ) -> Result<(), LaserError>

Provided Methods§

Source

fn append( &self, scope: &MemoryScope, id: MemoryId, kind: MemoryKind, payload: Vec<u8>, ) -> impl Future<Output = Result<MemoryId, LaserError>>
where Self: Sync,

Append a typed item. Custom backends can keep their remember fallback.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<TraitVariantBlanketType: Memory> LocalMemory for TraitVariantBlanketType