Bugfix
This commit is contained in:
@@ -89,10 +89,10 @@ export const OpenAIStream = async (
|
|||||||
const onParse = (event: ParsedEvent | ReconnectInterval) => {
|
const onParse = (event: ParsedEvent | ReconnectInterval) => {
|
||||||
if (event.type === 'event') {
|
if (event.type === 'event') {
|
||||||
const data = event.data;
|
const data = event.data;
|
||||||
|
if (data !== '[DONE]') {
|
||||||
try {
|
try {
|
||||||
const json = JSON.parse(data);
|
const json = JSON.parse(data);
|
||||||
if (json.choices[0].finish_reason != null) {
|
if (json.choices[0].finish_reason != null || json.choices[0].finish_details != null) {
|
||||||
controller.close();
|
controller.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -103,6 +103,7 @@ export const OpenAIStream = async (
|
|||||||
controller.error(e);
|
controller.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const parser = createParser(onParse);
|
const parser = createParser(onParse);
|
||||||
|
|||||||
Reference in New Issue
Block a user