pub struct ThreadSafeRandAgent { /* private fields */ }Expand description
线程安全的 RandAgent,支持多线程并发访问
Implementations§
Source§impl ThreadSafeRandAgent
impl ThreadSafeRandAgent
Sourcepub fn with_max_failures(
agents: Vec<(BoxAgent<'static>, String, String)>,
max_failures: u32,
) -> Self
pub fn with_max_failures( agents: Vec<(BoxAgent<'static>, String, String)>, max_failures: u32, ) -> Self
使用自定义最大失败次数创建线程安全 RandAgent
Sourcepub fn add_agent_with_max_failures(
&self,
agent: BoxAgent<'static>,
provider: String,
model: String,
max_failures: u32,
)
pub fn add_agent_with_max_failures( &self, agent: BoxAgent<'static>, provider: String, model: String, max_failures: u32, )
使用自定义最大失败次数添加代理
Sourcepub async fn prompt(
&self,
message: &str,
) -> Result<String, Box<dyn Error + Send + Sync>>
pub async fn prompt( &self, message: &str, ) -> Result<String, Box<dyn Error + Send + Sync>>
向随机有效代理发送消息
Sourcepub fn reset_failures(&self)
pub fn reset_failures(&self)
重置所有代理的失败计数
Trait Implementations§
impl Send for ThreadSafeRandAgent
impl Sync for ThreadSafeRandAgent
Auto Trait Implementations§
impl Freeze for ThreadSafeRandAgent
impl RefUnwindSafe for ThreadSafeRandAgent
impl Unpin for ThreadSafeRandAgent
impl UnwindSafe for ThreadSafeRandAgent
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