feat(ollama): provide a helper to enable ollama when service is available

Ollama is disabled by default, as it normally does not require API keys
to be defined. Users are supposed to override is_env_set() method in
their configs to enable Ollama.

Provide check_endpoint_alive() helper in Ollama provider module that can
be used directly in place of is_env_set() and checks whether the server
replies to "get list of models" query:

...
  ollama = {
    is_env_set = require("avante.providers.ollama").check_endpoint_alive,
  },
...
This commit is contained in:
Dmitry Torokhov
2025-10-12 22:30:46 -07:00
parent 3e8557a29e
commit 2f9daf2bc6
3 changed files with 45 additions and 23 deletions

View File

@@ -790,13 +790,14 @@ return {
## Ollama
ollama 是 avante.nvim 的一流提供者。您可以通过在配置中设置 `provider = "ollama"` 来使用它,并 `ollama`设置 `model` 字段为您想要使用的模型。例如:
ollama 是 avante.nvim 的一流提供者。要开始使用它,您需要在配置中设置 `provider = "ollama"`,并 `ollama` `model` 字段设置为您想要使用的模型。Ollama 默认是禁用的,您需要为其 `is_env_set` 方法提供一个实现来正确地启用它。例如:
```lua
provider = "ollama",
providers = {
ollama = {
model = "qwq:32b",
is_env_set = require("avante.providers.ollama").check_endpoint_alive,
},
}
```