mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
Merge pull request #2183 from cheahjs/fix/streaming-error
feat: better handle openai errors, add error message to message
This commit is contained in:
@@ -6,6 +6,8 @@ type TextStreamUpdate = {
|
||||
value: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
citations?: any;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
error?: any;
|
||||
};
|
||||
|
||||
// createOpenAITextStream takes a responseBody with a SSE response,
|
||||
@@ -47,6 +49,11 @@ async function* openAIStreamToIterator(
|
||||
const parsedData = JSON.parse(data);
|
||||
console.log(parsedData);
|
||||
|
||||
if (parsedData.error) {
|
||||
yield { done: true, value: '', error: parsedData.error };
|
||||
break;
|
||||
}
|
||||
|
||||
if (parsedData.citations) {
|
||||
yield { done: false, value: '', citations: parsedData.citations };
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user