Skip to content

Commit

Permalink
Fix sse bad state close
Browse files Browse the repository at this point in the history
  • Loading branch information
gamestap99 committed Nov 21, 2023
1 parent 2415d53 commit 356206b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/client/openai_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ class OpenAIClient extends OpenAIWrapper {
final mData = data.substring(6);
if (mData.startsWith("[DONE]")) {
log.log("stream response is done");
controller.done;
controller.close();

return;
}
Expand All @@ -283,8 +285,6 @@ class OpenAIClient extends OpenAIWrapper {
controller
..sink
..add(complete(jsonMap[jsonMap.keys.last]));

controller.close();
} else {
log.log("stream response invalid try regenerate");
log.log("last json error :$mData");
Expand Down

0 comments on commit 356206b

Please sign in to comment.