Commit 615e9e34 authored by Jun Siang Cheah's avatar Jun Siang Cheah
Browse files

fix: do not error out if OpenAI response has no delta

parent 510afab3
......@@ -36,7 +36,7 @@ async function* openAIStreamToIterator(
const data = JSON.parse(line.replace(/^data: /, ''));
console.log(data);
yield { done: false, value: data.choices[0].delta.content ?? '' };
yield { done: false, value: data.choices?.[0]?.delta?.content ?? '' };
} catch (e) {
console.error('Error extracting delta from SSE event:', e);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment