use async_trait::async_trait;
use super::TextAgent;
use crate::error::AgentError;
use crate::state::State;
pub struct TapTextAgent {
name: String,
func: Box<dyn Fn(&State) + Send + Sync>,
}
impl TapTextAgent {
pub fn new(name: impl Into<String>, f: impl Fn(&State) + Send + Sync + 'static) -> Self {
Self {
name: name.into(),
func: Box::new(f),
}
}
}
#[async_trait]
impl TextAgent for TapTextAgent {
fn name(&self) -> &str {
&self.name
}
async fn run(&self, state: &State) -> Result<String, AgentError> {
(self.func)(state);
Ok(String::new())
}
}