fix(openai): first chunk emit errors (#337)

This commit is contained in:
Daniel Rodriguez 2024-08-28 17:36:50 -05:00 committed by GitHub
parent 1c4aef68cb
commit bb5411cd9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -95,11 +95,13 @@ M.parse_response = function(data_stream, _, opts)
if choice.finish_reason == "stop" then if choice.finish_reason == "stop" then
opts.on_complete(nil) opts.on_complete(nil)
elseif choice.delta.content then elseif choice.delta.content then
if choice.delta.content ~= vim.NIL then
opts.on_chunk(choice.delta.content) opts.on_chunk(choice.delta.content)
end end
end end
end end
end end
end
M.parse_curl_args = function(provider, code_opts) M.parse_curl_args = function(provider, code_opts)
local base, body_opts = P.parse_config(provider) local base, body_opts = P.parse_config(provider)