Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Streaming Response for Application Load Balancer + Lambda (Fastapi : server sent event -> streaming response) #341

Open
GxWwT opened this issue Nov 27, 2024 · 1 comment

Comments

@GxWwT
Copy link

GxWwT commented Nov 27, 2024

from fastapi.responses import StreamingResponse

if chat_request.stream:
    return StreamingResponse(
        content=model.chat_stream(chat_request), media_type="text/event-stream"
    )

This approach, when redirected to ALB through Mangum, loses the streaming response. Instead, all chunks are printed out all at once.

@KamilLegault
Copy link

I dont think this is a mangum issue, the Python runtimes on AWS Lambda do not support streaming.

Look into the AWS lambda web adapter https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/fastapi-response-streaming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants