pub struct ReActLoop { /* private fields */ }Expand description
The ReAct agent loop.
Implementations§
Source§impl ReActLoop
impl ReActLoop
Sourcepub fn new(config: AgentConfig) -> Self
pub fn new(config: AgentConfig) -> Self
Create a new ReActLoop with the given configuration and an empty tool registry.
Sourcepub fn register_tool(&mut self, spec: ToolSpec)
pub fn register_tool(&mut self, spec: ToolSpec)
Register a tool that the agent loop can invoke.
Sourcepub async fn run<F, Fut>(
&self,
prompt: &str,
infer: F,
) -> Result<Vec<ReActStep>, AgentRuntimeError>
pub async fn run<F, Fut>( &self, prompt: &str, infer: F, ) -> Result<Vec<ReActStep>, AgentRuntimeError>
Execute the ReAct loop for the given prompt.
§Arguments
prompt— user input passed as the initial contextinfer— async inference function: receives context string, returns response string
§Returns
Ok(Vec<ReActStep>)— steps executed, ending with aFINAL_ANSWERstepErr(AgentRuntimeError::AgentLoop)— if max iterations reached withoutFINAL_ANSWERor if a ReAct response cannot be parsed
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ReActLoop
impl !RefUnwindSafe for ReActLoop
impl Send for ReActLoop
impl Sync for ReActLoop
impl Unpin for ReActLoop
impl UnsafeUnpin for ReActLoop
impl !UnwindSafe for ReActLoop
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