Skip to content

Commit

Permalink
fix: preset vendors missing many fields (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone authored Nov 15, 2024
1 parent 7bab283 commit a3e5053
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lua/avante/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local M = {}
---@class avante.Config
M.defaults = {
debug = false,
---@alias Provider "claude" | "openai" | "azure" | "gemini" | "vertex" | "cohere" | "copilot" | [string]
---@alias Provider "claude" | "openai" | "azure" | "gemini" | "vertex" | "cohere" | "copilot" | string
provider = "claude", -- Only recommend using Claude
auto_suggestions_provider = "claude",
---@alias Tokenizer "tiktoken" | "hf"
Expand Down Expand Up @@ -88,7 +88,7 @@ M.defaults = {
vendors = {
---@type AvanteSupportedProvider
["claude-haiku"] = {
endpoint = "https://api.anthropic.com",
__inherited_from = "claude",
model = "claude-3-5-haiku-20241022",
timeout = 30000, -- Timeout in milliseconds
temperature = 0,
Expand All @@ -97,7 +97,7 @@ M.defaults = {
},
---@type AvanteSupportedProvider
["claude-opus"] = {
endpoint = "https://api.anthropic.com",
__inherited_from = "claude",
model = "claude-3-opus-20240229",
timeout = 30000, -- Timeout in milliseconds
temperature = 0,
Expand Down Expand Up @@ -340,6 +340,7 @@ M.BASE_PROVIDER_KEYS = {
"tokenizer_id",
"use_xml_format",
"role_map",
"__inherited_from",
}

return M
11 changes: 10 additions & 1 deletion lua/avante/providers/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ local DressingState = { winid = nil, input_winid = nil, input_bufnr = nil }
---@field _shellenv? string
---
---@class AvanteSupportedProvider: AvanteDefaultBaseProvider
---@field __inherited_from? string
---@field temperature? number
---@field max_tokens? number
---
Expand Down Expand Up @@ -267,7 +268,15 @@ M = setmetatable(M, {
---@diagnostic disable: undefined-field,no-unknown,inject-field
if Config.vendors[k] ~= nil then
Opts.parse_response = Opts.parse_response_data
t[k] = Opts
if Opts.__inherited_from ~= nil then
local BaseOpts = M.get_config(Opts.__inherited_from)
local ok, module = pcall(require, "avante.providers." .. Opts.__inherited_from)
if not ok then error("Failed to load provider: " .. Opts.__inherited_from) end
Opts._shellenv = module.api_key_name ~= M.AVANTE_INTERNAL_KEY and module.api_key_name or nil
t[k] = vim.tbl_deep_extend("keep", BaseOpts, Opts, module)
else
t[k] = Opts
end
else
local ok, module = pcall(require, "avante.providers." .. k)
if not ok then error("Failed to load provider: " .. k) end
Expand Down

0 comments on commit a3e5053

Please sign in to comment.