_diffctx/config/
filtering.rs1use once_cell::sync::Lazy;
2
3use crate::config::env_overrides::read_env_f64;
4
5pub struct FilteringConfig {
6 pub proximity_floor_max: f64,
7 pub proximity_half_decay: f64,
8 pub definition_proximity_half_decay: f64,
9 pub hub_reverse_threshold: usize,
10 pub max_context_fragments_per_file: usize,
11 pub low_relevance_threshold: f64,
12 pub size_penalty_base_tokens: f64,
13 pub size_penalty_exponent: f64,
14}
15
16impl Default for FilteringConfig {
17 fn default() -> Self {
18 Self {
19 proximity_floor_max: 0.04,
20 proximity_half_decay: 50.0,
21 definition_proximity_half_decay: 5.0,
22 hub_reverse_threshold: 2,
23 max_context_fragments_per_file: 30,
24 low_relevance_threshold: 0.015,
25 size_penalty_base_tokens: 100.0,
26 size_penalty_exponent: 0.5,
27 }
28 }
29}
30
31pub static FILTERING: Lazy<FilteringConfig> = Lazy::new(|| FilteringConfig {
32 proximity_half_decay: read_env_f64("DIFFCTX_OP_FILTERING_PROXIMITY_HALF_DECAY", 50.0),
33 definition_proximity_half_decay: read_env_f64(
34 "DIFFCTX_OP_FILTERING_DEFINITION_PROXIMITY_HALF_DECAY",
35 5.0,
36 ),
37 ..FilteringConfig::default()
38});