use serde::Serialize;
use crate::model::Model;
#[derive(Debug, Clone, Serialize)]
pub struct Agent {
description: String,
prompt: String,
#[serde(skip_serializing_if = "Option::is_none")]
model: Option<Model>,
#[serde(skip_serializing_if = "Vec::is_empty")]
tools: Vec<String>,
}
impl Agent {
pub fn new(description: impl Into<String>, prompt: impl Into<String>) -> Self {
Self {
description: description.into(),
prompt: prompt.into(),
model: None,
tools: Vec::new(),
}
}
pub fn description(&self) -> &str {
&self.description
}
pub fn prompt(&self) -> &str {
&self.prompt
}
pub fn model(&self) -> Option<&Model> {
self.model.as_ref()
}
pub fn set_model(&mut self, model: impl Into<Model>) {
self.model = Some(model.into());
}
#[must_use]
pub fn with_model(mut self, model: impl Into<Model>) -> Self {
self.set_model(model);
self
}
pub fn tools(&self) -> &[String] {
&self.tools
}
pub fn set_tools(&mut self, tools: impl IntoIterator<Item = impl Into<String>>) {
self.tools = tools.into_iter().map(|s| s.into()).collect();
}
#[must_use]
pub fn with_tools(mut self, tools: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.set_tools(tools);
self
}
}