StreamingCallback

Trait StreamingCallback 

Source
pub trait StreamingCallback: Send + Sync {
    // Required methods
    fn on_chunk<'life0, 'life1, 'async_trait>(
        &'life0 self,
        chunk: &'life1 str,
        tokens: Option<TokenMetrics>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_complete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        full_response: &'life1 str,
        final_tokens: TokenMetrics,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_error<'life0, 'life1, 'async_trait>(
        &'life0 self,
        error: &'life1 Error,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_status_update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for streaming callback to handle real-time response processing

Required Methods§

Source

fn on_chunk<'life0, 'life1, 'async_trait>( &'life0 self, chunk: &'life1 str, tokens: Option<TokenMetrics>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called when a new chunk of text is received

Source

fn on_complete<'life0, 'life1, 'async_trait>( &'life0 self, full_response: &'life1 str, final_tokens: TokenMetrics, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called when the response is complete

Source

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

Called when an error occurs

Source

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

Called for status updates

Implementors§