Skip to main content

codetether_agent/tui/app/smart_switch/
same_provider.rs

1//! Same-provider fallback generation.
2
3use std::collections::HashSet;
4
5use super::error_detection::smart_switch_model_key;
6use super::models::smart_switch_preferred_models;
7
8/// Returns candidates from the same provider.
9pub fn same_provider_candidates(
10    provider_name: &str,
11    available: &HashSet<String>,
12    attempted_models: &HashSet<String>,
13) -> Vec<String> {
14    let mut out = Vec::new();
15    if available.contains(provider_name) {
16        for model_id in smart_switch_preferred_models(provider_name) {
17            let candidate = format!("{provider_name}/{model_id}");
18            if !attempted_models.contains(&smart_switch_model_key(&candidate)) {
19                out.push(candidate);
20            }
21        }
22    }
23    out
24}