pub struct StreamAccumulator { /* private fields */ }Expand description
Folds chat.completion.chunk payloads into one assistant message.
Implementations§
Source§impl StreamAccumulator
impl StreamAccumulator
Sourcepub fn push_event(&mut self, data: &str, on_delta: DeltaFn<'_>) -> Result<()>
pub fn push_event(&mut self, data: &str, on_delta: DeltaFn<'_>) -> Result<()>
Handle one SSE data payload, reporting any text through on_delta.
Sourcepub fn usage_body(&self) -> Value
pub fn usage_body(&self) -> Value
The assembled message. Fails if the stream ended before the model signalled completion, so a cut connection is never mistaken for a finished reply. What the server said this call cost, in the same shape as a non-streaming reply.
pub fn finish(self) -> Result<Message>
Trait Implementations§
Auto Trait Implementations§
impl Forget for StreamAccumulator
impl Freeze for StreamAccumulatorwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const LeafNode<u64, PartialCall> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(u64, PartialCall)>>: Freeze,
PhantomData<Value>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
impl Move for StreamAccumulator
impl RefUnwindSafe for StreamAccumulator
impl Send for StreamAccumulator
impl Sync for StreamAccumulator
impl Unpin for StreamAccumulator
impl UnsafeUnpin for StreamAccumulatorwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const LeafNode<u64, PartialCall> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(u64, PartialCall)>>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
impl UnwindSafe for StreamAccumulatorwhere
RawVecInner: UnwindSafe,
BTreeMap<u64, PartialCall>: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
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