Skip to content

Commit

Permalink
fix sse
Browse files Browse the repository at this point in the history
  • Loading branch information
redevrx committed Jan 18, 2024
1 parent e8670da commit 1f711f1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/src/client/openai_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,20 @@ class OpenAIClient extends OpenAIWrapper {
// to be truncated, and at this time it needs to be concatenated
// together with 'tmpData'.
try {
final decodeData = json.decode('$tmpData$line');
//add this
tmpData = tmpData + line;

final decodeData = json.decode(tmpData);
controller
..sink
..add(complete(decodeData));
//when success
tmpData = '';
} catch (e) {
// skip
log.log('unexpected exception: $e');
log.log('tmpData=$tmpData\nline=$line');
log.log('$e');
}
tmpData = '';
// tmpData = '';
}
}
},
Expand Down

0 comments on commit 1f711f1

Please sign in to comment.