Skip to content

Commit 2857a44

Browse files
docs(nodes): update docstrings for InputField
1 parent 035d943 commit 2857a44

File tree

1 file changed

+49
-21
lines changed

1 file changed

+49
-21
lines changed

invokeai/app/invocations/fields.py

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ class OutputFieldJSONSchemaExtra(BaseModel):
477477

478478
field_kind: FieldKind
479479
ui_hidden: bool
480-
ui_type: Optional[UIType]
481480
ui_order: Optional[int]
482481

483482
model_config = ConfigDict(
@@ -520,31 +519,55 @@ def InputField(
520519
"""
521520
Creates an input field for an invocation.
522521
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)
524523
that adds a few extra parameters to support graph execution and the node editor UI.
525524
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.
530527
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`.
537545
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.
542547
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.
544550
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`.
546554
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".
548571
"""
549572

550573
json_schema_extra_ = InputFieldJSONSchemaExtra(
@@ -771,7 +794,7 @@ def OutputField(
771794
This is a wrapper for Pydantic's [Field](https://docs.pydantic.dev/1.10/usage/schema/#field-customization) \
772795
that adds a few extra parameters to support graph execution and the node editor UI.
773796
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. \
775798
In some situations, the field's type is not enough to infer the correct UI type. \
776799
For example, model selection fields should render a dropdown UI component to select a model. \
777800
Internally, there is no difference between SD-1, SD-2 and SDXL model fields, they all use \
@@ -782,6 +805,12 @@ def OutputField(
782805
783806
:param int ui_order: [None] Specifies the order in which this field should be rendered in the UI. \
784807
"""
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+
785814
return Field(
786815
default=default,
787816
title=title,
@@ -799,7 +828,6 @@ def OutputField(
799828
min_length=min_length,
800829
max_length=max_length,
801830
json_schema_extra=OutputFieldJSONSchemaExtra(
802-
ui_type=ui_type,
803831
ui_hidden=ui_hidden,
804832
ui_order=ui_order,
805833
field_kind=FieldKind.Output,

0 commit comments

Comments
 (0)