1use serde::{Deserialize, Serialize};
2use std::time::Duration;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct GraphConfig {
6 pub max_iterations: usize,
7 pub execution_timeout: Duration,
8 pub enable_cancellation: bool,
9}
10
11impl Default for GraphConfig {
12 fn default() -> Self {
13 Self {
14 max_iterations: 50,
15 execution_timeout: Duration::from_secs(300),
16 enable_cancellation: true,
17 }
18 }
19}
20
21impl GraphConfig {
22 pub fn new() -> Self {
23 Self::default()
24 }
25
26 pub fn with_max_iterations(mut self, max: usize) -> Self {
27 self.max_iterations = max;
28 self
29 }
30
31 pub fn with_timeout(mut self, timeout: Duration) -> Self {
32 self.execution_timeout = timeout;
33 self
34 }
35
36 pub fn with_cancellation(mut self, enabled: bool) -> Self {
37 self.enable_cancellation = enabled;
38 self
39 }
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct LLMConfig {
44 pub model: String,
45 pub temperature: Option<f32>,
46 pub max_tokens: Option<u32>,
47}
48
49impl LLMConfig {
50 pub fn new(model: impl Into<String>) -> Self {
51 Self {
52 model: model.into(),
53 temperature: None,
54 max_tokens: None,
55 }
56 }
57
58 pub fn with_temperature(mut self, temp: f32) -> Self {
59 self.temperature = Some(temp);
60 self
61 }
62
63 pub fn with_max_tokens(mut self, tokens: u32) -> Self {
64 self.max_tokens = Some(tokens);
65 self
66 }
67}
68
69impl Default for LLMConfig {
70 fn default() -> Self {
71 Self {
72 model: "gpt-5".to_string(),
73 temperature: Some(1.0),
74 max_tokens: Some(4096),
75 }
76 }
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(tag = "type", rename_all = "snake_case")]
81pub enum ContextPolicy {
82 LastK { k: usize },
83 AllMessages,
84}
85
86impl Default for ContextPolicy {
87 fn default() -> Self {
88 Self::LastK { k: 10 }
89 }
90}
91