Handle undefined stream chunk for native LLM ()

This commit is contained in:
Timothy Carambat 2024-01-04 18:05:06 -08:00 committed by GitHub
parent 74d2711d80
commit e9f7b9b79e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -268,6 +268,11 @@ function handleStreamResponses(response, stream, responseProps) {
return new Promise(async (resolve) => {
let fullText = "";
for await (const chunk of stream) {
if (chunk === undefined)
throw new Error(
"Stream returned undefined chunk. Aborting reply - check model provider logs."
);
const content = chunk.hasOwnProperty("content") ? chunk.content : chunk;
fullText += content;
writeResponseChunk(response, {