Memory

Trait Memory 

Source
pub trait Memory: Send + Sync {
    // Required methods
    fn add_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
        role: &'life2 str,
        content: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = RragResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn add_structured_message<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
        message: ConversationMessage,
    ) -> Pin<Box<dyn Future<Output = RragResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_conversation_history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = RragResult<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_messages<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = RragResult<Vec<ConversationMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_recent_messages<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = RragResult<Vec<ConversationMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear_conversation<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = RragResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_memory_variables<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = RragResult<HashMap<String, String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn save_context<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
        context: HashMap<String, String>,
    ) -> Pin<Box<dyn Future<Output = RragResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = RragResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Core memory trait for conversation management

Required Methods§

Source

fn add_message<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, conversation_id: &'life1 str, role: &'life2 str, content: &'life3 str, ) -> Pin<Box<dyn Future<Output = RragResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Add a message to the conversation

Source

fn add_structured_message<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, message: ConversationMessage, ) -> Pin<Box<dyn Future<Output = RragResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add a structured message

Source

fn get_conversation_history<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = RragResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get conversation history

Source

fn get_messages<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = RragResult<Vec<ConversationMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get structured conversation history

Source

fn get_recent_messages<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = RragResult<Vec<ConversationMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get recent messages with limit

Source

fn clear_conversation<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = RragResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Clear conversation history

Source

fn get_memory_variables<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = RragResult<HashMap<String, String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get memory variables for prompt injection

Source

fn save_context<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, context: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = RragResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save arbitrary context

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RragResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Health check

Implementors§