Closed tv-ankur closed 6 months ago
@tv-ankur You need to add event listeners for the events you care about. Does OpenAI document the custom event types they use in their stream response?
@mpetazzoni thanks a lot for looking into it.
If anyone is using this library to receive the open ai assistant streaming response, you can subscribe to these event-
source.addEventListener('thread.message.delta', function (e) {
//for getting streamed data
const payload = JSON.parse(e.data)
console.log("delta",payload.delta.content[0].text.value)
})
source.addEventListener('thread.message.completed', function (e) {
//complete response in one go.
const completeMessage = JSON.parse(e.data)
console.log(completeMessage.content[0].text.value)
})
Here is the list of complete event list - https://platform.openai.com/docs/api-reference/assistants-streaming/events
Hi ,
I am using this library at the client side to handle the openai assistant streaming response.
Open AI assistant stream the response in the following format -
The SSE library is unable to capture this response, with no error displayed.
When I connect the SSE, it initially shows state 1, but after some time, it transitions to state 2, indicating that the connection is closed.
I already tested my server api is properly streaming the response.
here is how I have setup the SSE library-
Can anyone help, why its not working?
It is perfectly working when I try to capture the open ai chat completion stream response.
Open ai completion has the following stream format -
So I am guessing its something related to the stream format issue.
**** After some more digging ****
It look like I need to pass the custom event types into the library , but how to do it for the above open ai assistant streaming format?