@@ -477,7 +477,6 @@ class OutputFieldJSONSchemaExtra(BaseModel):
477
477
478
478
field_kind : FieldKind
479
479
ui_hidden : bool
480
- ui_type : Optional [UIType ]
481
480
ui_order : Optional [int ]
482
481
483
482
model_config = ConfigDict (
@@ -520,31 +519,55 @@ def InputField(
520
519
"""
521
520
Creates an input field for an invocation.
522
521
523
- This is a wrapper for Pydantic's [Field](https://docs.pydantic.dev/latest/api/fields/#pydantic.fields.Field) \
522
+ This is a wrapper for Pydantic's [Field](https://docs.pydantic.dev/latest/api/fields/#pydantic.fields.Field)
524
523
that adds a few extra parameters to support graph execution and the node editor UI.
525
524
526
- :param Input input: [Input.Any] The kind of input this field requires. \
527
- `Input.Direct` means a value must be provided on instantiation. \
528
- `Input.Connection` means the value must be provided by a connection. \
529
- `Input.Any` means either will do.
525
+ If the field is a `ModelIdentifierField`, use the `ui_model_[base|type|variant|format]` args to filter the model list
526
+ in the Workflow Editor. Otherwise, use `ui_type` to provide extra type hints for the UI.
530
527
531
- :param UIType ui_type: [None] Optionally provides an extra type hint for the UI. \
532
- In some situations, the field's type is not enough to infer the correct UI type. \
533
- For example, model selection fields should render a dropdown UI component to select a model. \
534
- Internally, there is no difference between SD-1, SD-2 and SDXL model fields, they all use \
535
- `MainModelField`. So to ensure the base-model-specific UI is rendered, you can use \
536
- `UIType.SDXLMainModelField` to indicate that the field is an SDXL main model field.
528
+ Don't use both `ui_type` and `ui_model_[base|type|variant|format]` - if both are provided, a warning will be
529
+ logged and `ui_type` will be ignored.
530
+
531
+ Args:
532
+ input: The kind of input this field requires.
533
+ - `Input.Direct` means a value must be provided on instantiation.
534
+ - `Input.Connection` means the value must be provided by a connection.
535
+ - `Input.Any` means either will do.
536
+
537
+ ui_type: Optionally provides an extra type hint for the UI. In some situations, the field's type is not enough
538
+ to infer the correct UI type. For example, Scheduler fields are enums, but we want to render a special scheduler
539
+ dropdown in the UI. Use `UIType.Scheduler` to indicate this.
540
+
541
+ ui_component: Optionally specifies a specific component to use in the UI. The UI will always render a suitable
542
+ component, but sometimes you want something different than the default. For example, a `string` field will
543
+ default to a single-line input, but you may want a multi-line textarea instead. In this case, you could use
544
+ `UIComponent.Textarea`.
537
545
538
- :param UIComponent ui_component: [None] Optionally specifies a specific component to use in the UI. \
539
- The UI will always render a suitable component, but sometimes you want something different than the default. \
540
- For example, a `string` field will default to a single-line input, but you may want a multi-line textarea instead. \
541
- For this case, you could provide `UIComponent.Textarea`.
546
+ ui_hidden: Specifies whether or not this field should be hidden in the UI.
542
547
543
- :param bool ui_hidden: [False] Specifies whether or not this field should be hidden in the UI.
548
+ ui_order: Specifies the order in which this field should be rendered in the UI. If omitted, the field will be
549
+ rendered after all fields with an explicit order, in the order they are defined in the Invocation class.
544
550
545
- :param int ui_order: [None] Specifies the order in which this field should be rendered in the UI.
551
+ ui_model_base: Specifies the base model architectures to filter the model list by in the Workflow Editor. For
552
+ example, `ui_model_base=BaseModelType.StableDiffusionXL` will show only SDXL architecture models. This arg is
553
+ only valid if this Input field is annotated as a `ModelIdentifierField`.
546
554
547
- :param dict[str, str] ui_choice_labels: [None] Specifies the labels to use for the choices in an enum field.
555
+ ui_model_type: Specifies the model type(s) to filter the model list by in the Workflow Editor. For example,
556
+ `ui_model_type=ModelType.VAE` will show only VAE models. This arg is only valid if this Input field is
557
+ annotated as a `ModelIdentifierField`.
558
+
559
+ ui_model_variant: Specifies the model variant(s) to filter the model list by in the Workflow Editor. For example,
560
+ `ui_model_variant=ModelVariantType.Inpainting` will show only inpainting models. This arg is only valid if this
561
+ Input field is annotated as a `ModelIdentifierField`.
562
+
563
+ ui_model_format: Specifies the model format(s) to filter the model list by in the Workflow Editor. For example,
564
+ `ui_model_format=ModelFormat.Diffusers` will show only models in the diffusers format. This arg is only valid
565
+ if this Input field is annotated as a `ModelIdentifierField`.
566
+
567
+ ui_choice_labels: Specifies the labels to use for the choices in an enum field. If omitted, the enum values
568
+ will be used. This arg is only valid if the field is annotated with as a `Literal`. For example,
569
+ `Literal["choice1", "choice2", "choice3"]` with `ui_choice_labels={"choice1": "Choice 1", "choice2": "Choice 2",
570
+ "choice3": "Choice 3"}` will render a dropdown with the labels "Choice 1", "Choice 2" and "Choice 3".
548
571
"""
549
572
550
573
json_schema_extra_ = InputFieldJSONSchemaExtra (
@@ -771,7 +794,7 @@ def OutputField(
771
794
This is a wrapper for Pydantic's [Field](https://docs.pydantic.dev/1.10/usage/schema/#field-customization) \
772
795
that adds a few extra parameters to support graph execution and the node editor UI.
773
796
774
- :param UIType ui_type: [None] Optionally provides an extra type hint for the UI. \
797
+ :param UIType ui_type: [None] DEPRECATED Optionally provides an extra type hint for the UI. \
775
798
In some situations, the field's type is not enough to infer the correct UI type. \
776
799
For example, model selection fields should render a dropdown UI component to select a model. \
777
800
Internally, there is no difference between SD-1, SD-2 and SDXL model fields, they all use \
@@ -782,6 +805,12 @@ def OutputField(
782
805
783
806
:param int ui_order: [None] Specifies the order in which this field should be rendered in the UI. \
784
807
"""
808
+
809
+ if ui_type is not None :
810
+ logger .warning (
811
+ "OutputField: 'ui_type' is deprecated. Use 'ui_model_[base|type|variant]' in InputField instead."
812
+ )
813
+
785
814
return Field (
786
815
default = default ,
787
816
title = title ,
@@ -799,7 +828,6 @@ def OutputField(
799
828
min_length = min_length ,
800
829
max_length = max_length ,
801
830
json_schema_extra = OutputFieldJSONSchemaExtra (
802
- ui_type = ui_type ,
803
831
ui_hidden = ui_hidden ,
804
832
ui_order = ui_order ,
805
833
field_kind = FieldKind .Output ,
0 commit comments