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>) -> Self
pub fn new(script: Vec<Completion>) -> Self
A mock scripted with a sequence of successful completions.
Sourcepub fn with_results(script: Vec<Result<Completion, ProviderError>>) -> Self
pub fn with_results(script: Vec<Result<Completion, ProviderError>>) -> Self
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 stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ConversationRequest,
on_delta: &'life2 mut (dyn FnMut(CompletionDelta) + Send),
) -> Pin<Box<dyn Future<Output = Result<Completion, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ConversationRequest,
on_delta: &'life2 mut (dyn FnMut(CompletionDelta) + Send),
) -> Pin<Box<dyn Future<Output = Result<Completion, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Streams the next scripted completion as word-ish text deltas (the chunks
concatenate back to the completion’s text exactly), then returns the same
whole Completion — a realistic multi-delta stream for engine/TUI tests
without a network.
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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
request. Read more