Repository navigation
[Fix] Handle user image inputs in Responses API - #5043
Conversation
Add one shared HTTP/SSE image matrix for Chat, Messages, and Responses, exercising PNG/JPEG/WEBP, data and HTTP URLs, image-only input, interleaved multiple images, and multi-turn history with real image decoding. Keep protocol-specific Responses validation tests separate. Cover corrupt-image rejection and text-only model rejection for all three protocols. Generation and remote HTTP transport are simulated; no GPU service is started.
There was a problem hiding this comment.
Overall LGTM, one small nit about UT.
This PR only modify /v1/respponses related, how about removing tests/test_lmdeploy/serve/test_user_images.py, or putting simplified logic in tests/test_lmdeploy/serve/openai/responses/test_images.py, which makes the PR focused and clean.
|
Thanks @CUHKSZzxy, agreed. Addressed in 6a5a32a: removed The broader three-endpoint regression suite is now submitted separately in #5046, so it can be reviewed independently. Production code is unchanged by this revision. The complete serving suite passes (486 tests), and the applicable pre-commit hooks pass. |
Motivation
POST /v1/responsesrejects userinput_imagecontent with HTTP 400 (Unsupported Responses input content part type: 'input_image'.) before model preprocessing, even when the same image works through/v1/chat/completionson the same vision model.Fix this request-conversion gap by forwarding user images through the existing multimodal execution path.
Modification
input_imageblocks into Chat-compatibleimage_urlparts, preserving interleaved text/image order, multiple images, and conversation turns.detailand the existing dynamic-patch image parameters. Preserve raw JSON input dictionaries so SDK TypedDict validation does not discard image extensions; SDK model objects remain supported.This change covers images in user messages. Image file IDs, images in other roles, and image-bearing
function_call_outputremain unsupported. Tool-image ownership/order is handled separately in #5044. Router forwarding changes are outside this PR. Image parameter effects remain model-dependent.BC-breaking (Optional)
No intended breaking changes. Existing supported text and tool-call inputs retain their behavior; valid user image inputs that previously returned HTTP 400 are now accepted for vision-capable models.
Use cases (Optional)
Send a user message containing
input_textandinput_imageto/v1/responses, using either a remote image URL or an image data URL. Both non-streaming and streaming requests use the existing vision-model execution path. See the updated English and Chinese API documentation for complete examples.Validation
6a5a32a4: 486 passed (python -m pytest tests/test_lmdeploy/serve -q).50754852(subsequent changes affect tests only): 17/17 HTTP checks passed, covering PNG/JPEG/WEBP, image-only input, image extensions, two images, multiple turns, remote image fetching, SSE completion, and expected 400 responses for corrupt image data, file IDs, and unknown content types.168158a4: 42/42 ordinary-image HTTP checks passed across Chat, Messages, and Responses, both non-streaming and SSE. Coverage includes PNG/JPEG/WEBP data URLs, image-only input, multiple images, multi-turn image history, and an actual remotely fetched image. Checks compare the final recognition answer and verify successful response/stream completion. The model ran locally on 8 H200 GPUs using the existing Python environment and its actual vision path.git diff --checkpassed.Test scope
tests/test_lmdeploy/serve/openai/responses/test_images.pycontains the focused image regressions for this fix and reuses the existing Responses endpoint fixture. The shared 24-case Chat/Messages/Responses suite is submitted separately in #5046. Tool-result image handling and its three-endpoint tests remain in #5044.The GPU results above were collected at the explicitly recorded earlier commits. The current test-only revision leaves all production code and documentation identical to
168158a4; the serving tests and applicable pre-commit hooks were rerun after the split. No GPU service was started for this revision.Checklist