Skip to content

Commit 57c0696

Browse files
JunKi Jindeathbeam
authored andcommitted
fix: refactor ask function to handle content properly
This commit ensures that response content of non-streaming types (when is_stream has false) is not ignored due to the finish_reason.
1 parent 1fe19d1 commit 57c0696

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lua/CopilotChat/copilot.lua

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -635,25 +635,19 @@ function Copilot:ask(prompt, opts)
635635

636636
last_message = content
637637
local choice = content.choices[1]
638-
639-
if choice.finish_reason then
640-
if job then
641-
finish_stream(nil, job)
642-
end
643-
return
644-
end
645-
646638
content = choice.message and choice.message.content or choice.delta and choice.delta.content
647639

648-
if not content then
649-
return
640+
if content then
641+
full_response = full_response .. content
650642
end
651643

652-
if on_progress then
644+
if content and on_progress then
653645
on_progress(content)
654646
end
655647

656-
full_response = full_response .. content
648+
if choice.finish_reason and job then
649+
finish_stream(nil, job)
650+
end
657651
end
658652

659653
local function parse_stream_line(line, job)

0 commit comments

Comments
 (0)