1use std::collections::HashMap;
4
5use chrono::{DateTime, Utc};
6use serde::{Deserialize, Serialize};
7
8pub const DEFAULT_CYCLE_THRESHOLD_TOKENS: usize = 768_000;
10
11pub const DEFAULT_BRIEFING_MAX_TOKENS: usize = 3_000;
13
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
16pub struct ModelCycleConfig {
17 pub threshold_tokens: usize,
19 pub briefing_max_tokens: usize,
21}
22
23impl Default for ModelCycleConfig {
24 fn default() -> Self {
25 Self {
26 threshold_tokens: DEFAULT_CYCLE_THRESHOLD_TOKENS,
27 briefing_max_tokens: DEFAULT_BRIEFING_MAX_TOKENS,
28 }
29 }
30}
31
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
34pub struct CycleConfig {
35 pub enabled: bool,
37 pub threshold_tokens: usize,
39 pub briefing_max_tokens: usize,
41 pub per_model: HashMap<String, ModelCycleConfig>,
43}
44
45impl Default for CycleConfig {
46 fn default() -> Self {
47 let mut per_model: HashMap<String, ModelCycleConfig> = HashMap::new();
48 per_model.insert("deepseek-v4-pro".to_string(), ModelCycleConfig::default());
49 per_model.insert("deepseek-v4-flash".to_string(), ModelCycleConfig::default());
50 Self {
51 enabled: true,
52 threshold_tokens: DEFAULT_CYCLE_THRESHOLD_TOKENS,
53 briefing_max_tokens: DEFAULT_BRIEFING_MAX_TOKENS,
54 per_model,
55 }
56 }
57}
58
59impl CycleConfig {
60 #[must_use]
62 pub fn threshold_for(&self, model: &str) -> usize {
63 self.per_model
64 .get(model)
65 .map(|m| m.threshold_tokens)
66 .unwrap_or(self.threshold_tokens)
67 }
68
69 #[must_use]
71 pub fn briefing_max_for(&self, model: &str) -> usize {
72 self.per_model
73 .get(model)
74 .map(|m| m.briefing_max_tokens)
75 .unwrap_or(self.briefing_max_tokens)
76 }
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct CycleBriefing {
82 pub cycle: u32,
84 pub timestamp: DateTime<Utc>,
86 pub briefing_text: String,
88 pub token_estimate: usize,
90}