sysid / sse-starlette

BSD 3-Clause "New" or "Revised" License
504 stars 35 forks source link

Multiple events grouped as one event #66

Closed cirezd closed 11 months ago

cirezd commented 11 months ago

Hi, I have one issue on the client-side when using the API using this library/fastapi and I am unable to pin-point the issue. Sometimes I receive events grouped as one single event, like this:

--
event: token
data:

event: token
data: It

event: token
data: does
--

instead of

--
event: token
data:
--
event: token
data: It
--
event: token
data: does
--

Are there any settings or changes one can make to prevent this? In my generator I am actually yielding ServerSentEvents, so I believe it is not related to the generator itself, otherwise this wouldn't work. Any advice is appreciated!

sysid commented 11 months ago

Hi @cirezd , I am not aware of any backend configuration which might relate to your observations, I am afraid. If you can provide the code I could try to reproduce, though.

cirezd commented 11 months ago

Thanks @sysid that already helps. We used a different method of parsing the input on the client side and now it is not an issue anymore. I was wondering about whether events get grouped together and send via one package, if the time between generated events is small. I use sse-starlette in the context of langchain and tokens arrive quite irregular from the LLMs.

sysid commented 11 months ago

Thanks for the feedback @cirezd , so I close the issue.