Struct LoopTextAgent
pub struct LoopTextAgent { /* private fields */ }Expand description
Runs a text agent repeatedly until max iterations or a state predicate.
Implementations§
§impl LoopTextAgent
impl LoopTextAgent
pub fn new(
name: impl Into<String>,
body: Arc<dyn TextAgent>,
max: u32,
) -> LoopTextAgent
pub fn new( name: impl Into<String>, body: Arc<dyn TextAgent>, max: u32, ) -> LoopTextAgent
Create a new loop agent that repeats up to max iterations.
pub fn until(
self,
pred: impl Fn(&State) -> bool + Send + Sync + 'static,
) -> LoopTextAgent
pub fn until( self, pred: impl Fn(&State) -> bool + Send + Sync + 'static, ) -> LoopTextAgent
Add a predicate — loop breaks when predicate returns true.
pub fn with_middleware_chain(self, chain: MiddlewareChain) -> LoopTextAgent
pub fn with_middleware_chain(self, chain: MiddlewareChain) -> LoopTextAgent
Attach a middleware chain. AgentEvent::LoopIteration is emitted through
it on every iteration, so on_event observers (e.g. M::on_loop) fire.
Trait Implementations§
§impl TextAgent for LoopTextAgent
impl TextAgent for LoopTextAgent
§fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
state: &'life1 State,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
LoopTextAgent: 'async_trait,
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
state: &'life1 State,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
LoopTextAgent: 'async_trait,
Execute this agent. Reads/writes
state. Returns the final text output.Auto Trait Implementations§
impl Freeze for LoopTextAgent
impl !RefUnwindSafe for LoopTextAgent
impl Send for LoopTextAgent
impl Sync for LoopTextAgent
impl Unpin for LoopTextAgent
impl !UnwindSafe for LoopTextAgent
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