Skip to main content

Memory

Trait Memory 

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

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

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

Required Methods§

Source

fn remember( &self, scope: &MemoryScope, payload: Vec<u8>, ) -> impl Future<Output = Result<MemoryId, LaserError>> + Send

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

Source

fn recall( &self, scope: &MemoryScope, query: &MemoryQuery, ) -> impl Future<Output = Result<Vec<MemoryItem>, LaserError>> + Send

Source

fn improve( &self, scope: &MemoryScope, feedback: Feedback, ) -> impl Future<Output = Result<MemoryId, LaserError>> + Send

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

Source

fn forget( &self, scope: &MemoryScope, id: MemoryId, ) -> impl Future<Output = Result<(), LaserError>> + Send

Provided Methods§

Source

fn append( &self, scope: &MemoryScope, id: MemoryId, kind: MemoryKind, payload: Vec<u8>, ) -> impl Future<Output = Result<MemoryId, LaserError>> + Send
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§