[Bugfix] fix: return 400 for unsupported multi-image edits such as Qwen-Image-Layered (#2298)

Signed-off-by: David Chen <530634352@qq.com>
This commit is contained in:
WeiQing Chen authored and GitHub committed 2026-03-30 20:24:57 +08:00
1 parent 911be0d426
commit 1eee8435e1
6 files changed
+91

No files matched your search

+17
View File
@@ -118,6 +118,23 @@ class AsyncOmni(EngineClient, OmniBase):
"""Compatibility helper for call sites expecting async vllm config access."""
return self.vllm_config
def get_diffusion_od_config(self) -> Any | None:
"""Return the diffusion-stage config when the pipeline has one."""
for stage_client in self.engine.stage_clients:
if getattr(stage_client, "stage_type", None) != "diffusion":
continue
od_config = getattr(stage_client, "od_config", None)
if od_config is not None:
return od_config
inner_engine = getattr(stage_client, "_engine", None)
od_config = getattr(inner_engine, "od_config", None)
if od_config is not None:
return od_config
return None
@property
def model_config(self):
"""Return the model config for the comprehension stage when present."""
@@ -251,6 +251,10 @@ class AsyncOmniDiffusion:
finished=True,
)
def get_diffusion_od_config(self) -> OmniDiffusionConfig:
"""Return the diffusion config used by this engine."""
return self.od_config
# ------------------------------------------------------------------
# Public generate API
# ------------------------------------------------------------------
@@ -1406,6 +1406,11 @@ async def edit_images(
if not input_images_list:
raise HTTPException(status_code=422, detail="Field 'image' or 'url' is required")
pil_images = await _load_input_images(input_images_list)
if len(pil_images) > 1 and not _supports_multimodal_image_inputs(raw_request, engine_client):
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST.value,
detail="Received multiple input images. Only a single image is supported by this model.",
)
prompt["multi_modal_data"] = {}
prompt["multi_modal_data"]["image"] = pil_images
@@ -1584,6 +1589,20 @@ def _get_engine_and_model(raw_request: Request):
return engine_client, model_name, normalized_stage_configs
def _supports_multimodal_image_inputs(raw_request: Request, engine_client: Any) -> bool:
diffusion_engine = getattr(raw_request.app.state, "diffusion_engine", None) or engine_client
get_diffusion_od_config = getattr(diffusion_engine, "get_diffusion_od_config", None)
od_config = (
get_diffusion_od_config() if callable(get_diffusion_od_config) else getattr(diffusion_engine, "od_config", None)
)
if od_config is None:
# Preserve the existing compatibility behavior when the diffusion
# config is not exposed on the serving surface.
return True
return bool(getattr(od_config, "supports_multimodal_inputs", False))
def _get_lora_from_json_str(lora_body):
if lora_body is None:
return None