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§async fn completion(
&self,
request: CompletionRequest,
) -> Result<CompletionResponse, CompletionError>
async fn completion( &self, request: CompletionRequest, ) -> Result<CompletionResponse, CompletionError>
Generates a completion response for the given completion request.
Source§async fn stream(
&self,
request: CompletionRequest,
) -> Result<StreamingCompletionResponse, CompletionError>
async fn stream( &self, request: CompletionRequest, ) -> Result<StreamingCompletionResponse, CompletionError>
Streams a completion response for the given completion request.
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 capabilities(&self) -> ProviderCapabilities
fn capabilities(&self) -> ProviderCapabilities
Provider behavior a runtime should account for when preparing requests. Read more
Source§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) -> AgentBuilderwhere
Self: 'static,
fn into_agent_builder(self) -> AgentBuilderwhere
Self: 'static,
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