fix(openai): add backward compat for get_user_message (#813)

Co-authored-by: ming.chen <ming.chen@shopee.com>
Co-authored-by: Aaron Pham <Aaronpham0103@gmail.com>
This commit is contained in:
insects 2024-11-07 15:16:19 +08:00 committed by GitHub
parent b872ac9c12
commit ec9b00db8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,7 +39,17 @@ M.role_map = {
}
---@param opts AvantePromptOptions
M.get_user_message = function(opts) return table.concat(opts.messages, "\n") end
M.get_user_message = function(opts)
vim.deprecate("get_user_message", "parse_messages", "0.1.0", "avante.nvim")
return table.concat(
vim.iter(opts.messages):filter(function(_, value) return value.role == "user" end):fold({}, function(acc, value)
acc = vim.list_extend({}, acc)
acc = vim.list_extend(acc, { value.content })
return acc
end),
"\n"
)
end
M.parse_messages = function(opts)
local messages = {}