1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! Configuration for proxy response shaping (#1125).
use serde::{Deserialize, Serialize};
/// Response-shaping configuration (`[response_shaping]`).
///
/// The proxy applies the patterns of the selected `mode`. The former
/// `preamble`, `code_repetition`, `narration` and `confirmation` sub-sections
/// were never read; they are retired and ignored when an older config loads.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(default)]
pub struct ResponseShapingConfig {
/// Enable proxy response shaping. Defaults to the conservative gentle mode.
pub enabled: bool,
/// `off`, `gentle`, or `aggressive`.
pub mode: String,
}
impl Default for ResponseShapingConfig {
fn default() -> Self {
Self {
enabled: true,
mode: "gentle".into(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn retired_sub_sections_still_load() {
let cfg: ResponseShapingConfig = toml::from_str(
r#"
enabled = true
mode = "aggressive"
[preamble]
max_pattern_length = 42
[code_repetition]
enabled = true
[narration]
max_summary_tokens = 24
[confirmation]
strip_trailing = false
"#,
)
.expect("response-shaping TOML");
assert_eq!(cfg.mode, "aggressive");
assert!(cfg.enabled);
}
}