rs_adk/text/
sequential.rs1use std::sync::Arc;
2
3use async_trait::async_trait;
4
5use super::TextAgent;
6use crate::error::AgentError;
7use crate::state::State;
8
9pub struct SequentialTextAgent {
12 name: String,
13 children: Vec<Arc<dyn TextAgent>>,
14}
15
16impl SequentialTextAgent {
17 pub fn new(name: impl Into<String>, children: Vec<Arc<dyn TextAgent>>) -> Self {
19 Self {
20 name: name.into(),
21 children,
22 }
23 }
24}
25
26#[async_trait]
27impl TextAgent for SequentialTextAgent {
28 fn name(&self) -> &str {
29 &self.name
30 }
31
32 async fn run(&self, state: &State) -> Result<String, AgentError> {
33 let mut last_output = String::new();
34 for child in &self.children {
35 last_output = child.run(state).await?;
36 state.set("input", &last_output);
38 }
39 Ok(last_output)
40 }
41}