rexis_rag/agent/
config.rs

1//! Agent configuration
2
3use serde::{Deserialize, Serialize};
4
5/// Agent conversation mode
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7pub enum ConversationMode {
8    /// Stateless: Each call is independent
9    Stateless,
10    /// Stateful: Maintains conversation across calls
11    Stateful,
12}
13
14/// Agent configuration
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct AgentConfig {
17    /// System prompt that defines agent behavior
18    pub system_prompt: String,
19
20    /// Maximum iterations before stopping (prevents infinite loops)
21    pub max_iterations: usize,
22
23    /// Whether to show verbose output
24    pub verbose: bool,
25
26    /// Conversation mode
27    pub conversation_mode: ConversationMode,
28
29    /// Maximum conversation history length (for stateful mode)
30    pub max_conversation_length: usize,
31}
32
33impl Default for AgentConfig {
34    fn default() -> Self {
35        Self {
36            system_prompt: "You are a helpful assistant with access to tools. Use tools when needed to provide accurate information.".to_string(),
37            max_iterations: 10,
38            verbose: false,
39            conversation_mode: ConversationMode::Stateless,
40            max_conversation_length: 50,
41        }
42    }
43}
44
45impl AgentConfig {
46    /// Create a new configuration
47    pub fn new() -> Self {
48        Self::default()
49    }
50
51    /// Set system prompt
52    pub fn with_system_prompt(mut self, prompt: impl Into<String>) -> Self {
53        self.system_prompt = prompt.into();
54        self
55    }
56
57    /// Set max iterations
58    pub fn with_max_iterations(mut self, max: usize) -> Self {
59        self.max_iterations = max;
60        self
61    }
62
63    /// Enable verbose output
64    pub fn with_verbose(mut self, verbose: bool) -> Self {
65        self.verbose = verbose;
66        self
67    }
68
69    /// Set conversation mode
70    pub fn with_conversation_mode(mut self, mode: ConversationMode) -> Self {
71        self.conversation_mode = mode;
72        self
73    }
74
75    /// Set max conversation length
76    pub fn with_max_conversation_length(mut self, length: usize) -> Self {
77        self.max_conversation_length = length;
78        self
79    }
80}