fix: invalid response err (#19)
This commit is contained in:
parent
2674872945
commit
78be877a3e
@ -237,11 +237,13 @@ local function call_openai_api_stream(question, code_lang, code_content, on_chun
|
|||||||
error("Error: failed to parse json: " .. parsed)
|
error("Error: failed to parse json: " .. parsed)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if parsed and parsed.choices and parsed.choices[1].delta.content then
|
if parsed and parsed.choices and parsed.choices[1] then
|
||||||
on_chunk(parsed.choices[1].delta.content)
|
local choice = parsed.choices[1]
|
||||||
elseif parsed and parsed.choices and parsed.choices[1].finish_reason == "stop" then
|
if choice.finish_reason == "stop" then
|
||||||
-- Stream request completed
|
|
||||||
on_complete(nil)
|
on_complete(nil)
|
||||||
|
elseif choice.delta and choice.delta.content then
|
||||||
|
on_chunk(choice.delta.content)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user