extract_cw_overrides (src/model_capabilities.rs)

moltis · crates/providers/src/model_capabilities.rs · rust · MIT
ai, tag:embed-classified

Extracts context window overrides for language models from config.

// Source: https://github.com/moltis-org/moltis | License: MIT | Copyright 2025 Fabien Penso
// Provided via justclaw.it.com; keep this notice with the code.
//! Model capability heuristics: context window, tool support, vision, reasoning.

use {crate::model_id::capability_model_id, moltis_config::schema::ModelOverride};

/// Extract a `HashMap<String, u32>` of model ID → context window from
/// a `HashMap<String, ModelOverride>`, filtering out entries without a
/// `context_window` value.
#[must_use]
pub fn extract_cw_overrides(
    overrides: &std::collections::HashMap<String, ModelOverride>,
) -> std::collections::HashMap<String, u32> {
    overrides
        .iter()
        .filter_map(|(k, v)| v.context_window.map(|cw| (k.clone(), cw)))
        .collect()
}

/// Return the known contex

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key