pub struct MockAgentProvider { /* private fields */ }Expand description
An AgentProvider backed by a closure.
§Examples
use ironflow_core::provider::AgentOutput;
use ironflow_engine::testing::MockAgentProvider;
use serde_json::json;
let provider = MockAgentProvider::new(|cfg| {
assert!(cfg.prompt.contains("review"));
Ok(AgentOutput::new(json!({"score": 9})))
});Implementations§
Source§impl MockAgentProvider
impl MockAgentProvider
Sourcepub fn new(
f: impl Fn(&AgentConfig) -> Result<AgentOutput, AgentError> + Send + Sync + 'static,
) -> Self
pub fn new( f: impl Fn(&AgentConfig) -> Result<AgentOutput, AgentError> + Send + Sync + 'static, ) -> Self
Answer every invocation with f.
§Examples
use ironflow_core::provider::AgentOutput;
use ironflow_engine::testing::MockAgentProvider;
use serde_json::json;
let provider = MockAgentProvider::new(|_cfg| Ok(AgentOutput::new(json!("done"))));Trait Implementations§
Source§impl AgentProvider for MockAgentProvider
impl AgentProvider for MockAgentProvider
Source§fn invoke<'a>(&'a self, config: &'a AgentConfig) -> InvokeFuture<'a>
fn invoke<'a>(&'a self, config: &'a AgentConfig) -> InvokeFuture<'a>
Execute a single agent invocation with the given configuration. Read more
Source§fn invoke_with_logs<'a>(
&'a self,
config: &'a AgentConfig,
log_sink: Arc<dyn LogSink>,
) -> Pin<Box<dyn Future<Output = Result<AgentOutput, AgentError>> + Send + 'a>>
fn invoke_with_logs<'a>( &'a self, config: &'a AgentConfig, log_sink: Arc<dyn LogSink>, ) -> Pin<Box<dyn Future<Output = Result<AgentOutput, AgentError>> + Send + 'a>>
Execute an agent invocation with real-time log streaming. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for MockAgentProvider
impl !UnwindSafe for MockAgentProvider
impl Freeze for MockAgentProvider
impl Send for MockAgentProvider
impl Sync for MockAgentProvider
impl Unpin for MockAgentProvider
impl UnsafeUnpin for MockAgentProvider
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