pub struct CompactionThreshold {
pub tokens: Option<u64>,
pub ratio: Option<f64>,
}Expand description
压缩阈值配置 — 控制在 Threshold 模式下何时触发。
§解析优先级(与 oh-my-pi 一致)
tokens (固定值) > ratio (百分比) > fallback (context_window - reserve_tokens)§Examples
use katu_core::compaction::CompactionThreshold;
// 固定阈值: 超过 150K tokens 时触发
let fixed = CompactionThreshold::fixed(150_000);
// 百分比阈值: 超过 context window 的 85% 时触发
let ratio = CompactionThreshold::ratio(0.85);
// 默认: 都不设 — 使用 fallback (context_window - reserve_tokens)
let fallback = CompactionThreshold::default();Fields§
§tokens: Option<u64>固定 token 阈值 — 优先级最高。
当 context_tokens > tokens 时触发压缩。
ratio: Option<f64>百分比阈值 (0.0 ~ 1.0) — tokens 未设置时使用。
当 context_tokens > context_window * ratio 时触发。 来源: oh-my-pi thresholdPercent。
Implementations§
Trait Implementations§
Source§impl Clone for CompactionThreshold
impl Clone for CompactionThreshold
Source§fn clone(&self) -> CompactionThreshold
fn clone(&self) -> CompactionThreshold
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompactionThreshold
impl Debug for CompactionThreshold
Source§impl Default for CompactionThreshold
impl Default for CompactionThreshold
Source§fn default() -> CompactionThreshold
fn default() -> CompactionThreshold
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CompactionThreshold
impl<'de> Deserialize<'de> for CompactionThreshold
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for CompactionThreshold
impl PartialEq for CompactionThreshold
Source§fn eq(&self, other: &CompactionThreshold) -> bool
fn eq(&self, other: &CompactionThreshold) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for CompactionThreshold
impl Serialize for CompactionThreshold
impl Copy for CompactionThreshold
impl StructuralPartialEq for CompactionThreshold
Auto Trait Implementations§
impl Freeze for CompactionThreshold
impl RefUnwindSafe for CompactionThreshold
impl Send for CompactionThreshold
impl Sync for CompactionThreshold
impl Unpin for CompactionThreshold
impl UnsafeUnpin for CompactionThreshold
impl UnwindSafe for CompactionThreshold
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more