From a0fc91d4c83750b0d3bf566fcbc76e1f82a826cf Mon Sep 17 00:00:00 2001 From: Andriy Rakhnin Date: Sun, 22 Jun 2025 19:13:15 +0200 Subject: [PATCH] fix: parse_api_key inheritance problem (#2252) --- lua/avante/providers/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/avante/providers/init.lua b/lua/avante/providers/init.lua index 0ea6391..ddc4a73 100644 --- a/lua/avante/providers/init.lua +++ b/lua/avante/providers/init.lua @@ -168,12 +168,12 @@ M = setmetatable(M, { t[k] = provider_config - if t[k].parse_api_key == nil then t[k].parse_api_key = function() return E.parse_envvar(t[k]) end end + if rawget(t[k], "parse_api_key") == nil then t[k].parse_api_key = function() return E.parse_envvar(t[k]) end end -- default to gpt-4o as tokenizer if t[k].tokenizer_id == nil then t[k].tokenizer_id = "gpt-4o" end - if t[k].is_env_set == nil then + if rawget(t[k], "is_env_set") == nil then t[k].is_env_set = function() if not E.require_api_key(t[k]) then return true end local ok, result = pcall(t[k].parse_api_key) @@ -182,7 +182,7 @@ M = setmetatable(M, { end end - if t[k].setup == nil then + if rawget(t[k], "setup") == nil then local provider_conf = M.parse_config(t[k]) t[k].setup = function() if E.require_api_key(provider_conf) then t[k].parse_api_key() end