fix: preset vendors missing many fields (#851)

This commit is contained in:
yetone 2024-11-16 02:09:14 +08:00 committed by GitHub
parent 7bab283616
commit a3e5053d55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View File

@ -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"
@ -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,
@ -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,
@ -340,6 +340,7 @@ M.BASE_PROVIDER_KEYS = {
"tokenizer_id",
"use_xml_format",
"role_map",
"__inherited_from",
}
return M

View File

@ -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
---
@ -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