Skip to content

Commit

Permalink
Handle undefined stream chunk for native LLM (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycarambat authored Jan 5, 2024
1 parent 74d2711 commit e9f7b9b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/utils/chats/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit e9f7b9b

Please sign in to comment.