pub struct StreamState {
pub response_id: String,
pub output_id: String,
pub model: String,
pub text: TextAccumulator,
pub indices: IndexAllocator,
pub usage: UsageMetrics,
pub tool_calls: ToolCallTracker,
pub emit: EmitState,
pub request_context: Option<ResponseRequestContext>,
}Expand description
Streaming converter state for tracking incremental changes.
Fields§
§response_id: String§output_id: String§model: String§text: TextAccumulator§indices: IndexAllocator§usage: UsageMetrics§tool_calls: ToolCallTracker§emit: EmitState§request_context: Option<ResponseRequestContext>Backwards-compat carrier for the request context. New code paths should
pass Option<&ResponseRequestContext> directly to
build_response_object; this field will be removed once ProxyContext
stores the context separately.
Implementations§
Source§impl StreamState
impl StreamState
Sourcepub fn new(
response_id: String,
model: String,
request_context: Option<ResponseRequestContext>,
) -> Self
pub fn new( response_id: String, model: String, request_context: Option<ResponseRequestContext>, ) -> Self
Create a new stream state.
Sourcepub fn take_sequence_number(&mut self) -> u64
pub fn take_sequence_number(&mut self) -> u64
Allocate and return the next sequence number, then advance the counter.
Sourcepub fn update_usage(&mut self, chunk: &ChatStreamChunk)
pub fn update_usage(&mut self, chunk: &ChatStreamChunk)
Update usage from a ChatStreamChunk.
Sourcepub fn build_response_object(&self) -> Box<ResponseObject>
pub fn build_response_object(&self) -> Box<ResponseObject>
Build the final ResponseObject with all accumulated outputs.
The ctx parameter supplies request-level fields (instructions, tools,
sampling params, etc.). It defaults to self.request_context for
backwards compatibility but new callers should pass it explicitly.
Trait Implementations§
Source§impl Clone for StreamState
impl Clone for StreamState
Source§fn clone(&self) -> StreamState
fn clone(&self) -> StreamState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StreamState
impl RefUnwindSafe for StreamState
impl Send for StreamState
impl Sync for StreamState
impl Unpin for StreamState
impl UnsafeUnpin for StreamState
impl UnwindSafe for StreamState
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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