Bugfix
This commit is contained in:
@@ -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