pub struct MockProvider {
pub requests: Mutex<Vec<CompletionRequest>>,
/* private fields */
}Expand description
A ModelProvider that returns pre-configured responses from a queue.
Fields§
§requests: Mutex<Vec<CompletionRequest>>All requests received, in arrival order. Public so tests can assert on them.
Implementations§
Source§impl MockProvider
impl MockProvider
Sourcepub fn new(responses: Vec<CompletionResponse>) -> Self
pub fn new(responses: Vec<CompletionResponse>) -> Self
Build a mock that will reply with responses in FIFO order.
Trait Implementations§
Source§impl ModelProvider for MockProvider
impl ModelProvider for MockProvider
Source§fn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Issue a single non-streaming completion request.
Source§fn stream_complete<'a>(
&'a self,
request: CompletionRequest,
) -> Pin<Box<dyn Stream<Item = Result<ProviderEvent, AgentError>> + Send + 'a>>
fn stream_complete<'a>( &'a self, request: CompletionRequest, ) -> Pin<Box<dyn Stream<Item = Result<ProviderEvent, AgentError>> + Send + 'a>>
Stream a completion as a sequence of
ProviderEvents. Read moreSource§fn max_tokens(&self) -> u32
fn max_tokens(&self) -> u32
Return the maximum number of tokens that can be requested from this provider. Read more
Auto Trait Implementations§
impl !Freeze for MockProvider
impl !RefUnwindSafe for MockProvider
impl Send for MockProvider
impl Sync for MockProvider
impl Unpin for MockProvider
impl UnsafeUnpin for MockProvider
impl UnwindSafe for MockProvider
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