pub trait StreamingHandler: Send + Sync {
// Required methods
fn handle_chunk<'life0, 'async_trait>(
&'life0 self,
chunk: StreamChunk,
) -> Pin<Box<dyn Future<Output = LLMResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn handle_completion<'life0, 'async_trait>(
&'life0 self,
final_message: LLMMessage,
usage: TokenUsage,
) -> Pin<Box<dyn Future<Output = LLMResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn handle_error<'life0, 'async_trait>(
&'life0 self,
error: LLMError,
) -> Pin<Box<dyn Future<Output = LLMResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Streaming response handler
Required Methods§
Sourcefn handle_chunk<'life0, 'async_trait>(
&'life0 self,
chunk: StreamChunk,
) -> Pin<Box<dyn Future<Output = LLMResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_chunk<'life0, 'async_trait>(
&'life0 self,
chunk: StreamChunk,
) -> Pin<Box<dyn Future<Output = LLMResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a stream chunk
Sourcefn handle_completion<'life0, 'async_trait>(
&'life0 self,
final_message: LLMMessage,
usage: TokenUsage,
) -> Pin<Box<dyn Future<Output = LLMResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_completion<'life0, 'async_trait>(
&'life0 self,
final_message: LLMMessage,
usage: TokenUsage,
) -> Pin<Box<dyn Future<Output = LLMResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle stream completion