walrus_core/agent/
builder.rs1use super::tool::ToolSender;
4use crate::{
5 agent::{Agent, config::AgentConfig},
6 model::{Model, Tool},
7};
8
9pub struct AgentBuilder<M: Model> {
14 config: AgentConfig,
15 model: M,
16 tools: Vec<Tool>,
17 tool_tx: Option<ToolSender>,
18}
19
20impl<M: Model> AgentBuilder<M> {
21 pub fn new(model: M) -> Self {
23 Self {
24 config: AgentConfig::default(),
25 model,
26 tools: Vec::new(),
27 tool_tx: None,
28 }
29 }
30
31 pub fn config(mut self, config: AgentConfig) -> Self {
33 self.config = config;
34 self
35 }
36
37 pub fn tools(mut self, tools: Vec<Tool>) -> Self {
39 self.tools = tools;
40 self
41 }
42
43 pub fn tool_tx(mut self, tx: ToolSender) -> Self {
45 self.tool_tx = Some(tx);
46 self
47 }
48
49 pub fn build(self) -> Agent<M> {
51 Agent {
52 config: self.config,
53 model: self.model,
54 tools: self.tools,
55 tool_tx: self.tool_tx,
56 }
57 }
58}