feat(providers): add support for custom vendors (#74)

* feat(providers): add support for custom vendors

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* fix: override configuration not setup

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-08-18 22:20:29 -04:00
committed by GitHub
parent 5fa4f701dd
commit 2700cad921
5 changed files with 260 additions and 76 deletions

View File

@@ -6,7 +6,7 @@ local M = {}
---@class avante.Config
M.defaults = {
---@alias Provider "openai" | "claude" | "azure" | "deepseek" | "groq"
---@alias Provider "openai" | "claude" | "azure" | "deepseek" | "groq" | [string]
provider = "claude", -- "claude" or "openai" or "azure" or "deepseek" or "groq"
openai = {
endpoint = "https://api.openai.com",
@@ -39,6 +39,10 @@ M.defaults = {
temperature = 0,
max_tokens = 4096,
},
--- To add support for custom provider, follow the format below
--- See https://github.com/yetone/avante.nvim/README.md#custom-providers for more details
---@type table<string, AvanteProvider>
vendors = {},
behaviour = {
auto_apply_diff_after_generation = false, -- Whether to automatically apply diff after LLM response.
},
@@ -100,6 +104,11 @@ function M.setup(opts)
)
end
---@param opts? avante.Config
function M.override(opts)
M.options = vim.tbl_deep_extend("force", M.options, opts or {})
end
M = setmetatable(M, {
__index = function(_, k)
if M.options[k] then