mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 13:40:55 +00:00
fix: catch any errors parsing openai sse events
This commit is contained in:
parent
e9ba8d74d2
commit
510afab37c
@ -32,10 +32,14 @@ async function* openAIStreamToIterator(
|
|||||||
if (line === 'data: [DONE]') {
|
if (line === 'data: [DONE]') {
|
||||||
yield { done: true, value: '' };
|
yield { done: true, value: '' };
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
const data = JSON.parse(line.replace(/^data: /, ''));
|
const data = JSON.parse(line.replace(/^data: /, ''));
|
||||||
console.log(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user