use std::time::Duration;
use aither_core::llm::model::Parameters;
use crate::context::ContextPolicy;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum AgentKind {
#[default]
Coding,
Chatbot,
}
#[derive(Debug, Clone)]
pub struct CacheKeepAlive {
pub send_before_expiry: Duration,
pub frequent_idle_threshold: usize,
}
impl Default for CacheKeepAlive {
fn default() -> Self {
Self {
send_before_expiry: Duration::from_secs(30),
frequent_idle_threshold: 3,
}
}
}
#[derive(Debug, Clone)]
pub struct AgentConfig {
pub max_iterations: usize,
pub context_policy: ContextPolicy,
pub system_prompt: Option<String>,
pub persona_prompt: Option<String>,
pub agent_kind: AgentKind,
pub tasks_stale_after_turns: usize,
pub request_parameters: Parameters,
pub cache_keep_alive: Option<CacheKeepAlive>,
}
impl Default for AgentConfig {
fn default() -> Self {
Self {
max_iterations: 10_000,
context_policy: ContextPolicy::default(),
system_prompt: None,
persona_prompt: None,
agent_kind: AgentKind::default(),
tasks_stale_after_turns: 4,
request_parameters: Parameters::default(),
cache_keep_alive: None,
}
}
}
impl AgentConfig {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub const fn with_max_iterations(mut self, limit: usize) -> Self {
self.max_iterations = limit;
self
}
#[must_use]
pub const fn with_context_policy(mut self, policy: ContextPolicy) -> Self {
self.context_policy = policy;
self
}
#[must_use]
pub fn with_system_prompt(mut self, prompt: impl Into<String>) -> Self {
self.system_prompt = Some(prompt.into());
self
}
#[must_use]
pub fn with_persona_prompt(mut self, prompt: impl Into<String>) -> Self {
self.persona_prompt = Some(prompt.into());
self
}
#[must_use]
pub const fn with_agent_kind(mut self, kind: AgentKind) -> Self {
self.agent_kind = kind;
self
}
#[must_use]
pub fn with_request_parameters(mut self, parameters: Parameters) -> Self {
self.request_parameters = parameters;
self
}
#[must_use]
pub const fn with_cache_keep_alive(mut self, keep_alive: CacheKeepAlive) -> Self {
self.cache_keep_alive = Some(keep_alive);
self
}
}