Repository navigation
feat(dashscope): add qwen-image-edit-plus image edits and qwen3-tts-vc tts - #33862
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Mubashir Osmani seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
…c tts Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
07878cd to
b5f3ea6
Compare
Greptile SummaryThis PR adds two new DashScope surfaces: image editing via
Confidence Score: 3/5Not safe to merge as-is: the TTS response transform makes a blocking network call that stalls the event loop on every async TTS request, and the image-edit helper will raise an unhelpful error for standard tuple-style file inputs. The TTS audio download uses a raw synchronous
|
| Filename | Overview |
|---|---|
| litellm/llms/dashscope/text_to_speech/transformation.py | New DashScope TTS config; contains a blocking httpx.get() call inside transform_text_to_speech_response that stalls the async event loop and bypasses litellm's HTTP infrastructure. |
| litellm/llms/dashscope/image_edit/transformation.py | New DashScope image-edit config; _read_all_bytes does not handle tuple or PathLike variants of FileTypes, causing silent ValueError for common caller patterns; type signature for image also under-specifies the accepted list variant. |
| litellm/main.py | Adds a dashscope TTS dispatch branch, consistent with the existing minimax/aws_polly pattern; no functional issues in the dispatch code itself. |
| litellm/utils.py | Registers dashscope in get_provider_image_edit_config and get_provider_text_to_speech_config following existing provider patterns; straightforward and correct. |
| tests/test_litellm/llms/dashscope/test_dashscope_image_edit_transformation.py | Unit tests use mocks throughout; covers request building, response parsing, error paths; no real network calls. |
| tests/test_litellm/llms/dashscope/test_dashscope_text_to_speech_transformation.py | Unit tests properly patch httpx.get; covers TTS request shape, audio download, and error cases; no real network calls. |
| model_prices_and_context_window.json | Adds metadata for two new dashscope models; supported endpoints look correct. |
| litellm/model_prices_and_context_window_backup.json | Mirror of the canonical model prices file; same additions, consistent. |
Reviews (1): Last reviewed commit: "feat(dashscope): add qwen-image-edit-plu..." | Re-trigger Greptile
| raise self.get_error_class( | ||
| error_message=str(response_json.get("message", response_json)), | ||
| status_code=raw_response.status_code, | ||
| headers=raw_response.headers, | ||
| ) | ||
|
|
There was a problem hiding this comment.
Synchronous HTTP download blocks event loop in async path
transform_text_to_speech_response is called directly from async_text_to_speech_handler (llm_http_handler.py:11495) without await. The httpx.get(audio_url, timeout=60.0) call is a blocking network request — it will stall the entire asyncio event loop for up to 60 seconds on every aspeech call, preventing other coroutines from running. Beyond the async problem, the raw httpx.get usage bypasses litellm's HTTP infrastructure (retries, proxy configuration, OTEL tracing), violating the project rule that custom HTTP handlers must reuse litellm's existing HTTP handler layer.
Rule Used: What: Block any PR which writes it's own custom ht... (source)
| { | ||
| "image": "data:{};base64,{}".format( | ||
| ImageEditRequestUtils.get_image_content_type(img), | ||
| base64.b64encode(self._read_all_bytes(img)).decode("utf-8"), | ||
| ) | ||
| } | ||
| for img in images | ||
| if img is not None | ||
| ] |
There was a problem hiding this comment.
_read_all_bytes silently rejects valid FileTypes variants
FileTypes is a union that includes PathLike, IO[bytes], and tuple forms like (filename, bytes) and (filename, bytes, content_type). Any caller who passes a standard file tuple (the most common form from HTTP multipart clients) or a pathlib.Path reaches the final raise ValueError("Unsupported image type for DashScope image edit.") with no useful hint about what went wrong. Handling only the bytes / BytesIO / BufferedReader subset means most real-world FileTypes values will fail at runtime.
| def transform_image_edit_request( | ||
| self, | ||
| model: str, | ||
| prompt: str | None, | ||
| image: FileTypes | None, |
There was a problem hiding this comment.
The
image parameter is typed as FileTypes | None (matching the base class), but _prepare_image_parts silently accepts a list[FileTypes] — the tests already exercise this path with two images. The public signature should advertise the list variant so callers know it is supported and static type checkers don't flag list arguments.
| def transform_image_edit_request( | |
| self, | |
| model: str, | |
| prompt: str | None, | |
| image: FileTypes | None, | |
| def transform_image_edit_request( | |
| self, | |
| model: str, | |
| prompt: str | None, | |
| image: FileTypes | list[FileTypes] | None, |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Review (LIT-4580)Recommendation: request changes. One blocker, plus a scope gap against the ticket BlockerAsync TTS stalls the event loop. Requirements gapThe ticket asks for dashscope image + TTS (qwen-image-2.0, qwen-image-edit-plus, qwen3-tts-vc), byteplus seedream, pruna, and novita image models. This PR only adds Minor
Nitpicks
GoodClean config-based wiring, registered in both Note: the failing |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… speech dispatch Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Live e2e proof against DashScope is pending a
DASHSCOPE_API_KEY; none is provisioned in this environment. Once a key is available the runbook below reproduces both flows against the real APIType
🆕 New Feature
Changes
Adds two new DashScope surfaces on top of the existing image generation support
qwen-image-edit-plusis wired to the standardized/v1/images/editsroute through a newDashScopeImageEditConfig. DashScope has no OpenAI-style edit endpoint; it uses the multimodal-generation endpoint, so the config sends JSON (not multipart), base64-encodes each input image into adata:URL underinput.messages[].content, and normalizes the returned image URLs back into anImageResponse. Multiple input images are supported. It is registered inProviderConfigManager.get_provider_image_edit_config, and the genericimage_edit_handlerpath picks it upqwen3-tts-vcis wired to/v1/audio/speechthrough a newDashScopeTextToSpeechConfig. DashScope TTS is not OpenAI-compatible; it posts{"model", "input": {"text", "voice", ...}}to the multimodal-generation endpoint and returns an audio file URL valid for 24h, so the response transform downloads that URL and returns the bytes asHttpxBinaryResponseContent.-vcis voice cloning, sovoicecarries a pre-enrolled custom voice id and extra DashScope-specific fields pass throughextra_body. Registered inget_provider_text_to_speech_configplus a dispatch branch inspeech()mirroring the other config-based TTS providersDashScope is listed in
openai_compatible_providersfor chat and embeddings, and thespeech()OpenAI-compatible branch would otherwise intercept the TTS call and post the wrong request shape, so that branch now excludesdashscopeand lets the dedicated config handle itModel metadata for
dashscope/qwen-image-edit-plus(image_generation, edits + generations endpoints) anddashscope/qwen3-tts-vc(audio_speech) is added to both the canonical and backup cost mapsFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/9582d90df7974fb6a678a8a8e4e10372