use std::sync::Arc; use forge_app::{FollowUpService, UserInfra}; /// Use this tool when you encounter ambiguities, need clarification, or require /// more details to proceed effectively. Use this tool judiciously to maintain a /// balance between gathering necessary information and avoiding excessive /// back-and-forth. #[derive(Debug)] pub struct ForgeFollowup { infra: Arc, } impl ForgeFollowup { pub fn new(infra: Arc) -> Self { Self { infra } } } #[async_trait::async_trait] impl FollowUpService for ForgeFollowup { async fn follow_up( &self, question: String, options: Vec, multiple: Option, ) -> anyhow::Result> { let inquire = &self.infra; let result = match (options.is_empty(), multiple.unwrap_or_default()) { (true, _) => inquire.prompt_question(&question).await?, (false, true) => inquire .select_many(&question, options) .await? .map(|selected| { format!( "User selected {} option(s): {}", selected.len(), selected.join(", ") ) }), (false, false) => inquire .select_one(&question, options) .await? .map(|selected| format!("User selected: {selected}")), }; Ok(result) } }