pub struct ModelContext {
pub capabilities: ModelCapabilities,
pub tags: Vec<String>,
pub inference_defaults: Option<InferenceConfig>,
pub defaults_origin: Option<DefaultsOrigin>,
pub context_length: Option<u64>,
}Expand description
Everything a request pipeline needs to know about the target model, gathered in a single catalog round-trip.
The five fields feed the resolution and shaping stages, which is why they travel together rather than being looked up where each is needed:
capabilities— request-side transforms (strict-turn coalescing and friends).tags— response-stream parser selection, and (via thereasoningtag) the sampling floor.inference_defaults— the per-model layer of the sampling hierarchy.defaults_origin— which runginference_defaultsoccupies in that hierarchy.context_length— the history-truncation budget.
Before this type was shared, the proxy resolved all of them while every
other surface resolved the same row and kept only tags, so capability
coalescing and per-model defaults were unreachable outside the proxy.
Fields§
§capabilities: ModelCapabilitiesStored capability bitfield — drives request-side transforms.
format:* tags — drives response-stream parser selection.
inference_defaults: Option<InferenceConfig>Per-model inference defaults to merge into each request.
defaults_origin: Option<DefaultsOrigin>Whether inference_defaults was set by
the user or auto-detected. See DefaultsOrigin.
context_length: Option<u64>Maximum context the model supports, in tokens — the history-truncation budget for every surface that cannot measure a live serving context.
Implementations§
Source§impl ModelContext
impl ModelContext
Sourcepub fn passthrough() -> Self
pub fn passthrough() -> Self
The zeroed context: empty capabilities so every transform is a no-op, empty tags so the identity passthrough parser is selected, no per-model defaults, and no truncation budget.
This is the conservative fallback used whenever the model cannot be resolved — an unresolvable model must never block a request, only lose its model-specific handling.
Sourcepub fn context_budget_chars(&self) -> Option<usize>
pub fn context_budget_chars(&self) -> Option<usize>
The history-truncation budget in characters, from the model’s own
capacity: context_length tokens converted at
CHARS_PER_TOKEN_APPROX.
None when the context size is unknown, which
apply reads as do not truncate. Guessing a budget
for an unresolvable model would risk rejecting a request over a number
nobody actually knows; losing model-specific handling is the whole
fallback policy of this module.
Callers that know the live serving context — the proxy, which also learns a per-model chars-per-token ratio from observed usage frames — compute a better number and pass that instead. This is the answer for everyone else.
Trait Implementations§
Source§impl Clone for ModelContext
impl Clone for ModelContext
Source§fn clone(&self) -> ModelContext
fn clone(&self) -> ModelContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelContext
impl Debug for ModelContext
Source§impl Default for ModelContext
impl Default for ModelContext
Source§fn default() -> ModelContext
fn default() -> ModelContext
Source§impl From<&ModelSummary> for ModelContext
impl From<&ModelSummary> for ModelContext
Source§fn from(summary: &ModelSummary) -> Self
fn from(summary: &ModelSummary) -> Self
Source§impl PartialEq for ModelContext
impl PartialEq for ModelContext
Source§fn eq(&self, other: &ModelContext) -> bool
fn eq(&self, other: &ModelContext) -> bool
self and other values to be equal, and is used by ==.