pub struct ChatStream { /* private fields */ }Expand description
Streaming response wrapper.
Wraps an async Stream and provides convenient collection methods.
Implementations§
Source§impl ChatStream
impl ChatStream
Sourcepub fn new(
stream: Pin<Box<dyn Stream<Item = Result<StreamChunk, LlmError>> + Send>>,
) -> ChatStream
pub fn new( stream: Pin<Box<dyn Stream<Item = Result<StreamChunk, LlmError>> + Send>>, ) -> ChatStream
Create a new ChatStream.
Sourcepub fn into_inner(
self,
) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, LlmError>> + Send>>
pub fn into_inner( self, ) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, LlmError>> + Send>>
Consume self and return the inner stream.
Useful for adapters that need to wrap the stream in a different type.
Sourcepub async fn collect_text(self) -> Result<String, LlmError>
pub async fn collect_text(self) -> Result<String, LlmError>
Collect all text into a string.
Note: this loses tool calls and usage information.
Use collect_response for the full response.
Sourcepub async fn collect_response(self) -> Result<ChatResponse, LlmError>
pub async fn collect_response(self) -> Result<ChatResponse, LlmError>
Collect full response (including tool calls, usage).
Used by GenericProvider::chat() stream fallback mode,
ensuring no tool calls or usage info is lost.
Handles incremental tool call assembly: tool calls arrive across multiple chunks (first has id+name, subsequent have only argument fragments).
Auto Trait Implementations§
impl !RefUnwindSafe for ChatStream
impl !Sync for ChatStream
impl !UnwindSafe for ChatStream
impl Freeze for ChatStream
impl Send for ChatStream
impl Unpin for ChatStream
impl UnsafeUnpin for ChatStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more