Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for ChatGPT 4 in code edits. #393

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lua/chatgpt/code_edits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,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
Loading