Skip to content

Commit cfed293

Browse files
fix(nodes): do not make invocation field defaults None when they are not provided
1 parent d36bc18 commit cfed293

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

invokeai/app/invocations/fields.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ class InputFieldJSONSchemaExtra(BaseModel):
400400
"""
401401

402402
input: Input
403-
orig_required: bool
404403
field_kind: FieldKind
404+
orig_required: bool = True
405405
default: Optional[Any] = None
406406
orig_default: Optional[Any] = None
407407
ui_hidden: bool = False
@@ -498,7 +498,7 @@ def InputField(
498498
input: Input = Input.Any,
499499
ui_type: Optional[UIType] = None,
500500
ui_component: Optional[UIComponent] = None,
501-
ui_hidden: bool = False,
501+
ui_hidden: Optional[bool] = None,
502502
ui_order: Optional[int] = None,
503503
ui_choice_labels: Optional[dict[str, str]] = None,
504504
) -> Any:
@@ -534,15 +534,20 @@ def InputField(
534534

535535
json_schema_extra_ = InputFieldJSONSchemaExtra(
536536
input=input,
537-
ui_type=ui_type,
538-
ui_component=ui_component,
539-
ui_hidden=ui_hidden,
540-
ui_order=ui_order,
541-
ui_choice_labels=ui_choice_labels,
542537
field_kind=FieldKind.Input,
543-
orig_required=True,
544538
)
545539

540+
if ui_type is not None:
541+
json_schema_extra_.ui_type = ui_type
542+
if ui_component is not None:
543+
json_schema_extra_.ui_component = ui_component
544+
if ui_hidden is not None:
545+
json_schema_extra_.ui_hidden = ui_hidden
546+
if ui_order is not None:
547+
json_schema_extra_.ui_order = ui_order
548+
if ui_choice_labels is not None:
549+
json_schema_extra_.ui_choice_labels = ui_choice_labels
550+
546551
"""
547552
There is a conflict between the typing of invocation definitions and the typing of an invocation's
548553
`invoke()` function.
@@ -614,7 +619,7 @@ def InputField(
614619

615620
return Field(
616621
**provided_args,
617-
json_schema_extra=json_schema_extra_.model_dump(exclude_none=True),
622+
json_schema_extra=json_schema_extra_.model_dump(exclude_unset=True),
618623
)
619624

620625

0 commit comments

Comments
 (0)