pub struct MockCompletionModel { /* private fields */ }Available on crate feature
test-utils only.Expand description
A cloneable scripted CompletionModel for tests.
Each completion or stream call consumes exactly one scripted turn. If no turn
is available, the model returns CompletionError::ProviderError with a
clear message instead of repeating previous responses.
Implementations§
Source§impl MockCompletionModel
impl MockCompletionModel
Sourcepub fn new(turns: impl IntoIterator<Item = MockTurn>) -> MockCompletionModel
Available on crate features test-utils only.
pub fn new(turns: impl IntoIterator<Item = MockTurn>) -> MockCompletionModel
test-utils only.Create a mock model from scripted non-streaming turns.
Sourcepub fn text(text: impl Into<String>) -> MockCompletionModel
Available on crate features test-utils only.
pub fn text(text: impl Into<String>) -> MockCompletionModel
test-utils only.Create a mock model that returns one text completion.
Sourcepub fn from_turns(
turns: impl IntoIterator<Item = MockTurn>,
) -> MockCompletionModel
Available on crate features test-utils only.
pub fn from_turns( turns: impl IntoIterator<Item = MockTurn>, ) -> MockCompletionModel
test-utils only.Create a mock model from scripted non-streaming turns.
Sourcepub fn from_stream_turns(
stream_turns: impl IntoIterator<Item = impl IntoIterator<Item = MockStreamEvent>>,
) -> MockCompletionModel
Available on crate features test-utils only.
pub fn from_stream_turns( stream_turns: impl IntoIterator<Item = impl IntoIterator<Item = MockStreamEvent>>, ) -> MockCompletionModel
test-utils only.Create a mock model from scripted streaming turns.
Sourcepub fn requests(&self) -> Vec<CompletionRequest>
Available on crate features test-utils only.
pub fn requests(&self) -> Vec<CompletionRequest>
test-utils only.Return cloned requests received by this model.
Sourcepub fn request_count(&self) -> usize
Available on crate features test-utils only.
pub fn request_count(&self) -> usize
test-utils only.Return the number of requests received by this model.
Trait Implementations§
Source§impl Clone for MockCompletionModel
impl Clone for MockCompletionModel
Source§fn clone(&self) -> MockCompletionModel
fn clone(&self) -> MockCompletionModel
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 moreSource§impl CompletionModel for MockCompletionModel
impl CompletionModel for MockCompletionModel
Source§type Response = MockResponse
type Response = MockResponse
The raw response type returned by the underlying completion model.
Source§type StreamingResponse = MockResponse
type StreamingResponse = MockResponse
The raw response type returned by the underlying completion model when streaming.
Source§fn make(
_: &<MockCompletionModel as CompletionModel>::Client,
_: impl Into<String>,
) -> MockCompletionModel
fn make( _: &<MockCompletionModel as CompletionModel>::Client, _: impl Into<String>, ) -> MockCompletionModel
Construct a model handle from a provider client and model identifier.
Source§async fn completion(
&self,
request: CompletionRequest,
) -> Result<CompletionResponse<<MockCompletionModel as CompletionModel>::Response>, CompletionError>
async fn completion( &self, request: CompletionRequest, ) -> Result<CompletionResponse<<MockCompletionModel as CompletionModel>::Response>, CompletionError>
Generates a completion response for the given completion request.
async fn stream( &self, request: CompletionRequest, ) -> Result<StreamingCompletionResponse<<MockCompletionModel as CompletionModel>::StreamingResponse>, CompletionError>
Source§fn completion_request(
&self,
prompt: impl Into<Message>,
) -> CompletionRequestBuilder<Self>
fn completion_request( &self, prompt: impl Into<Message>, ) -> CompletionRequestBuilder<Self>
Generates a completion request builder for the given
prompt.Source§fn composes_native_output_with_tools(&self) -> bool
fn composes_native_output_with_tools(&self) -> bool
Whether this provider’s native structured output (
output_schema ->
format/response_format) composes with tool calls in the same
multi-turn request without suppressing them. Read moreSource§impl Default for MockCompletionModel
impl Default for MockCompletionModel
Source§fn default() -> MockCompletionModel
fn default() -> MockCompletionModel
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MockCompletionModel
impl RefUnwindSafe for MockCompletionModel
impl Send for MockCompletionModel
impl Sync for MockCompletionModel
impl Unpin for MockCompletionModel
impl UnsafeUnpin for MockCompletionModel
impl UnwindSafe for MockCompletionModel
Blanket Implementations§
Source§impl<M> AgentModelExt for Mwhere
M: CompletionModel,
impl<M> AgentModelExt for Mwhere
M: CompletionModel,
Source§fn into_agent_builder(self) -> AgentBuilder<Self>
fn into_agent_builder(self) -> AgentBuilder<Self>
Convert this model into a classic agent builder.
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