[Bugfix] Forward backend Content-Type in StreamingResponse#880
[Bugfix] Forward backend Content-Type in StreamingResponse#880shernshiou wants to merge 3 commits intovllm-project:mainfrom
Conversation
Signed-off-by: Shern Shiou Tan <shernshiou@gmail.com>
Signed-off-by: Shern Shiou Tan <shernshiou@gmail.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the vLLM router was incorrectly handling binary audio streams, leading to truncation and service crashes. The changes ensure that the router accurately forwards the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses two issues related to handling non-text responses, specifically for audio streaming. The changes are well-implemented and logical. First, dynamically forwarding the Content-Type from the backend instead of hardcoding it ensures that clients receive the correct media type, which is crucial for binary data like audio. Second, gracefully handling decoding errors during token tracking prevents crashes when processing binary response chunks. The addition of a comprehensive test suite in src/tests/test_audio_speech_routing.py is excellent, as it covers the new functionality, regressions, and edge cases, ensuring the fixes are robust. The changes are clean, targeted, and improve the router's reliability.
56b8dea to
986bdd0
Compare
Signed-off-by: Shern Shiou Tan <shernshiou@gmail.com>
986bdd0 to
50e633b
Compare
Problem
When using the vLLM router with vLLM-omni + Qwen3-TTS, audio streams returned via
/v1/audio/speechget interrupted/truncated. The same TTS request works perfectly when sent directly to the vLLM backend, but fails when routed through the production-stack router.In
src/vllm_router/services/request_service/request.py, theStreamingResponsehardcodesmedia_type="text/event-stream". This forces SSE framing on binary audio responses, corrupting the audio data and causing clients to misinterpret the stream.Additionally, process_request attempts to JSON-decode every response chunk for token tracking, which raises UnicodeDecodeError on binary (non-UTF-8) audio payloads and crashes the request pipeline.
Changes
Dynamic Content-Type forwarding
StreamingResponsenow uses the backend'sContent-Typeheader instead of always assumingtext/event-stream. Falls back totext/event-streamwhen the header is absent.Graceful handling of binary responses
Token-tracking now catches
UnicodeDecodeErrorandValueErroralongsidejson.JSONDecodeError, so binary audio chunks no longer crash the pipeline.-swhen doinggit commit[Bugfix],[Feat], and[CI].Detailed Checklist (Click to Expand)
Thank you for your contribution to production-stack! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]for bug fixes.[CI/Build]for build or continuous integration improvements.[Doc]for documentation fixes and improvements.[Feat]for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).[Router]for changes to thevllm_router(e.g., routing algorithm, router observability, etc.).[Misc]for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
pre-committo format your code. SeeREADME.mdfor installation.DCO and Signed-off-by
When contributing changes to this project, you must agree to the DCO. Commits must include a
Signed-off-by:header which certifies agreement with the terms of the DCO.Using
-swithgit commitwill automatically add this header.What to Expect for the Reviews
We aim to address all PRs in a timely manner. If no one reviews your PR within 5 days, please @-mention one of YuhanLiu11
, Shaoting-Feng or ApostaC.