Skip to main content

lash_core/provider/
model_policy.rs

1use super::support::*;
2
3#[derive(Clone, Debug)]
4pub struct StaticModelPolicy {
5    default_model: &'static str,
6    supported_variants: &'static [&'static str],
7    default_variant: Option<&'static str>,
8}
9
10impl StaticModelPolicy {
11    pub fn new(default_model: &'static str) -> Self {
12        Self {
13            default_model,
14            supported_variants: &[],
15            default_variant: None,
16        }
17    }
18
19    pub fn with_variants(
20        default_model: &'static str,
21        supported_variants: &'static [&'static str],
22        default_variant: Option<&'static str>,
23    ) -> Self {
24        Self {
25            default_model,
26            supported_variants,
27            default_variant,
28        }
29    }
30}
31
32impl ProviderModelPolicy for StaticModelPolicy {
33    fn default_model(&self) -> &str {
34        self.default_model
35    }
36
37    fn supported_variants(&self, _model: &str) -> &'static [&'static str] {
38        self.supported_variants
39    }
40
41    fn default_model_variant(&self, _model: &str) -> Option<&'static str> {
42        self.default_variant
43    }
44
45    fn request_variant_config(&self, _model: &str, variant: &str) -> Option<VariantRequestConfig> {
46        self.supported_variants
47            .contains(&variant)
48            .then(|| VariantRequestConfig::ReasoningEffort(variant.to_string()))
49    }
50
51    fn default_agent_model(&self, _tier: &str) -> Option<AgentModelSelection> {
52        None
53    }
54}