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 methods
fn failure_mode(&self) -> ContextProviderFailureMode { ... }
fn cognitive_package_binding(&self) -> Option<&CognitivePackageBindingV1> { ... }
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§
Sourcefn 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,
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§
Sourcefn failure_mode(&self) -> ContextProviderFailureMode
fn failure_mode(&self) -> ContextProviderFailureMode
Whether provider failure may be omitted or must abort the turn.
Sourcefn cognitive_package_binding(&self) -> Option<&CognitivePackageBindingV1>
fn cognitive_package_binding(&self) -> Option<&CognitivePackageBindingV1>
Exact cognitive-package identity, when this is Code’s typed adapter.
Hosts must install such an adapter through
SessionOptions::with_cognitive_context
so the same value is persisted in the session snapshot.
Sourcefn 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,
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".