pub enum MockStreamEvent {
Text(String),
ToolCall {
id: String,
name: String,
arguments: Value,
call_id: Option<String>,
},
ToolCallDelta {
id: String,
internal_call_id: String,
content: ToolCallDeltaContent,
},
MessageId(String),
FinalResponse(MockResponse),
Error(MockError),
}Available on crate feature
test-utils only.Expand description
Scripted streaming event yielded by MockCompletionModel.
Variants§
Text(String)
Text chunk.
ToolCall
Complete tool call event.
ToolCallDelta
Tool call delta event.
MessageId(String)
Provider-assigned message ID.
FinalResponse(MockResponse)
Final raw response carrying optional usage.
Error(MockError)
Stream error.
Implementations§
Source§impl MockStreamEvent
impl MockStreamEvent
Sourcepub fn tool_call(
id: impl Into<String>,
name: impl Into<String>,
arguments: Value,
) -> Self
pub fn tool_call( id: impl Into<String>, name: impl Into<String>, arguments: Value, ) -> Self
Create a complete tool call event.
Sourcepub fn with_call_id(self, call_id: impl Into<String>) -> Self
pub fn with_call_id(self, call_id: impl Into<String>) -> Self
Attach a provider-specific call ID to a complete tool call event.
Sourcepub fn tool_call_name_delta(
id: impl Into<String>,
internal_call_id: impl Into<String>,
name: impl Into<String>,
) -> Self
pub fn tool_call_name_delta( id: impl Into<String>, internal_call_id: impl Into<String>, name: impl Into<String>, ) -> Self
Create a tool call name delta.
Sourcepub fn tool_call_arguments_delta(
id: impl Into<String>,
internal_call_id: impl Into<String>,
arguments: impl Into<String>,
) -> Self
pub fn tool_call_arguments_delta( id: impl Into<String>, internal_call_id: impl Into<String>, arguments: impl Into<String>, ) -> Self
Create a tool call arguments delta.
Sourcepub fn message_id(id: impl Into<String>) -> Self
pub fn message_id(id: impl Into<String>) -> Self
Create a provider-assigned message ID event.
Sourcepub fn final_response(usage: Usage) -> Self
pub fn final_response(usage: Usage) -> Self
Create a final response event with usage.
Sourcepub fn final_response_with_default_usage() -> Self
pub fn final_response_with_default_usage() -> Self
Create a final response event with default zero usage.
Sourcepub fn final_response_with_total_tokens(total_tokens: u64) -> Self
pub fn final_response_with_total_tokens(total_tokens: u64) -> Self
Create a final response event whose usage has only total_tokens set.
Trait Implementations§
Source§impl Clone for MockStreamEvent
impl Clone for MockStreamEvent
Source§fn clone(&self) -> MockStreamEvent
fn clone(&self) -> MockStreamEvent
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 MockStreamEvent
impl RefUnwindSafe for MockStreamEvent
impl Send for MockStreamEvent
impl Sync for MockStreamEvent
impl Unpin for MockStreamEvent
impl UnsafeUnpin for MockStreamEvent
impl UnwindSafe for MockStreamEvent
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
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more