agent: Only show recommended models that are actually configured (#28613)
Release Notes: - N/A
This commit is contained in:
parent
0036a33263
commit
62ebae96e3
1 changed files with 22 additions and 15 deletions
|
@ -396,26 +396,33 @@ impl PickerDelegate for LanguageModelPickerDelegate {
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
let filtered_models = cx
|
let filtered_models = cx
|
||||||
.background_spawn(async move {
|
.background_spawn(async move {
|
||||||
let filter_models = |model_infos: &[ModelInfo]| {
|
let matches = |info: &ModelInfo| {
|
||||||
model_infos
|
info.model
|
||||||
.iter()
|
.name()
|
||||||
.filter(|model_info| {
|
.0
|
||||||
model_info
|
.to_lowercase()
|
||||||
.model
|
.contains(&query.to_lowercase())
|
||||||
.name()
|
|
||||||
.0
|
|
||||||
.to_lowercase()
|
|
||||||
.contains(&query.to_lowercase())
|
|
||||||
})
|
|
||||||
.cloned()
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let recommended_models = filter_models(&all_models.recommended);
|
let recommended_models = all_models
|
||||||
|
.recommended
|
||||||
|
.iter()
|
||||||
|
.filter(|r| {
|
||||||
|
configured_providers.contains(&r.model.provider_id()) && matches(r)
|
||||||
|
})
|
||||||
|
.cloned()
|
||||||
|
.collect();
|
||||||
let mut other_models = IndexMap::default();
|
let mut other_models = IndexMap::default();
|
||||||
for (provider_id, models) in &all_models.other {
|
for (provider_id, models) in &all_models.other {
|
||||||
if configured_providers.contains(&provider_id) {
|
if configured_providers.contains(&provider_id) {
|
||||||
other_models.insert(provider_id.clone(), filter_models(models));
|
other_models.insert(
|
||||||
|
provider_id.clone(),
|
||||||
|
models
|
||||||
|
.iter()
|
||||||
|
.filter(|m| matches(m))
|
||||||
|
.cloned()
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupedModels {
|
GroupedModels {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue