walrus_core/agent/builder.rs
1//! Fluent builder for constructing an [`Agent`].
2
3use crate::{
4 agent::{Agent, config::AgentConfig},
5 model::Model,
6};
7
8/// Fluent builder for [`Agent<M>`].
9///
10/// Requires a model at construction. Use [`AgentConfig`] builder methods
11/// for field configuration, then pass it via [`AgentBuilder::config`].
12pub struct AgentBuilder<M: Model> {
13 config: AgentConfig,
14 model: M,
15}
16
17impl<M: Model> AgentBuilder<M> {
18 /// Create a new builder with the given model.
19 pub fn new(model: M) -> Self {
20 Self {
21 config: AgentConfig::default(),
22 model,
23 }
24 }
25
26 /// Set the full config, replacing all fields.
27 ///
28 /// Typical usage: build an `AgentConfig` via its fluent methods,
29 /// then pass it here before calling `build()`.
30 pub fn config(mut self, config: AgentConfig) -> Self {
31 self.config = config;
32 self
33 }
34
35 /// Build the [`Agent`].
36 pub fn build(self) -> Agent<M> {
37 Agent {
38 config: self.config,
39 model: self.model,
40 history: Vec::new(),
41 }
42 }
43}