Skip to content

Commit

Permalink
fix(openai): add backward compat for get_user_message (#813)
Browse files Browse the repository at this point in the history
Co-authored-by: ming.chen <ming.chen@shopee.com>
Co-authored-by: Aaron Pham <Aaronpham0103@gmail.com>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent b872ac9 commit ec9b00d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lua/avante/providers/openai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit ec9b00d

Please sign in to comment.