# Objective Fix two related bugs in the Ollama edit-prediction provider config (`Settings > AI > Edit Prediction > Configure Providers`): 1. The Ollama model dropdown showed only a single model (the currently-configured one), regardless of what models were actually available on the configured server. 2. Ollama never appeared as a selectable option in the "Active Provider" list, even when fully configured. Both bugs shared the same root cause: several places in the edit-prediction code path read from the Assistant's separate Ollama *language model* provider (`language_models.ollama.*`, used by the AI panel/agent) instead of the edit-prediction-specific `edit_predictions.ollama.*` settings. These are two independent Ollama connections that can point at different servers, so the edit-prediction UI was effectively showing/gating on the wrong provider's state. This changes fixes #47393 ## Solution - **Model dropdown**: Added `edit_prediction::ollama::fetch_models_from_server`, which queries `/api/tags` directly against the edit-prediction's own configured `api_url`, independent of the Assistant's Ollama provider. The dropdown now re-fetches from that URL every time it's opened, so changing the server URL and reopening the dropdown shows the new server's models. - **Model filtering**: Fetched models are filtered to those Zed can infer a completion prompt format for (`infer_prompt_format`), so chat-only and embedding models (e.g. `nomic-embed-text`, `llama3:70b`) no longer clutter the list. This function was extracted from `edit_prediction_registry.rs` (previously private, used only for prompt-format resolution) into `edit_prediction::fim` so it can be shared between the dropdown filter and the existing routing logic — same behavior, no duplication. - **Provider visibility**: `get_available_providers` now gates Ollama's visibility on `edit_predictions.ollama.is_some()` (i.e. whether the user has configured a model), matching the existing pattern already used for the OpenAI-Compatible provider, instead of checking the unrelated Assistant provider's authentication state. Removed the now-dead `ollama::is_available`/`ensure_authenticated` functions and the startup call that existed solely to make that broken check eventually pass. ## Testing - Added unit tests for `infer_prompt_format` covering all known model families (qwen/codellama/deepseek-coder/starcoder/codestral/glm/zeta/sweep) and confirming unsupported models (chat/embedding) correctly return `None`. - Added an async test for `fetch_models_from_server` using a fake HTTP client, verifying it filters to FIM-capable models and returns them sorted. - Added a regression test, `test_ollama_provider_routes_to_fim_model`, verifying that Ollama + a known model (`qwen2.5-coder:3b`) resolves to `EditPredictionProviderConfig::Zed(EditPredictionModel::Fim { format: Qwen })` — this exercises the exact routing path underlying the provider-visibility fix. - Manually verified end-to-end against a real local Ollama server: configured a custom `api_url`, confirmed the model dropdown populated with the server's actual models, selected one, and confirmed Ollama appeared in and could be selected from the Active Provider list, with predictions successfully returned. - Ran `cargo check` and `./script/clippy` on all touched crates (`edit_prediction`, `settings_ui`, `edit_prediction_ui`, `zed`); no warnings. - Not tested: the `get_available_providers` gating change itself has no direct test (it's a one-line settings check whose underlying resolution is covered by the `zed`-crate regression test above); Windows/Linux were not tested, only macOS. ## Self-Review Checklist: - [X] I've reviewed my own diff for quality, security, and reliability - [X] Unsafe blocks (if any) have justifying comments - [X] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [X] Tests cover the new/changed behavior - [X] Performance impact has been considered and is acceptable ## Showcase <details> <summary>Click to view showcase</summary> Now when we open the dropdown model selector on Ollama section we will see the available models in the current server that we are trying to use <img width="903" height="755" alt="image" src="https://github.com/user-attachments/assets/873c662b-3624-4530-811c-6f07ab518e35" /> Now Ollama will be displayed as provider in the edit prediction providers dropdown <img width="903" height="755" alt="image" src="https://github.com/user-attachments/assets/9dfe737d-6527-4ecd-9803-3d0959075c34" /> </details> --- Release Notes: - Fixed Ollama edit predictions not appearing as a selectable provider and the model dropdown showing only a single model instead of the models available on the configured server
103 lines
2.7 KiB
TOML
103 lines
2.7 KiB
TOML
[package]
|
|
name = "edit_prediction"
|
|
version = "0.1.0"
|
|
edition.workspace = true
|
|
publish.workspace = true
|
|
license = "GPL-3.0-or-later"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[lib]
|
|
path = "src/edit_prediction.rs"
|
|
|
|
[features]
|
|
cli-support = []
|
|
|
|
[dependencies]
|
|
ai_onboarding.workspace = true
|
|
anyhow.workspace = true
|
|
heapless.workspace = true
|
|
buffer_diff.workspace = true
|
|
client.workspace = true
|
|
clock.workspace = true
|
|
cloud_api_client.workspace = true
|
|
cloud_api_types.workspace = true
|
|
cloud_llm_client = { workspace = true, features = ["predict-edits"] }
|
|
collections.workspace = true
|
|
copilot.workspace = true
|
|
copilot_ui.workspace = true
|
|
credentials_provider.workspace = true
|
|
db.workspace = true
|
|
edit_prediction_types.workspace = true
|
|
edit_prediction_context.workspace = true
|
|
edit_prediction_metrics = { workspace = true, features = ["tree-sitter"] }
|
|
feature_flags.workspace = true
|
|
fs.workspace = true
|
|
futures.workspace = true
|
|
git.workspace = true
|
|
gpui.workspace = true
|
|
indoc.workspace = true
|
|
itertools.workspace = true
|
|
language.workspace = true
|
|
language_model.workspace = true
|
|
log.workspace = true
|
|
lsp.workspace = true
|
|
menu.workspace = true
|
|
ollama.workspace = true
|
|
open_ai.workspace = true
|
|
postage.workspace = true
|
|
pretty_assertions.workspace = true
|
|
project.workspace = true
|
|
pulldown-cmark.workspace = true
|
|
rand.workspace = true
|
|
regex.workspace = true
|
|
release_channel.workspace = true
|
|
semver.workspace = true
|
|
serde.workspace = true
|
|
serde_json.workspace = true
|
|
settings.workspace = true
|
|
strum.workspace = true
|
|
telemetry.workspace = true
|
|
telemetry_events.workspace = true
|
|
text.workspace = true
|
|
thiserror.workspace = true
|
|
toml.workspace = true
|
|
ui.workspace = true
|
|
util.workspace = true
|
|
uuid.workspace = true
|
|
workspace.workspace = true
|
|
worktree.workspace = true
|
|
zed_actions.workspace = true
|
|
zed_credentials_provider.workspace = true
|
|
zeta_prompt.workspace = true
|
|
zstd.workspace = true
|
|
|
|
[dev-dependencies]
|
|
criterion.workspace = true
|
|
fs = { workspace = true, features = ["test-support"] }
|
|
gpui = { workspace = true, features = ["test-support"] }
|
|
languages = { workspace = true, features = ["load-grammars"] }
|
|
node_runtime.workspace = true
|
|
clock = { workspace = true, features = ["test-support"] }
|
|
cloud_llm_client = { workspace = true, features = ["test-support"] }
|
|
ctor.workspace = true
|
|
indoc.workspace = true
|
|
language = { workspace = true, features = ["test-support"] }
|
|
language_model = { workspace = true, features = ["test-support"] }
|
|
lsp.workspace = true
|
|
parking_lot.workspace = true
|
|
project = { workspace = true, features = ["test-support"] }
|
|
settings = { workspace = true, features = ["test-support"] }
|
|
workspace = { workspace = true, features = ["test-support"] }
|
|
|
|
zlog.workspace = true
|
|
|
|
[[bench]]
|
|
name = "kept_rate"
|
|
harness = false
|
|
|
|
[[bench]]
|
|
name = "ts_error_count"
|
|
harness = false
|