From 2e4666ce6cc8e247ac25e96bcd825201e61206c6 Mon Sep 17 00:00:00 2001 From: AlvisGong Date: Thu, 19 Mar 2026 11:46:31 +0800 Subject: [PATCH 1/6] [Bugfix]Fix bug of online server can not return mutli images Signed-off-by: Hui <1779066624@qq.com> --- vllm_omni/entrypoints/openai/serving_chat.py | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/vllm_omni/entrypoints/openai/serving_chat.py b/vllm_omni/entrypoints/openai/serving_chat.py index 4d93dcf0ab..d2de8d384a 100644 --- a/vllm_omni/entrypoints/openai/serving_chat.py +++ b/vllm_omni/entrypoints/openai/serving_chat.py @@ -2177,19 +2177,20 @@ async def _create_diffusion_chat_completion( # Convert images to base64 content image_contents: list[dict[str, Any]] = [] for img in images: - with BytesIO() as buffer: - img.save(buffer, format="PNG") - img_bytes = buffer.getvalue() - img_base64 = base64.b64encode(img_bytes).decode("utf-8") - image_contents.append( - { - "type": "image_url", - "image_url": { - "url": f"data:image/png;base64,{img_base64}", - }, - "stage_durations": stage_durations, - } - ) + if isinstance(img, list): + for sub_idx, sub_img in enumerate(img): + with BytesIO() as buffer: + sub_img.save(buffer, format="PNG") + img_bytes = buffer.getvalue() + img_base64 = base64.b64encode(img_bytes).decode("utf-8") + image_contents.append( + { + "type": "image_url", + "image_url": { + "url": f"data:image/png;base64,{img_base64}", + }, + } + ) # Build response if not image_contents: From c92f46b9ca3d6b5b5810433b3a14b5a6b5fc8f06 Mon Sep 17 00:00:00 2001 From: Hui <1779066624@qq.com> Date: Thu, 19 Mar 2026 17:02:57 +0800 Subject: [PATCH 2/6] fix version error Signed-off-by: Hui <1779066624@qq.com> --- vllm_omni/entrypoints/openai/serving_chat.py | 35 +++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/vllm_omni/entrypoints/openai/serving_chat.py b/vllm_omni/entrypoints/openai/serving_chat.py index d2de8d384a..a60756f2ca 100644 --- a/vllm_omni/entrypoints/openai/serving_chat.py +++ b/vllm_omni/entrypoints/openai/serving_chat.py @@ -2176,21 +2176,26 @@ async def _create_diffusion_chat_completion( # Convert images to base64 content image_contents: list[dict[str, Any]] = [] - for img in images: - if isinstance(img, list): - for sub_idx, sub_img in enumerate(img): - with BytesIO() as buffer: - sub_img.save(buffer, format="PNG") - img_bytes = buffer.getvalue() - img_base64 = base64.b64encode(img_bytes).decode("utf-8") - image_contents.append( - { - "type": "image_url", - "image_url": { - "url": f"data:image/png;base64,{img_base64}", - }, - } - ) + flat_images = [] + for item in images: + if isinstance(item, list): + flat_images.extend(item) + else: + flat_images.append(item) + + for img in flat_images: + with BytesIO() as buffer: + img.save(buffer, format="PNG") + img_base64 = base64.b64encode(buffer.getvalue()).decode("utf-8") + image_contents.append( + { + "type": "image_url", + "image_url": { + "url": f"data:image/png;base64,{img_base64}", + }, + "stage_durations": stage_durations, + } + ) # Build response if not image_contents: From cf3e60a27ac1a2e67f3f29bc72f3c6c8e839cf4b Mon Sep 17 00:00:00 2001 From: Hui <1779066624@qq.com> Date: Thu, 19 Mar 2026 15:25:01 +0800 Subject: [PATCH 3/6] solve conflict Signed-off-by: Hui <1779066624@qq.com> --- vllm_omni/entrypoints/openai/serving_chat.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vllm_omni/entrypoints/openai/serving_chat.py b/vllm_omni/entrypoints/openai/serving_chat.py index a60756f2ca..6a9f18ffae 100644 --- a/vllm_omni/entrypoints/openai/serving_chat.py +++ b/vllm_omni/entrypoints/openai/serving_chat.py @@ -2173,6 +2173,7 @@ async def _create_diffusion_chat_completion( # Handle nested OmniRequestOutput structure where images might be in request_output images = getattr(result.request_output, "images", []) stage_durations = result.stage_durations + stage_durations = result.stage_durations # Convert images to base64 content image_contents: list[dict[str, Any]] = [] @@ -2196,6 +2197,13 @@ async def _create_diffusion_chat_completion( "stage_durations": stage_durations, } ) + image_contents.append({ + "type": "image_url", + "image_url": { + "url": f"data:image/png;base64,{img_base64}", + }, + "stage_durations": stage_durations, + }) # Build response if not image_contents: From 8b9202dcb69245dabf0e51b74198216ac86a15ee Mon Sep 17 00:00:00 2001 From: Hui <1779066624@qq.com> Date: Thu, 19 Mar 2026 15:37:28 +0800 Subject: [PATCH 4/6] format prob Signed-off-by: Hui <1779066624@qq.com> --- vllm_omni/entrypoints/openai/serving_chat.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/vllm_omni/entrypoints/openai/serving_chat.py b/vllm_omni/entrypoints/openai/serving_chat.py index 6a9f18ffae..4d99410904 100644 --- a/vllm_omni/entrypoints/openai/serving_chat.py +++ b/vllm_omni/entrypoints/openai/serving_chat.py @@ -2197,13 +2197,6 @@ async def _create_diffusion_chat_completion( "stage_durations": stage_durations, } ) - image_contents.append({ - "type": "image_url", - "image_url": { - "url": f"data:image/png;base64,{img_base64}", - }, - "stage_durations": stage_durations, - }) # Build response if not image_contents: From 34edd370ea04457eba02b13ad5f076fa9f0dcd52 Mon Sep 17 00:00:00 2001 From: Hui <1779066624@qq.com> Date: Thu, 19 Mar 2026 15:43:41 +0800 Subject: [PATCH 5/6] fix precommit Signed-off-by: Hui <1779066624@qq.com> --- vllm_omni/entrypoints/openai/serving_chat.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vllm_omni/entrypoints/openai/serving_chat.py b/vllm_omni/entrypoints/openai/serving_chat.py index 4d99410904..2e79625ace 100644 --- a/vllm_omni/entrypoints/openai/serving_chat.py +++ b/vllm_omni/entrypoints/openai/serving_chat.py @@ -1906,9 +1906,6 @@ def _create_image_choice( choices: list[ChatCompletionResponseChoice] = [] final_res = omni_outputs.request_output - # Handle profiling data - stage_durations = omni_outputs.stage_durations - # Handle different image output formats images = [] @@ -1962,7 +1959,6 @@ def _create_image_choice( "image_url": { "url": f"data:image/png;base64,{img_base64}", }, - "stage_durations": stage_durations, } ) From e690866d8c4247e71244c4ea66ce696594a7cf75 Mon Sep 17 00:00:00 2001 From: Hui <1779066624@qq.com> Date: Thu, 19 Mar 2026 17:28:56 +0800 Subject: [PATCH 6/6] rebase main Signed-off-by: Hui <1779066624@qq.com> --- vllm_omni/entrypoints/openai/serving_chat.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vllm_omni/entrypoints/openai/serving_chat.py b/vllm_omni/entrypoints/openai/serving_chat.py index 2e79625ace..a60756f2ca 100644 --- a/vllm_omni/entrypoints/openai/serving_chat.py +++ b/vllm_omni/entrypoints/openai/serving_chat.py @@ -1906,6 +1906,9 @@ def _create_image_choice( choices: list[ChatCompletionResponseChoice] = [] final_res = omni_outputs.request_output + # Handle profiling data + stage_durations = omni_outputs.stage_durations + # Handle different image output formats images = [] @@ -1959,6 +1962,7 @@ def _create_image_choice( "image_url": { "url": f"data:image/png;base64,{img_base64}", }, + "stage_durations": stage_durations, } ) @@ -2169,7 +2173,6 @@ async def _create_diffusion_chat_completion( # Handle nested OmniRequestOutput structure where images might be in request_output images = getattr(result.request_output, "images", []) stage_durations = result.stage_durations - stage_durations = result.stage_durations # Convert images to base64 content image_contents: list[dict[str, Any]] = []