Skip to content

Commit

Permalink
Merge pull request #79 from gamestap99/fix-sse
Browse files Browse the repository at this point in the history
Fix sse bad state close
  • Loading branch information
redevrx committed Nov 22, 2023
2 parents 2415d53 + 356206b commit dd34388
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 dd34388

Please sign in to comment.