Skip to content

Commit

Permalink
feat: add support for ChatGPT 4 in code edits. (jackMort#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamiKalliomaki authored and qaptoR committed Jul 6, 2024
1 parent b787ea8 commit 0ddc7f1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lua/chatgpt/code_edits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,20 @@ M.edit_with_instructions = function(output_lines, bufnr, selection, ...)
local output_txt = response
if use_functions_for_edits then
output_txt = Utils.match_indentation(input, response.changed_code)

if response.applied_changes then
vim.notify(response.applied_changes, vim.log.levels.INFO)
local applied_changes = response.applied_changes

-- ChatGPT 4 returns a table of changes, but ChatGPT 3 returns a string.
-- For ChatGPT 4, format the changes as a bullet list.
if type(applied_changes) == "table" then
for i, change in ipairs(applied_changes) do
applied_changes[i] = " - " .. change
end
applied_changes = table.concat(applied_changes, "\n")
end

vim.notify(applied_changes, vim.log.levels.INFO)
end
end
local output_txt_nlfixed = Utils.replace_newlines_at_end(output_txt, nlcount)
Expand Down

0 comments on commit 0ddc7f1

Please sign in to comment.