feat: add ollama as supported provider (#1543)

* feat: add ollama as supported provider

*This implementation is only working with `stream = true`*
- Uses the actual ollama api and allows for passing additional options
- Properly passes the system prompt to api

Use ollama as provider in opts like this:
opts = {
        debug = true,
        provider = "ollama",
        ollama = {
                api_key_name = "",
                endpoint = "http://127.0.0.1:11434",
                model = "qwen2.5-coder:latest",
                options = {
                        num_ctx = 32768,
                        temperature = 0,
                },
                stream = true,
        },

* fix: ollama types

---------

Co-authored-by: jtabke <25010496+jtabke@users.noreply.github.com>
This commit is contained in:
yetone
2025-03-10 02:23:56 +08:00
committed by GitHub
parent 4976807a33
commit 750ee80971
5 changed files with 100 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ local DressingState = { winid = nil, input_winid = nil, input_bufnr = nil }
---@field gemini AvanteProviderFunctor
---@field cohere AvanteProviderFunctor
---@field bedrock AvanteBedrockProviderFunctor
---@field ollama AvanteProviderFunctor
local M = {}
---@class EnvironmentHandler
@@ -152,8 +153,13 @@ M = setmetatable(M, {
__index = function(t, k)
local provider_config = M.get_config(k)
if Config.vendors[k] ~= nil and k == "ollama" then
Utils.warn(
"ollama is now a first-class provider in avante.nvim, please stop using vendors to define ollama, for migration guide please refer to: https://github.com/yetone/avante.nvim/wiki/Custom-providers#ollama"
)
end
---@diagnostic disable: undefined-field,no-unknown,inject-field
if Config.vendors[k] ~= nil then
if Config.vendors[k] ~= nil and k ~= "ollama" then
if provider_config.parse_response_data ~= nil then
Utils.error("parse_response_data is not supported for avante.nvim vendors")
end