Skip to content
Snippets Groups Projects
Unverified Commit e9f7b9b7 authored by Timothy Carambat's avatar Timothy Carambat Committed by GitHub
Browse files

Handle undefined stream chunk for native LLM (#534)

parent 74d2711d
No related branches found
No related tags found
No related merge requests found
...@@ -268,6 +268,11 @@ function handleStreamResponses(response, stream, responseProps) { ...@@ -268,6 +268,11 @@ function handleStreamResponses(response, stream, responseProps) {
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
let fullText = ""; let fullText = "";
for await (const chunk of stream) { 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; const content = chunk.hasOwnProperty("content") ? chunk.content : chunk;
fullText += content; fullText += content;
writeResponseChunk(response, { writeResponseChunk(response, {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment