Creates an input field for an invocation. This is a wrapper for Pydantic's [Field](https://docs.pydantic.dev/latest/api/fields/#pydantic.fields.Field) that adds a few extra parameters to support graph execution and the node editor UI. If the field is a `ModelIdentifierField`, use
(
# copied from pydantic's Field
# TODO: Can we support default_factory?
default: Any = _Unset,
default_factory: Callable[[], Any] | None = _Unset,
title: str | None = _Unset,
description: str | None = _Unset,
pattern: str | None = _Unset,
strict: bool | None = _Unset,
gt: float | None = _Unset,
ge: float | None = _Unset,
lt: float | None = _Unset,
le: float | None = _Unset,
multiple_of: float | None = _Unset,
allow_inf_nan: bool | None = _Unset,
max_digits: int | None = _Unset,
decimal_places: int | None = _Unset,
min_length: int | None = _Unset,
max_length: int | None = _Unset,
# custom
input: Input = Input.Any,
ui_type: Optional[UIType] = None,
ui_component: Optional[UIComponent] = None,
ui_hidden: Optional[bool] = None,
ui_order: Optional[int] = None,
ui_choice_labels: Optional[dict[str, str]] = None,
ui_model_base: Optional[BaseModelType | list[BaseModelType]] = None,
ui_model_type: Optional[ModelType | list[ModelType]] = None,
ui_model_variant: Optional[ClipVariantType | ModelVariantType | list[ClipVariantType | ModelVariantType]] = None,
ui_model_format: Optional[ModelFormat | list[ModelFormat]] = None,
ui_model_provider_id: Optional[str | list[str]] = None,
)
| 609 | |
| 610 | |
| 611 | def InputField( |
| 612 | # copied from pydantic's Field |
| 613 | # TODO: Can we support default_factory? |
| 614 | default: Any = _Unset, |
| 615 | default_factory: Callable[[], Any] | None = _Unset, |
| 616 | title: str | None = _Unset, |
| 617 | description: str | None = _Unset, |
| 618 | pattern: str | None = _Unset, |
| 619 | strict: bool | None = _Unset, |
| 620 | gt: float | None = _Unset, |
| 621 | ge: float | None = _Unset, |
| 622 | lt: float | None = _Unset, |
| 623 | le: float | None = _Unset, |
| 624 | multiple_of: float | None = _Unset, |
| 625 | allow_inf_nan: bool | None = _Unset, |
| 626 | max_digits: int | None = _Unset, |
| 627 | decimal_places: int | None = _Unset, |
| 628 | min_length: int | None = _Unset, |
| 629 | max_length: int | None = _Unset, |
| 630 | # custom |
| 631 | input: Input = Input.Any, |
| 632 | ui_type: Optional[UIType] = None, |
| 633 | ui_component: Optional[UIComponent] = None, |
| 634 | ui_hidden: Optional[bool] = None, |
| 635 | ui_order: Optional[int] = None, |
| 636 | ui_choice_labels: Optional[dict[str, str]] = None, |
| 637 | ui_model_base: Optional[BaseModelType | list[BaseModelType]] = None, |
| 638 | ui_model_type: Optional[ModelType | list[ModelType]] = None, |
| 639 | ui_model_variant: Optional[ClipVariantType | ModelVariantType | list[ClipVariantType | ModelVariantType]] = None, |
| 640 | ui_model_format: Optional[ModelFormat | list[ModelFormat]] = None, |
| 641 | ui_model_provider_id: Optional[str | list[str]] = None, |
| 642 | ) -> Any: |
| 643 | """ |
| 644 | Creates an input field for an invocation. |
| 645 | |
| 646 | This is a wrapper for Pydantic's [Field](https://docs.pydantic.dev/latest/api/fields/#pydantic.fields.Field) |
| 647 | that adds a few extra parameters to support graph execution and the node editor UI. |
| 648 | |
| 649 | If the field is a `ModelIdentifierField`, use the `ui_model_[base|type|variant|format]` args to filter the model list |
| 650 | in the Workflow Editor. Otherwise, use `ui_type` to provide extra type hints for the UI. |
| 651 | |
| 652 | Don't use both `ui_type` and `ui_model_[base|type|variant|format]` - if both are provided, a warning will be |
| 653 | logged and `ui_type` will be ignored. |
| 654 | |
| 655 | Args: |
| 656 | input: The kind of input this field requires. |
| 657 | - `Input.Direct` means a value must be provided on instantiation. |
| 658 | - `Input.Connection` means the value must be provided by a connection. |
| 659 | - `Input.Any` means either will do. |
| 660 | |
| 661 | ui_type: Optionally provides an extra type hint for the UI. In some situations, the field's type is not enough |
| 662 | to infer the correct UI type. For example, Scheduler fields are enums, but we want to render a special scheduler |
| 663 | dropdown in the UI. Use `UIType.Scheduler` to indicate this. |
| 664 | |
| 665 | ui_component: Optionally specifies a specific component to use in the UI. The UI will always render a suitable |
| 666 | component, but sometimes you want something different than the default. For example, a `string` field will |
| 667 | default to a single-line input, but you may want a multi-line textarea instead. In this case, you could use |
| 668 | `UIComponent.Textarea`. |
no test coverage detected