pub struct MockProvider { /* private fields */ }Expand description
A provider that replays a fixed script of results, one per complete() call.
This is a real, shippable provider (the --provider mock mode runs it in CI
without an API key), not test-only. It ignores the request and returns the next
scripted Completion (or ProviderError) in order — letting a test drive the
loop through a tool-call turn, a final-text turn, or a scripted error, with zero
network. Calling complete() more times than scripted panics (a loud signal
that the loop ran an unexpected extra turn), per the agreed contract.
Implementations§
Source§impl MockProvider
impl MockProvider
Sourcepub fn new(script: Vec<Completion>) -> MockProvider
pub fn new(script: Vec<Completion>) -> MockProvider
A mock scripted with a sequence of successful completions.
Sourcepub fn with_results(
script: Vec<Result<Completion, ProviderError>>,
) -> MockProvider
pub fn with_results( script: Vec<Result<Completion, ProviderError>>, ) -> MockProvider
A mock scripted with a sequence of results (to inject errors as well).
Trait Implementations§
Source§impl Provider for MockProvider
impl Provider for MockProvider
Source§fn api_schema(&self) -> &str
fn api_schema(&self) -> &str
Source§fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ConversationRequest,
) -> Pin<Box<dyn Future<Output = Result<Completion, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockProvider: 'async_trait,
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ConversationRequest,
) -> Pin<Box<dyn Future<Output = Result<Completion, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockProvider: 'async_trait,
Sample one completion for
request. Read moreAuto 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