pub struct ModelLimit {
pub model_pattern: String,
pub max_context_tokens: u32,
pub max_output_tokens: Option<u32>,
pub safety_margin: Option<u32>,
}Expand description
Model limit configuration (user-overridable).
Fields§
§model_pattern: StringModel identifier (partial match supported, e.g., “gpt-4” matches “gpt-4o”)
max_context_tokens: u32Maximum context window size in tokens
max_output_tokens: Option<u32>Maximum output tokens (defaults to min(max_context / 4,
DEFAULT_MAX_OUTPUT_TOKENS) when unset — see Self::get_max_output_tokens)
safety_margin: Option<u32>Safety margin for token counting (defaults to 1000)
Implementations§
Source§impl ModelLimit
impl ModelLimit
Sourcepub fn new(model_pattern: impl Into<String>, max_context_tokens: u32) -> Self
pub fn new(model_pattern: impl Into<String>, max_context_tokens: u32) -> Self
Create a new model limit with defaults.
Sourcepub fn get_max_output_tokens(&self) -> u32
pub fn get_max_output_tokens(&self) -> u32
Get max output tokens with default calculation.
When unset, derive from the context window (max_context_tokens / 4)
capped at the global DEFAULT_MAX_OUTPUT_TOKENS. The cap tracks the
global default rather than a hard-coded 4096, so a user override like
ModelLimit::new("gpt-4o", 128_000) (no explicit max_output_tokens)
resolves to min(32_000, 128_000) = 32_000 instead of collapsing to
4096 — see issue #20, bug 4.
Sourcepub fn get_safety_margin(&self) -> u32
pub fn get_safety_margin(&self) -> u32
Get safety margin, scaling proportionally with context window.
Trait Implementations§
Source§impl Clone for ModelLimit
impl Clone for ModelLimit
Source§fn clone(&self) -> ModelLimit
fn clone(&self) -> ModelLimit
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more