pub struct RandAgent<'a> { /* private fields */ }Expand description
包装多个代理的结构体,每次调用时随机选择一个代理
Implementations§
Source§impl<'a> RandAgent<'a>
impl<'a> RandAgent<'a>
Sourcepub fn with_max_failures_and_callback(
agents: Vec<(BoxAgent<'a>, i32, String, String)>,
max_failures: u32,
on_agent_invalid: OnRandAgentInvalidCallback,
) -> Self
pub fn with_max_failures_and_callback( agents: Vec<(BoxAgent<'a>, i32, String, String)>, max_failures: u32, on_agent_invalid: OnRandAgentInvalidCallback, ) -> Self
使用自定义最大失败次数和回调创建新的 RandAgent
Sourcepub fn with_max_failures(
agents: Vec<(BoxAgent<'a>, i32, String, String)>,
max_failures: u32,
) -> Self
pub fn with_max_failures( agents: Vec<(BoxAgent<'a>, i32, String, String)>, max_failures: u32, ) -> Self
使用自定义最大失败次数创建新的 RandAgent
Sourcepub fn set_on_agent_invalid<F>(&mut self, callback: F)
pub fn set_on_agent_invalid<F>(&mut self, callback: F)
设置 agent 失效时的回调
Sourcepub async fn add_agent(
&self,
agent: BoxAgent<'a>,
id: i32,
provider: String,
model: String,
)
pub async fn add_agent( &self, agent: BoxAgent<'a>, id: i32, provider: String, model: String, )
向集合中添加代理
Sourcepub async fn add_agent_with_max_failures(
&self,
agent: BoxAgent<'a>,
id: i32,
provider: String,
model: String,
max_failures: u32,
)
pub async fn add_agent_with_max_failures( &self, agent: BoxAgent<'a>, id: i32, provider: String, model: String, max_failures: u32, )
使用自定义最大失败次数向集合中添加代理
Sourcepub async fn reset_failures(&self)
pub async fn reset_failures(&self)
重置所有代理的失败计数
Trait Implementations§
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