diff --git a/lib/src/client/openai_client.dart b/lib/src/client/openai_client.dart index 5894b6c..4b5c26b 100644 --- a/lib/src/client/openai_client.dart +++ b/lib/src/client/openai_client.dart @@ -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 = ''; } } },