Skip to content

Commit dadff57

Browse files
feat(nodes): add ui_model_format filter for nodes
1 parent 480857a commit dadff57

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

invokeai/app/invocations/fields.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77

88
from invokeai.app.util.metaenum import MetaEnum
99
from invokeai.backend.image_util.segment_anything.shared import BoundingBox
10-
from invokeai.backend.model_manager.taxonomy import BaseModelType, ClipVariantType, ModelType, ModelVariantType
10+
from invokeai.backend.model_manager.taxonomy import (
11+
BaseModelType,
12+
ClipVariantType,
13+
ModelFormat,
14+
ModelType,
15+
ModelVariantType,
16+
)
1117
from invokeai.backend.util.logging import InvokeAILogger
1218

1319
logger = InvokeAILogger.get_logger()
@@ -413,6 +419,7 @@ class InputFieldJSONSchemaExtra(BaseModel):
413419
ui_model_base: Optional[list[BaseModelType]] = None
414420
ui_model_type: Optional[list[ModelType]] = None
415421
ui_model_variant: Optional[list[ClipVariantType | ModelVariantType]] = None
422+
ui_model_format: Optional[list[ModelFormat]] = None
416423

417424
model_config = ConfigDict(
418425
validate_assignment=True,
@@ -508,6 +515,7 @@ def InputField(
508515
ui_model_base: Optional[BaseModelType | list[BaseModelType]] = None,
509516
ui_model_type: Optional[ModelType | list[ModelType]] = None,
510517
ui_model_variant: Optional[ClipVariantType | ModelVariantType | list[ClipVariantType | ModelVariantType]] = None,
518+
ui_model_format: Optional[ModelFormat | list[ModelFormat]] = None,
511519
) -> Any:
512520
"""
513521
Creates an input field for an invocation.
@@ -545,8 +553,13 @@ def InputField(
545553
)
546554

547555
if ui_type is not None:
548-
if ui_model_base is not None or ui_model_type is not None or ui_model_variant is not None:
549-
logger.warning("Use either ui_type or ui_model_[base|type|variant]. Ignoring ui_type.")
556+
if (
557+
ui_model_base is not None
558+
or ui_model_type is not None
559+
or ui_model_variant is not None
560+
or ui_model_format is not None
561+
):
562+
logger.warning("InputField: Use either ui_type or ui_model_[base|type|variant]. Ignoring ui_type.")
550563
# Map old-style UIType to new-style ui_model_[base|type|variant]
551564
elif ui_type is UIType.MainModel:
552565
json_schema_extra_.ui_model_type = [ModelType.Main]
@@ -649,6 +662,11 @@ def InputField(
649662
json_schema_extra_.ui_model_variant = ui_model_variant
650663
else:
651664
json_schema_extra_.ui_model_variant = [ui_model_variant]
665+
if ui_model_format is not None:
666+
if isinstance(ui_model_format, list):
667+
json_schema_extra_.ui_model_format = ui_model_format
668+
else:
669+
json_schema_extra_.ui_model_format = [ui_model_format]
652670

653671
"""
654672
There is a conflict between the typing of invocation definitions and the typing of an invocation's

0 commit comments

Comments
 (0)