pub struct MockLlmClient { /* private fields */ }Expand description
Supports:
- Predefined responses
- Tool call simulation
- Streaming simulation
- Call tracking
- Error injection
Implementations§
Source§impl MockLlmClient
impl MockLlmClient
Sourcepub fn with_responses_vec(responses: Vec<&str>) -> Self
pub fn with_responses_vec(responses: Vec<&str>) -> Self
Create a new mock client with simple text responses
Sourcepub fn from_mock_responses(responses: Vec<MockResponse>) -> Self
pub fn from_mock_responses(responses: Vec<MockResponse>) -> Self
Create a mock client with detailed responses
Sourcepub fn from_tool_call(tool_name: &str, args: Value) -> Self
pub fn from_tool_call(tool_name: &str, args: Value) -> Self
Create a mock client that calls a specific tool
Sourcepub fn with_tool_then_text(
tool_name: &str,
args: Value,
final_response: &str,
) -> Self
pub fn with_tool_then_text( tool_name: &str, args: Value, final_response: &str, ) -> Self
Create a mock client that calls a tool then responds with text
Sourcepub fn with_response(self, text: &str) -> Self
pub fn with_response(self, text: &str) -> Self
Add a text response to the chain
Sourcepub fn with_tool_call(self, tool_name: &str, args: Value) -> Self
pub fn with_tool_call(self, tool_name: &str, args: Value) -> Self
Add a tool call response to the chain
Sourcepub fn error_on_call(self, call_index: usize) -> Self
pub fn error_on_call(self, call_index: usize) -> Self
Set the client to error on a specific call index
Sourcepub fn fail_on_call(&self, call_index: usize)
pub fn fail_on_call(&self, call_index: usize)
Set the client to fail on the nth call (0-indexed)
Sourcepub fn call_count(&self) -> usize
pub fn call_count(&self) -> usize
Get the number of calls made
Sourcepub fn get_calls(&self) -> Vec<ChatRequest>
pub fn get_calls(&self) -> Vec<ChatRequest>
Get a copy of all calls made
Sourcepub fn last_call(&self) -> Option<ChatRequest>
pub fn last_call(&self) -> Option<ChatRequest>
Get the last call made
Sourcepub fn clear_calls(&self)
pub fn clear_calls(&self)
Clear call history
Trait Implementations§
Source§impl ChatClient for MockLlmClient
impl ChatClient for MockLlmClient
Source§fn chat<'life0, 'async_trait>(
&'life0 self,
request: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
request: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a chat completion request
Source§fn chat_stream<'life0, 'async_trait>(
&'life0 self,
request: ChatRequest,
tx: Sender<String>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_stream<'life0, 'async_trait>(
&'life0 self,
request: ChatRequest,
tx: Sender<String>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream a chat completion request with channel-based delivery
Source§impl Clone for MockLlmClient
impl Clone for MockLlmClient
Source§fn clone(&self) -> MockLlmClient
fn clone(&self) -> MockLlmClient
Returns a duplicate of the value. Read more
1.0.0 · 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 MockLlmClient
impl RefUnwindSafe for MockLlmClient
impl Send for MockLlmClient
impl Sync for MockLlmClient
impl Unpin for MockLlmClient
impl UnwindSafe for MockLlmClient
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