Trait MessageHistory

Source
pub trait MessageHistory:
    Send
    + Sync
    + Debug {
    // Required methods
    fn history<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn push_owned<'life0, 'async_trait>(
        &'life0 self,
        item: ChatMessage,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn overwrite<'life0, 'async_trait>(
        &'life0 self,
        items: Vec<ChatMessage>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn push<'life0, 'life1, 'async_trait>(
        &'life0 self,
        item: &'life1 ChatMessage,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn extend<'life0, 'life1, 'async_trait>(
        &'life0 self,
        items: &'life1 [ChatMessage],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn extend_owned<'life0, 'async_trait>(
        &'life0 self,
        items: Vec<ChatMessage>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A backend for the agent context. A default is provided for Arc<Mutex<Vec>>

If you want to use for instance a database, implement this trait and pass it to the agent context when creating it.

Required Methods§

Source

fn history<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the history of messages

Source

fn push_owned<'life0, 'async_trait>( &'life0 self, item: ChatMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a message to the history

Source

fn overwrite<'life0, 'async_trait>( &'life0 self, items: Vec<ChatMessage>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Overwrite the history with the given items

Provided Methods§

Source

fn push<'life0, 'life1, 'async_trait>( &'life0 self, item: &'life1 ChatMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add a message to the history

Source

fn extend<'life0, 'life1, 'async_trait>( &'life0 self, items: &'life1 [ChatMessage], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Extend the history with the given items

Source

fn extend_owned<'life0, 'async_trait>( &'life0 self, items: Vec<ChatMessage>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Extend the history with the given items, taking ownership of them

Implementations on Foreign Types§

Source§

impl MessageHistory for Mutex<Vec<ChatMessage>>

Source§

fn history<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn push_owned<'life0, 'async_trait>( &'life0 self, item: ChatMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn overwrite<'life0, 'async_trait>( &'life0 self, items: Vec<ChatMessage>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§