Skip to main content

ContextProvider

Trait ContextProvider 

Source
pub trait ContextProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 ContextQuery,
    ) -> Pin<Box<dyn Future<Output = Result<ContextResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn on_turn_complete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _session_id: &'life1 str,
        _prompt: &'life2 str,
        _response: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}
Expand description

Context provider trait - implement this for OpenViking, RAG systems, etc.

Required Methods§

Source

fn name(&self) -> &str

Provider name (used for identification and logging)

Source

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

Query the provider for relevant context

Provided Methods§

Source

fn on_turn_complete<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _session_id: &'life1 str, _prompt: &'life2 str, _response: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Called after each turn for memory extraction (optional)

Providers can implement this to extract and store memories from the conversation.

Implementors§