Skip to main content

MessageStore

Trait MessageStore 

Source
pub trait MessageStore: Send + Sync {
    // Required methods
    fn save_message<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message: &'life1 LLMMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn get_message<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<LLMMessage>, PersistenceError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_session_messages<'life0, 'async_trait>(
        &'life0 self,
        session_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<LLMMessage>, PersistenceError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_session_messages_paginated<'life0, 'async_trait>(
        &'life0 self,
        session_id: Uuid,
        offset: i64,
        limit: i64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<LLMMessage>, PersistenceError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn delete_message<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<bool, PersistenceError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn delete_session_messages<'life0, 'async_trait>(
        &'life0 self,
        session_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<i64, PersistenceError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn count_session_messages<'life0, 'async_trait>(
        &'life0 self,
        session_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<i64, PersistenceError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn save_messages<'life0, 'life1, 'async_trait>(
        &'life0 self,
        messages: &'life1 [LLMMessage],
    ) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

消息存储 trait

提供 LLM 消息的 CRUD 操作

Required Methods§

Source

fn save_message<'life0, 'life1, 'async_trait>( &'life0 self, message: &'life1 LLMMessage, ) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

保存消息

Source

fn get_message<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<LLMMessage>, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

获取消息

Source

fn get_session_messages<'life0, 'async_trait>( &'life0 self, session_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<LLMMessage>, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

获取会话消息列表

Source

fn get_session_messages_paginated<'life0, 'async_trait>( &'life0 self, session_id: Uuid, offset: i64, limit: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<LLMMessage>, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

获取会话消息列表 (分页)

Source

fn delete_message<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<bool, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

删除消息

Source

fn delete_session_messages<'life0, 'async_trait>( &'life0 self, session_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<i64, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

删除会话所有消息

Source

fn count_session_messages<'life0, 'async_trait>( &'life0 self, session_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<i64, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

统计会话消息数

Provided Methods§

Source

fn save_messages<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [LLMMessage], ) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

批量保存消息

Implementors§