mirror of
https://github.com/Comfy-Org/ComfyUI.git
synced 2026-08-05 18:05:08 +08:00
[Partner Nodes] fix(GPT Image): make custom_width/custom_height optional
OpenAIGPTImageNodeV2 declared the gpt-image-2 custom size widgets as required nested inputs, so a prompt that picked a preset size and omitted them failed validation with required_input_missing. execute() already reads both with a 1024 default, and the deprecated OpenAIGPTImage1 node in the same file already marks them optional.
This commit is contained in:
@@ -747,6 +747,7 @@ class OpenAIGPTImageNodeV2(IO.ComfyNode):
|
||||
max=3840,
|
||||
step=16,
|
||||
tooltip="Used only when `size` is 'Custom'. Must be a multiple of 16.",
|
||||
optional=True,
|
||||
),
|
||||
IO.Int.Input(
|
||||
"custom_height",
|
||||
@@ -755,6 +756,7 @@ class OpenAIGPTImageNodeV2(IO.ComfyNode):
|
||||
max=3840,
|
||||
step=16,
|
||||
tooltip="Used only when `size` is 'Custom'. Must be a multiple of 16.",
|
||||
optional=True,
|
||||
),
|
||||
IO.Combo.Input(
|
||||
"background",
|
||||
|
||||
27
tests-unit/comfy_api_test/gpt_image_size_inputs_test.py
Normal file
27
tests-unit/comfy_api_test/gpt_image_size_inputs_test.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from comfy_api.latest._io import get_finalized_class_inputs
|
||||
from comfy_api_nodes.nodes_openai import OpenAIGPTImageNodeV2
|
||||
|
||||
|
||||
def _finalized_inputs(live_inputs):
|
||||
class_inputs, _, _ = get_finalized_class_inputs(
|
||||
OpenAIGPTImageNodeV2.INPUT_TYPES(), live_inputs
|
||||
)
|
||||
return class_inputs
|
||||
|
||||
|
||||
def test_gpt_image_2_custom_size_inputs_are_optional():
|
||||
"""A preset `size` must not require the custom width/height widgets to be present."""
|
||||
class_inputs = _finalized_inputs({"model": "gpt-image-2", "model.size": "1536x1024"})
|
||||
|
||||
assert "model.custom_width" not in class_inputs["required"]
|
||||
assert "model.custom_height" not in class_inputs["required"]
|
||||
assert "model.custom_width" in class_inputs["optional"]
|
||||
assert "model.custom_height" in class_inputs["optional"]
|
||||
assert "model.size" in class_inputs["required"]
|
||||
|
||||
|
||||
def test_gpt_image_legacy_models_have_no_custom_size_inputs():
|
||||
for model in ("gpt-image-1", "gpt-image-1.5"):
|
||||
class_inputs = _finalized_inputs({"model": model, "model.size": "1536x1024"})
|
||||
assert "model.custom_width" not in class_inputs["required"]
|
||||
assert "model.custom_width" not in class_inputs["optional"]
|
||||
Reference in New Issue
Block a user