bug: in function 'get_user_message'
Closed this issue · 4 comments
Describe the bug
E5108: Error executing lua: /Users/tao/.config/nvim/lua/plugins/avante.lua:104: invalid value (table) at index 1 in table for 'concat'
stack traceback:
[C]: in function 'get_user_message'
/Users/tao/.config/nvim/lua/plugins/avante.lua:104: in function 'parse_curl_args'
...ao/.local/share/nvim/lazy/avante.nvim/lua/avante/llm.lua:136: in function 'stream'
...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:1432: in function 'handle_submit'
...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:1488: in function <...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:1478>
To reproduce
return {
"yetone/avante.nvim",
build = ":AvanteBuild",
-- init = function()
-- local config = require "avante.config"
-- config.auto_suggestions_provider = "deepseek"
-- end,
cmd = {
"AvanteAsk",
"AvanteBuild",
"AvanteEdit",
"AvanteRefresh",
"AvanteSwitchProvider",
"AvanteChat",
"AvanteToggle",
"AvanteClear",
},
dependencies = {
{
-- support for image pasting
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
},
},
{
-- Make sure to set this up properly if you have lazy=true
"MeanderingProgrammer/render-markdown.nvim",
opts = {
file_types = { "markdown", "Avante" },
},
ft = { "markdown", "Avante" },
},
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
{
"AstroNvim/astrocore",
opts = function(_, opts)
local maps = assert(opts.mappings)
local prefix = "a"
maps.n[prefix] = { desc = "Avante functionalities" }
maps.n[prefix .. "a"] = { function() require("avante.api").ask() end, desc = "Avante ask" }
maps.v[prefix .. "a"] = { function() require("avante.api").ask() end, desc = "Avante ask" }
maps.v[prefix .. "r"] = { function() require("avante.api").refresh() end, desc = "Avante refresh" }
maps.n[prefix .. "e"] = { function() require("avante.api").edit() end, desc = "Avante edit" }
maps.v[prefix .. "e"] = { function() require("avante.api").edit() end, desc = "Avante edit" }
-- the following key bindings do not have an official api implementation
maps.n.co = { "<Plug>(AvanteConflictOurs)", desc = "Choose ours", expr = true }
maps.v.co = { "<Plug>(AvanteConflictOurs)", desc = "Choose ours", expr = true }
maps.n.ct = { "<Plug>(AvanteConflictTheirs)", desc = "Choose theirs", expr = true }
maps.v.ct = { "<Plug>(AvanteConflictTheirs)", desc = "Choose theirs", expr = true }
maps.n.ca = { "<Plug>(AvanteConflictAllTheirs)", desc = "Choose all theirs", expr = true }
maps.v.ca = { "<Plug>(AvanteConflictAllTheirs)", desc = "Choose all theirs", expr = true }
maps.n.cb = { "<Plug>(AvanteConflictBoth)", desc = "Choose both", expr = true }
maps.v.cb = { "<Plug>(AvanteConflictBoth)", desc = "Choose both", expr = true }
maps.n.cc = { "<Plug>(AvanteConflictCursor)", desc = "Choose cursor", expr = true }
maps.v.cc = { "<Plug>(AvanteConflictCursor)", desc = "Choose cursor", expr = true }
maps.n["]x"] = { "<Plug>(AvanteConflictPrevConflict)", desc = "Move to previous conflict", expr = true }
maps.n["[x"] = { "<Plug>(AvanteConflictNextConflict)", desc = "Move to next conflict", expr = true }
end,
},
},
opts = {
provider = "deepseek",
vendors = {
deepseek = {
endpoint = "https://api.deepseek.com/chat/completions",
model = "deepseek-coder",
api_key_name = "DEEPSEEK_API_KEY",
parse_curl_args = function(opts, code_opts)
return {
url = opts.endpoint,
headers = {
["Accept"] = "application/json",
["Content-Type"] = "application/json",
["Authorization"] = "Bearer " .. os.getenv(opts.api_key_name),
},
body = {
model = opts.model,
messages = { -- you can make your own message, but this is very advanced
{
role = "system",
content = [[
Act as an expert software developer.
Always use best practices when coding.
Respect and use existing conventions, libraries, etc that are already present in the code base.
Always respond in Chinese.
]],
},
{ role = "user", content = require("avante.providers.openai").get_user_message(code_opts) },
},
temperature = 0,
max_tokens = 4096,
stream = true, -- this will be set by default.
},
}
end,
parse_response_data = function(data_stream, event_state, opts)
require("avante.providers").openai.parse_response(data_stream, event_state, opts)
end,
},
},
behaviour = {
auto_suggestions = false, -- Experimental stage
auto_set_highlight_group = true,
auto_set_keymaps = true,
auto_apply_diff_after_generation = false,
support_paste_from_clipboard = false,
},
},
specs = {},
}
Expected behavior
No response
Installation method
Use lazy.nvim:
{
"yetone/avante.nvim",
event = "VeryLazy",
lazy = false,
version = false, -- set this if you want to always pull the latest change
opts = {
-- add any opts here
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
build = "make",
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
dependencies = {
"nvim-treesitter/nvim-treesitter",
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
},
}
Environment
NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1727870382
Run "nvim -V1 -v" for more info
Repro
https://github.com/taotao7/dotfile/blob/master/vim/astrovim/plugins/avante.lua
I had the error, updated the plugin and it's working again.
It works after the update, but now it tells me that get_user_message is obsolete.
ok. i fixed it
parse_curl_args = function(opts, code_opts)
code_opts.system_prompt = [[Act as an expert software developer.
Always use best practices when coding.
Respect and use existing conventions, libraries, etc that are already present in the code base.
Always respond in Chinese.]]
return {
url = opts.endpoint,
headers = {
["Accept"] = "application/json",
["Content-Type"] = "application/json",
["Authorization"] = "Bearer " .. os.getenv(opts.api_key_name),
},
body = {
model = opts.model,
messages = require("avante.providers.openai").parse_messages(code_opts),
temperature = 0,
max_tokens = 4096,
stream = true, -- this will be set by default.
},
}
end,
I am having the same issue as you, update didn't fix the issue. I happens with all the providers (claude, copilot, etc.) can you please give more details about your fix? Thank you sir!