pub struct RandAgent<'a> { /* private fields */ }Expand description
包装多个代理的结构体,每次调用时随机选择一个代理
Implementations§
Source§impl<'a> RandAgent<'a>
impl<'a> RandAgent<'a>
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
使用自定义最大失败次数创建新的 RandAgent
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, )
使用自定义最大失败次数向集合中添加代理
Sourcepub fn agents(&self) -> &[AgentState<'a>]
pub fn agents(&self) -> &[AgentState<'a>]
获取所有代理(用于调试或检查)
Sourcepub fn reset_failures(&mut self)
pub fn reset_failures(&mut self)
重置所有代理的失败计数
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