Skip to content

Commit 6a2cdb8

Browse files
authored
fix(api-nodes-nanobana): raise error when not output image is present (#13167)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
1 parent 85b7495 commit 6a2cdb8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

comfy_api_nodes/nodes_gemini.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ async def get_image_from_response(response: GeminiGenerateContentResponse, thoug
201201
returned_image = await download_url_to_image_tensor(part.fileData.fileUri)
202202
image_tensors.append(returned_image)
203203
if len(image_tensors) == 0:
204+
if not thought:
205+
# No images generated --> extract text response for a meaningful error
206+
model_message = get_text_from_response(response).strip()
207+
if model_message:
208+
raise ValueError(f"Gemini did not generate an image. Model response: {model_message}")
209+
raise ValueError(
210+
"Gemini did not generate an image. "
211+
"Try rephrasing your prompt or changing the response modality to 'IMAGE+TEXT' "
212+
"to see the model's reasoning."
213+
)
204214
return torch.zeros((1, 1024, 1024, 4))
205215
return torch.cat(image_tensors, dim=0)
206216

0 commit comments

Comments
 (0)