Skip to main content

fallback_stream

Function fallback_stream 

Source
pub async fn fallback_stream<A: ChatAdapter + ?Sized>(
    adapter: &A,
    thread_id: &str,
    text_stream: TextStream,
    options: &StreamOptions,
) -> Result<SentMessage, ChatError>
Expand description

Stream text progressively using a post-then-edit loop.

This is the default fallback streaming strategy for adapters that do not provide a native streaming mechanism:

  1. Post an initial placeholder message.
  2. Consume chunks from text_stream, accumulating them.
  3. Every options.update_interval_ms milliseconds, edit the message with the accumulated text so far.
  4. After the stream ends, perform a final edit with the complete text.