use crate::agent::{RuntimeMode, ToolsConfig};
use crate::dynamic_tool::DynamicToolFactory;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
#[derive(Debug, Clone, Default, Serialize, Deserialize, ToSchema)]
pub struct DefinitionOverrides {
pub model: Option<String>,
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub max_iterations: Option<usize>,
pub instructions: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub instructions_append: Option<String>,
pub use_browser: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[schema(value_type = Option<Vec<String>>)]
pub runtime: Option<Vec<RuntimeMode>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[schema(value_type = Option<Object>)]
pub tools: Option<ToolsConfig>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sub_agents: Option<Vec<String>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dynamic_tools: Option<Vec<DynamicToolFactory>>,
}
impl DefinitionOverrides {
pub fn new() -> Self {
Self::default()
}
pub fn with_model(mut self, model: String) -> Self {
self.model = Some(model);
self
}
pub fn with_temperature(mut self, temperature: f32) -> Self {
self.temperature = Some(temperature);
self
}
pub fn with_max_tokens(mut self, max_tokens: u32) -> Self {
self.max_tokens = Some(max_tokens);
self
}
pub fn with_max_iterations(mut self, max_iterations: usize) -> Self {
self.max_iterations = Some(max_iterations);
self
}
pub fn with_instructions(mut self, instructions: String) -> Self {
self.instructions = Some(instructions);
self
}
pub fn with_instructions_append(mut self, suffix: String) -> Self {
self.instructions_append = Some(suffix);
self
}
pub fn with_browser_enabled(mut self, enabled: bool) -> Self {
self.use_browser = Some(enabled);
self
}
pub fn with_runtime(mut self, runtime: Vec<RuntimeMode>) -> Self {
self.runtime = Some(runtime);
self
}
pub fn with_remote(mut self, remote: bool) -> Self {
if remote {
self.runtime = Some(vec![RuntimeMode::Cloud]);
} else {
self.runtime = None;
}
self
}
pub fn with_tools(mut self, tools: ToolsConfig) -> Self {
self.tools = Some(tools);
self
}
pub fn with_description(mut self, description: String) -> Self {
self.description = Some(description);
self
}
pub fn with_sub_agents(mut self, sub_agents: Vec<String>) -> Self {
self.sub_agents = Some(sub_agents);
self
}
pub fn with_name(mut self, name: String) -> Self {
self.name = Some(name);
self
}
pub fn with_dynamic_tools(mut self, tools: Vec<DynamicToolFactory>) -> Self {
self.dynamic_tools = Some(tools);
self
}
}