openai-partial-stream icon indicating copy to clipboard operation
openai-partial-stream copied to clipboard

NodeJS + Express

Open neddyKG opened this issue 1 year ago • 2 comments

Thank you so much for the work on this! It's an awesome contribution. On running the Color example in an endpoint I get status of "COMPLETED", when the output didn't finish streaming yet.

Screenshot 2023-11-12 at 10 06 59

neddyKG avatar Nov 12 '23 14:11 neddyKG

My bad, I just saw that for multiple entities the status is "COMPLETED", there wouldn't be any way to identify that the stream finished in that case, right?

neddyKG avatar Nov 12 '23 14:11 neddyKG

Thank you for your question regarding the COMPLETED status. To clarify, this status is assigned to an entity once it has received all the fields that constitute it. This indicates the completion of one entity reception.

As for determining the completion of the entire stream, the stream is explicitly closed when there are no more data to be sent. This closure acts as a signal that the stream has completed.

For a practical example, you can refer to how this is implemented in the colors application. In the specified section of the code, you'll see that when there's no more data to consume, the stream is considered complete. And, specific logic can be executed. In this particular case, the application sends a final Server-Sent Event (SSE) message to indicate the end of the stream and ensures that the client side is properly informed when the stream has finished, allowing to close the event stream on the client.

I hope this helps in the difference between COMPLETED status and the stream ending. If you have any further questions or if you want to share your use case, feel free to ask!

I hope this explanation clarifies the difference between the COMPLETED status and the ending of the stream. If you have more questions, or if you'd like to discuss your specific use case, please feel free.

st3w4r avatar Jan 13 '24 19:01 st3w4r