streaming function `chatsStream` stopped working
manurueda opened this issue · comments
Describe the bug
I have experienced problems when getting an streaming output since today Jan 31st 2023. My previous code was working smoothly, so I believe it could be an update on the output JSON that is creating this errors. Here are some logs I am getting when doing a simple query on streaming that was previously working:
[OpenAIManager:46 - streamChatGPT(text:onReceive:onError:)] Error in chat stream: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected end of file" UserInfo={NSDebugDescription=Unexpected end of file}))). Retry attempt: 0
[OpenAIManagerTests:36 - testStreamChatGPT()] Delta Content:
[OpenAIManagerTests:36 - testStreamChatGPT()] Delta Content: Hello
[OpenAIManagerTests:36 - testStreamChatGPT()] Delta Content: !
[OpenAIManager:46 - streamChatGPT(text:onReceive:onError:)] Error in chat stream: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected end of file" UserInfo={NSDebugDescription=Unexpected end of file}))). Retry attempt: 1
[OpenAIManagerTests:36 - testStreamChatGPT()] Delta Content:
[OpenAIManager:46 - streamChatGPT(text:onReceive:onError:)] Error in chat stream: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected end of file" UserInfo={NSDebugDescription=Unexpected end of file}))). Retry attempt: 2
To Reproduce
Do a basic chatsStream query.
Expected behavior
Consistent output, no errors like "The given data was not valid JSON."
I found a couple of pull requests regarding this issue: #128