zed
zed copied to clipboard
Models selector sorts by model name not display name
Summary
Model names under the ollama section are sorted on their model name and not display_name key.
Description
Steps to trigger the problem:
- Install multiple models in ollama (qwen2.5-coder:7b, deepseek-r1:7b, mistral, deepseek-coder-v2:16b, etc.)
- Under the
available_models, assign some names and configurations, but not others. Example:
"available_models": [
{
"name": "qwen2.5-coder:7b",
"display_name": "64k// qwen2.5-coder:7b",
"keep_alive": "1h",
"max_tokens": 65536,
"supports_tools": true
},
{
"name": "qwen2.5-coder:1.5b",
"display_name": "64k// qwen2.5-coder:1.5b",
"keep_alive": "1h",
"max_tokens": 65536,
"supports_tools": true
},
{
"name": "qwen2.5-coder:14b",
"display_name": "64k// qwen2.5-coder:14b",
"keep_alive": "1h",
"max_tokens": 65536,
"supports_tools": true
},
{
"name": "deepseek-coder-v2:16b",
"display_name": "64k// deepseek-coder-v2:16b",
"keep_alive": "1h",
"max_tokens": 65536,
"supports_tools": false
}
]
Actual Behavior:
Listing of models shows the assigned display_name, but doesn't sort on them.
Expected Behavior:
Sort the list based on display_name, falling back to name if a display_name is not set.
- 64k// deepseek-coder-v2:16b
- 64k// qwen2.5-coder:1.5B
- 64k// qwen2.5-coder:14B
- 64k// qwen2.5-coder:7B
- deepseek-r1:14b
- mistral
Ideally, it would sort on name, then the tag (so that the qwen2.5-coder models would sort properly)
- 64k// qwen2.5-coder:1.5B
- 64k// qwen2.5-coder:7B
- 64k// qwen2.5-coder:14B
- deepseek-r1:14b
- mistral
Zed Version and System Specs
Zed: v0.186.9 (Zed) OS: Linux Wayland ubuntu 24.04 Memory: 54.7 GiB Architecture: x86_64 GPU: AMD Radeon 780M (RADV GFX1103_R1) || radv || Mesa 24.2.8-1ubuntu1~24.04.1
I'm new to rust, but I feel like this might be somewhere related to the file: crates/language_models/src/provider/ollama.rs:97
Currently, the sorting on the models list uses the model’s name field:
ollama_models.sort_by(|a, b| a.name.cmp(&b.name));
To sort by display_name (falling back to name if display_name isn’t set), we could update the comparison logic like this:
ollama_models.sort_by(|a, b| {
let a_key = a.display_name.as_ref().unwrap_or(&a.name);
let b_key = b.display_name.as_ref().unwrap_or(&b.name);
a_key.cmp(b_key)
});
This change should make the panel display models in the expected order, as described.
Let me know if you’d like a PR for this!
I don't think your sorting fully works, since the ollama object never has the display_name set during its instantiation (see L99, the display_name has "None" set). We would need some way of pulling that display_name string out of the ollama settings first to apply there.
@jgonyea Thanks for reporting. I think your desired behavior is more correct, sort on display_name falling back to modelname if no display name is set.