use crate::{
agent::{Agent, config::AgentConfig, tool::ToolDispatcher},
model::Model,
};
use crabllm_core::{Provider, Tool};
use std::sync::Arc;
pub struct AgentBuilder<P: Provider + 'static> {
config: AgentConfig,
model: Model<P>,
tools: Vec<Tool>,
dispatcher: Option<Arc<dyn ToolDispatcher>>,
}
impl<P: Provider + 'static> AgentBuilder<P> {
pub fn new(model: Model<P>) -> Self {
Self {
config: AgentConfig::default(),
model,
tools: Vec::new(),
dispatcher: None,
}
}
pub fn config(mut self, config: AgentConfig) -> Self {
self.config = config;
self
}
pub fn tools(mut self, tools: Vec<Tool>) -> Self {
self.tools = tools;
self
}
pub fn dispatcher(mut self, dispatcher: Arc<dyn ToolDispatcher>) -> Self {
self.dispatcher = Some(dispatcher);
self
}
pub fn build(self) -> Agent<P> {
Agent {
config: self.config,
model: self.model,
tools: self.tools,
dispatcher: self.dispatcher,
}
}
}