Bugfix
This commit is contained in:
1 parent
023a8a202b
commit
909ae9a233
1 file changed
+3
-2
@@ -89,10 +89,10 @@ export const OpenAIStream = async (
|
||||
const onParse = (event: ParsedEvent | ReconnectInterval) => {
|
||||
if (event.type === 'event') {
|
||||
const data = event.data;
|
||||
|
||||
if (data !== '[DONE]') {
|
||||
try {
|
||||
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();
|
||||
return;
|
||||
}
|
||||
@@ -103,6 +103,7 @@ export const OpenAIStream = async (
|
||||
controller.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const parser = createParser(onParse);
|
||||
|
||||
Reference in new issue
Block a user