SSE Client in golang issues with fine tune event streaming

I have been working on a terraform provider for OpenAI.
As part of the implementation, i utilised SSE event streaming to wait for fine tune completion.
However, I think there are some issues with OpenAI’s implementation of SSE.

  1. It looks like there is no LAST-EVENT-ID which means that all events are replayed on re-connection.
  2. The [DONE] message is bespoke to OpenAI.

In any case, I created a go SSEcleint that can be found on github under my handle @skyscrapr.

Just wondering if there is any chance of resolving the issues with the SSE implementation to make it more standard.

1 Like

I’ve created a fair number of streaming applications that make use of the SSE capabilities, never ran in to this replaying of content issue you mention, are you saying that if I break connection in the middle of a streaming session, I will be sent the entirety of the data again?

Unless I’m doing something wrong, whenever you make the call to begin the stream, you will get all the events from the beginning. The SSE spec handles this by using a LAST-EVENT-ID header to allow restarting the stream at the last event. This is not part of the Open AI implementation of SSE. And in my testing the server is issuing a 60s connection reset.

My guess is the python library handles this in the background.

Hmm, I am using the OpenAI python lib, and in my case I use a VPS as the server, I know some deployment environments like Google app Engine do not play nice with SSE, just wondering if it’s something long those lines causing the issue, as my VPS based chat servers do not exhibit that behaviour… could be (like you say) using the [DONE] message as a trigger, but not 100% sure.