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