pub struct RandAgent<'a> { /* private fields */ }Expand description
A wrapper struct that holds multiple agents and randomly selects one for each invocation
Implementations§
Source§impl<'a> RandAgent<'a>
impl<'a> RandAgent<'a>
Sourcepub fn new(agents: Vec<(BoxAgent<'a>, String, String)>) -> Self
pub fn new(agents: Vec<(BoxAgent<'a>, String, String)>) -> Self
Create a new RandAgent with the given agents
Sourcepub fn with_max_failures(
agents: Vec<(BoxAgent<'a>, String, String)>,
max_failures: u32,
) -> Self
pub fn with_max_failures( agents: Vec<(BoxAgent<'a>, String, String)>, max_failures: u32, ) -> Self
Create a new RandAgent with custom max failure count
Sourcepub fn from_builders(
_builders: Vec<AgentBuilder<CompletionModelHandle<'a>>>,
) -> Self
👎Deprecated: 请使用 RandAgentBuilder::add_agent/add_builder 方式构建并传递 provider/model
pub fn from_builders( _builders: Vec<AgentBuilder<CompletionModelHandle<'a>>>, ) -> Self
Create a RandAgent from multiple AgentBuilders
Sourcepub fn from_builders_with_max_failures(
_builders: Vec<AgentBuilder<CompletionModelHandle<'a>>>,
_max_failures: u32,
) -> Self
👎Deprecated: 请使用 RandAgentBuilder::add_agent/add_builder 方式构建并传递 provider/model
pub fn from_builders_with_max_failures( _builders: Vec<AgentBuilder<CompletionModelHandle<'a>>>, _max_failures: u32, ) -> Self
Create a RandAgent from multiple AgentBuilders with custom max failure count
Sourcepub fn add_agent(
&mut self,
agent: BoxAgent<'a>,
provider: String,
model: String,
)
pub fn add_agent( &mut self, agent: BoxAgent<'a>, provider: String, model: String, )
Add an agent to the collection
Sourcepub fn add_agent_with_max_failures(
&mut self,
agent: BoxAgent<'a>,
provider: String,
model: String,
max_failures: u32,
)
pub fn add_agent_with_max_failures( &mut self, agent: BoxAgent<'a>, provider: String, model: String, max_failures: u32, )
Add an agent to the collection with custom max failure count
Sourcepub async fn prompt(
&mut self,
message: &str,
) -> Result<String, Box<dyn Error + Send + Sync>>
pub async fn prompt( &mut self, message: &str, ) -> Result<String, Box<dyn Error + Send + Sync>>
Prompt a random valid agent with the given message
Sourcepub async fn stream_prompt(
&self,
_message: &str,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn stream_prompt( &self, _message: &str, ) -> Result<(), Box<dyn Error + Send + Sync>>
Stream a response from a random agent (not implemented due to trait compatibility issues)
Sourcepub fn agents(&self) -> &[AgentState<'a>]
pub fn agents(&self) -> &[AgentState<'a>]
Get all agents (for debugging or inspection)
Sourcepub fn reset_failures(&mut self)
pub fn reset_failures(&mut self)
Reset failure counts for all agents
Auto Trait Implementations§
impl<'a> Freeze for RandAgent<'a>
impl<'a> !RefUnwindSafe for RandAgent<'a>
impl<'a> Send for RandAgent<'a>
impl<'a> Sync for RandAgent<'a>
impl<'a> Unpin for RandAgent<'a>
impl<'a> !UnwindSafe for RandAgent<'a>
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