use crate::adapters::schemas::ToolsSchema;
use crate::context::Message;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ContextStrategy {
Append,
Reset,
}
impl Default for ContextStrategy {
fn default() -> Self {
Self::Append
}
}
#[derive(Debug, Clone)]
pub struct NodeConfig {
pub name: String,
pub system_prompt: Option<String>,
pub task_messages: Vec<Message>,
pub tools: Option<ToolsSchema>,
pub context_strategy: ContextStrategy,
pub respond_immediately: bool,
}
impl NodeConfig {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
system_prompt: None,
task_messages: Vec::new(),
tools: None,
context_strategy: ContextStrategy::default(),
respond_immediately: true,
}
}
pub fn with_system_prompt(mut self, prompt: impl Into<String>) -> Self {
self.system_prompt = Some(prompt.into());
self
}
pub fn with_task_message(mut self, content: impl Into<String>) -> Self {
self.task_messages.push(Message::System {
content: content.into(),
});
self
}
pub fn with_user_task_message(mut self, content: impl Into<String>) -> Self {
self.task_messages.push(Message::User {
content: content.into(),
});
self
}
pub fn with_task_messages(mut self, messages: Vec<Message>) -> Self {
self.task_messages = messages;
self
}
pub fn with_tools(mut self, tools: ToolsSchema) -> Self {
self.tools = Some(tools);
self
}
pub fn with_context_strategy(mut self, strategy: ContextStrategy) -> Self {
self.context_strategy = strategy;
self
}
pub fn with_respond_immediately(mut self, respond: bool) -> Self {
self.respond_immediately = respond;
self
}
}