yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
6.4k stars 229 forks source link

can't switch provider after the update - many errors #161

Closed bassamsdata closed 2 months ago

bassamsdata commented 2 months ago

Hello, thank you for all the updates to this plugin. Currently, I'm encountering two issues:

  1. I can't seem to switch providers using the AvanteSwitchProvider command, as it always complains about the has() function in every provider.

errors I have:

Error executing Lua callback: ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:217: attempt to call field 'has' (a nil value)
stack traceback:
    ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:217: in function 'refresh'
    ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:231: in function <...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:229>
Error executing Lua callback: ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:217: attempt to call field 'has' (a nil value)
stack traceback:
    ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:217: in function 'refresh'
    ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:231: in function <...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:229>

When I open Avante for the first time, it also throws the same error. Please note that I've set the provider to a custom one, "mistral."

Error executing vim.schedule lua callback: ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:177: attempt to call field 'has' (a nil value)
stack traceback:
    ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:177: in function ''
    vim/_editor.lua: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:177: attempt to call field 'has' (a nil value)
stack traceback:
    ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:177: in function ''
    vim/_editor.lua: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:177: attempt to call field 'has' (a nil value)
stack traceback:
    ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:177: in function ''
    vim/_editor.lua: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
  1. Every time I switch the provider, my custom provider "mistral" gets duplicated. The screenshot below clearly illustrates the issue. Screenshot 2024-08-23 at 1 02 38 AM
Avante config ```lua local avantWdith = vim.g.neovide and 40 or 30 return { { "yetone/avante.nvim", keys = { { "aa", }, }, opts = { windows = { wrap_line = true, -- similar to vim.o.wrap width = avantWdith, -- default % based on available width sidebar_header = { align = "center", -- left, center, right for title rounded = false, }, }, provider = "mistral", -- "claude" or "openai" or "azure" claude = { endpoint = "https://api.anthropic.com", model = "claude-3-5-sonnet-20240620", temperature = 0, max_tokens = 4096, }, groq = { endpoint = "https://api.groq.com", model = "llama-3.1-70b-versatile", temperature = 0, max_tokens = 4096, ["local"] = false, }, gemini = { endpoint = "", type = "gemini", model = "gemini-1.5-pro", options = {}, }, vendors = { mistral = { endpoint = "https://codestral.mistral.ai/v1/chat/completions", model = "codestral-latest", api_key_name = "CODESTRAL_API_KEY", parse_curl_args = function(opts, code_opts) local api_key = os.getenv(opts.api_key_name) local Llm = require("avante.providers") return { url = opts.endpoint, headers = { ["Accept"] = "application/json", ["Content-Type"] = "application/json", ["Authorization"] = "Bearer " .. api_key, }, body = { model = opts.model, messages = Llm.openai.parse_message(code_opts), temperature = 0.7, max_tokens = 8192, stream = true, safe_prompt = false, }, } end, parse_response_data = function(data_stream, event_state, opts) local Llm = require("avante.providers") Llm.openai.parse_response(data_stream, event_state, opts) end, }, }, }, build = "make", dependencies = { "echasnovski/mini.icons", "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", "MeanderingProgrammer/markdown.nvim", "stevearc/dressing.nvim", }, }, } ```

thank you

bassamsdata commented 2 months ago

please note that the issue occurred after PR #158.

bassamsdata commented 2 months ago

thank you for the quick fix