langserve icon indicating copy to clipboard operation
langserve copied to clipboard

Stream endpoint doesn't work with GZipMiddleware

Open kikohs opened this issue 1 year ago • 3 comments

I was struggling to understand why a RemoteRunnable.stream was not working from langchain JS in the browser

Disabling GZipMiddleware in FastAPI made it work again. Not sure if it's a Starlette/Uvicorn issue or LangServe but might be useful to fix/report.

kikohs avatar Apr 18 '24 19:04 kikohs

https://github.com/tiangolo/fastapi/discussions/8448

eyurtsev avatar Apr 18 '24 19:04 eyurtsev

Does that sound like the same issue?

eyurtsev avatar Apr 18 '24 19:04 eyurtsev

Not sure about the langserve underlying implementation. Here the streaming response is initiated in the browser correctly (with text/event-stream) from langchainJS, when the OpenAI API finishes, all the streaming events are returned.

Like if we were awaiting for the whole response and delivering at once (return instead of yield)

kikohs avatar Apr 18 '24 19:04 kikohs