pub struct ChatStreamParser<'a> { /* private fields */ }Expand description
Push-driven streaming parser for chat-adapter completions.
Hold one per LM call; push provider StreamDelta.content chunks
via Self::push; call Self::finish when the provider
stream ends. Both return Vec<ParseEvent> for the caller (the
streaming consumer) to forward over SSE.
Implementations§
Source§impl<'a> ChatStreamParser<'a>
impl<'a> ChatStreamParser<'a>
Sourcepub fn new(signature: &'a Signature) -> Self
pub fn new(signature: &'a Signature) -> Self
Build a parser for signature. Field types are read at marker
time via the signature’s output_fields() lookup.
Sourcepub fn push(&mut self, chunk: &str) -> Vec<ParseEvent>
pub fn push(&mut self, chunk: &str) -> Vec<ParseEvent>
Feed one chunk of provider text. Returns the events produced by this chunk in emission order.
Sourcepub fn finish(self) -> Vec<ParseEvent>
pub fn finish(self) -> Vec<ParseEvent>
Finalize at end of provider stream. Returns any closing events (FieldComplete for an unclosed final field, the no-marker fallback if applicable, StreamComplete).
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ChatStreamParser<'a>
impl<'a> !Sync for ChatStreamParser<'a>
impl<'a> !UnwindSafe for ChatStreamParser<'a>
impl<'a> Freeze for ChatStreamParser<'a>
impl<'a> Send for ChatStreamParser<'a>
impl<'a> Unpin for ChatStreamParser<'a>
impl<'a> UnsafeUnpin for ChatStreamParser<'a>
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