1mod args;
2mod closure;
3mod executor;
4mod fs;
5mod utils;
6mod web;
7
8use crate::types::{Message, ToolCall};
9use async_trait::async_trait;
10use futures::future::join_all;
11
12pub use args::*;
13pub(crate) use closure::*;
14pub use executor::*;
15pub use fs::*;
16pub use tiny_loop_macros::tool;
17pub use web::*;
18
19#[async_trait]
25pub trait Tool {
26 async fn call(&self, args: String) -> String;
28
29 async fn call_batch(&self, args: Vec<ToolCall>) -> Vec<Message> {
31 join_all(
32 args.into_iter()
33 .map(async |call| Message::Tool {
34 tool_call_id: call.id,
35 content: self.call(call.function.arguments).await,
36 })
37 .collect::<Vec<_>>(),
38 )
39 .await
40 }
41}