Skip to main content

StreamingChatProvider

Trait StreamingChatProvider 

Source
pub trait StreamingChatProvider: Send + Sync {
    type Message: Send + Sync + 'static;
    type Delta<'s>: Stream<Item = Result<String>> + Send + 's
       where Self: 's;

    // Required method
    fn chat_complete_stream<'s, M>(
        &'s self,
        params: ChatCompleteParameters<M>,
    ) -> Self::Delta<'s>
       where M: Into<Self::Message> + Clone + Send + Sync + 's;
}
Expand description

A provider that can deliver the model’s answer incrementally.

The stream yields UTF-8 text deltas (similar to OpenAI’s SSE format). Tool-call and richer payload support can be layered on later by introducing a dedicated enum – starting with plain text keeps the API minimal and backend-agnostic.

Required Associated Types§

Source

type Message: Send + Sync + 'static

Chat message type consumed by this backend.

Source

type Delta<'s>: Stream<Item = Result<String>> + Send + 's where Self: 's

The item type returned on the stream. For now it is plain UTF-8 text chunks, but back-ends are free to wrap it in richer enums if needed.

Required Methods§

Source

fn chat_complete_stream<'s, M>( &'s self, params: ChatCompleteParameters<M>, ) -> Self::Delta<'s>
where M: Into<Self::Message> + Clone + Send + Sync + 's,

Start a streaming chat completion.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§