codetether_rlm/model_select/
resolve.rs1use crate::config::RlmConfig;
4
5use super::{
6 RLM_MODEL_ENV, RlmModelChoice, RlmModelPurpose, RlmModelSource, configured::configured,
7};
8
9pub fn select_rlm_model(
11 config: &RlmConfig,
12 purpose: RlmModelPurpose,
13 caller_model: &str,
14 score: impl Fn(&str) -> Option<f64>,
15) -> RlmModelChoice {
16 let env_model = std::env::var(RLM_MODEL_ENV).ok();
17 select_rlm_model_with_env(config, purpose, caller_model, env_model.as_deref(), score)
18}
19
20pub fn select_rlm_model_with_env(
22 config: &RlmConfig,
23 purpose: RlmModelPurpose,
24 caller_model: &str,
25 env_model: Option<&str>,
26 _score: impl Fn(&str) -> Option<f64>,
27) -> RlmModelChoice {
28 if let Some((model, source)) = configured(config, purpose) {
29 return RlmModelChoice::new(model, source);
30 }
31 if let Some(model) = env_model.map(str::trim).filter(|s| !s.is_empty()) {
32 return RlmModelChoice::new(model, RlmModelSource::Env);
33 }
34 RlmModelChoice::new(caller_model, RlmModelSource::Caller)
35}