fix: check on_chunk if it is a nil (#1998)
This commit is contained in:
@@ -335,7 +335,8 @@ function M:parse_response_without_stream(data, _, opts)
|
|||||||
if json.choices and json.choices[1] then
|
if json.choices and json.choices[1] then
|
||||||
local choice = json.choices[1]
|
local choice = json.choices[1]
|
||||||
if choice.message and choice.message.content then
|
if choice.message and choice.message.content then
|
||||||
opts.on_chunk(choice.message.content)
|
if opts.on_chunk then opts.on_chunk(choice.message.content) end
|
||||||
|
self:add_text_message({}, choice.message.content, "generated", opts)
|
||||||
vim.schedule(function() opts.on_stop({ reason = "complete" }) end)
|
vim.schedule(function() opts.on_stop({ reason = "complete" }) end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user