@@ -54,6 +54,7 @@ class UIType(str, Enum, metaclass=MetaEnum):
54
54
# region Internal Field Types
55
55
_Collection = "CollectionField"
56
56
_CollectionItem = "CollectionItemField"
57
+ _IsIntermediate = "IsIntermediate"
57
58
# endregion
58
59
59
60
# region DEPRECATED
@@ -91,7 +92,6 @@ class UIType(str, Enum, metaclass=MetaEnum):
91
92
CollectionItem = "DEPRECATED_CollectionItem"
92
93
Enum = "DEPRECATED_Enum"
93
94
WorkflowField = "DEPRECATED_WorkflowField"
94
- IsIntermediate = "DEPRECATED_IsIntermediate"
95
95
BoardField = "DEPRECATED_BoardField"
96
96
MetadataItem = "DEPRECATED_MetadataItem"
97
97
MetadataItemCollection = "DEPRECATED_MetadataItemCollection"
@@ -423,6 +423,7 @@ class InputFieldJSONSchemaExtra(BaseModel):
423
423
model_config = ConfigDict (
424
424
validate_assignment = True ,
425
425
json_schema_serialization_defaults_required = True ,
426
+ use_enum_values = True ,
426
427
)
427
428
428
429
@@ -482,9 +483,114 @@ class OutputFieldJSONSchemaExtra(BaseModel):
482
483
model_config = ConfigDict (
483
484
validate_assignment = True ,
484
485
json_schema_serialization_defaults_required = True ,
486
+ use_enum_values = True ,
485
487
)
486
488
487
489
490
+ def migrate_model_ui_type (ui_type : UIType | str , json_schema_extra : dict [str , Any ]) -> bool :
491
+ """Migrate deprecated model-specifier ui_type values to new-style ui_model_[base|type|variant|format] in json_schema_extra."""
492
+ if not isinstance (ui_type , UIType ):
493
+ ui_type = UIType (ui_type )
494
+
495
+ ui_model_type : list [ModelType ] | None = None
496
+ ui_model_base : list [BaseModelType ] | None = None
497
+ ui_model_format : list [ModelFormat ] | None = None
498
+ ui_model_variant : list [ClipVariantType | ModelVariantType ] | None = None
499
+
500
+ match ui_type :
501
+ case UIType .MainModel :
502
+ ui_model_base = [BaseModelType .StableDiffusion1 , BaseModelType .StableDiffusion2 ]
503
+ ui_model_type = [ModelType .Main ]
504
+ case UIType .CogView4MainModel :
505
+ ui_model_base = [BaseModelType .CogView4 ]
506
+ ui_model_type = [ModelType .Main ]
507
+ case UIType .FluxMainModel :
508
+ ui_model_base = [BaseModelType .Flux ]
509
+ ui_model_type = [ModelType .Main ]
510
+ case UIType .SD3MainModel :
511
+ ui_model_base = [BaseModelType .StableDiffusion3 ]
512
+ ui_model_type = [ModelType .Main ]
513
+ case UIType .SDXLMainModel :
514
+ ui_model_base = [BaseModelType .StableDiffusionXL ]
515
+ ui_model_type = [ModelType .Main ]
516
+ case UIType .SDXLRefinerModel :
517
+ ui_model_base = [BaseModelType .StableDiffusionXLRefiner ]
518
+ ui_model_type = [ModelType .Main ]
519
+ case UIType .VAEModel :
520
+ ui_model_type = [ModelType .VAE ]
521
+ case UIType .FluxVAEModel :
522
+ ui_model_base = [BaseModelType .Flux ]
523
+ ui_model_type = [ModelType .VAE ]
524
+ case UIType .LoRAModel :
525
+ ui_model_type = [ModelType .LoRA ]
526
+ case UIType .ControlNetModel :
527
+ ui_model_type = [ModelType .ControlNet ]
528
+ case UIType .IPAdapterModel :
529
+ ui_model_type = [ModelType .IPAdapter ]
530
+ case UIType .T2IAdapterModel :
531
+ ui_model_type = [ModelType .T2IAdapter ]
532
+ case UIType .T5EncoderModel :
533
+ ui_model_type = [ModelType .T5Encoder ]
534
+ case UIType .CLIPEmbedModel :
535
+ ui_model_type = [ModelType .CLIPEmbed ]
536
+ case UIType .CLIPLEmbedModel :
537
+ ui_model_type = [ModelType .CLIPEmbed ]
538
+ ui_model_variant = [ClipVariantType .L ]
539
+ case UIType .CLIPGEmbedModel :
540
+ ui_model_type = [ModelType .CLIPEmbed ]
541
+ ui_model_variant = [ClipVariantType .G ]
542
+ case UIType .SpandrelImageToImageModel :
543
+ ui_model_type = [ModelType .SpandrelImageToImage ]
544
+ case UIType .ControlLoRAModel :
545
+ ui_model_type = [ModelType .ControlLoRa ]
546
+ case UIType .SigLipModel :
547
+ ui_model_type = [ModelType .SigLIP ]
548
+ case UIType .FluxReduxModel :
549
+ ui_model_type = [ModelType .FluxRedux ]
550
+ case UIType .LlavaOnevisionModel :
551
+ ui_model_type = [ModelType .LlavaOnevision ]
552
+ case UIType .Imagen3Model :
553
+ ui_model_base = [BaseModelType .Imagen3 ]
554
+ ui_model_type = [ModelType .Main ]
555
+ case UIType .Imagen4Model :
556
+ ui_model_base = [BaseModelType .Imagen4 ]
557
+ ui_model_type = [ModelType .Main ]
558
+ case UIType .ChatGPT4oModel :
559
+ ui_model_base = [BaseModelType .ChatGPT4o ]
560
+ ui_model_type = [ModelType .Main ]
561
+ case UIType .Gemini2_5Model :
562
+ ui_model_base = [BaseModelType .Gemini2_5 ]
563
+ ui_model_type = [ModelType .Main ]
564
+ case UIType .FluxKontextModel :
565
+ ui_model_base = [BaseModelType .FluxKontext ]
566
+ ui_model_type = [ModelType .Main ]
567
+ case UIType .Veo3Model :
568
+ ui_model_base = [BaseModelType .Veo3 ]
569
+ ui_model_type = [ModelType .Video ]
570
+ case UIType .RunwayModel :
571
+ ui_model_base = [BaseModelType .Runway ]
572
+ ui_model_type = [ModelType .Video ]
573
+ case _:
574
+ pass
575
+
576
+ did_migrate = False
577
+
578
+ if ui_model_type is not None :
579
+ json_schema_extra ["ui_model_type" ] = [m .value for m in ui_model_type ]
580
+ did_migrate = True
581
+ if ui_model_base is not None :
582
+ json_schema_extra ["ui_model_base" ] = [m .value for m in ui_model_base ]
583
+ did_migrate = True
584
+ if ui_model_format is not None :
585
+ json_schema_extra ["ui_model_format" ] = [m .value for m in ui_model_format ]
586
+ did_migrate = True
587
+ if ui_model_variant is not None :
588
+ json_schema_extra ["ui_model_variant" ] = [m .value for m in ui_model_variant ]
589
+ did_migrate = True
590
+
591
+ return did_migrate
592
+
593
+
488
594
def InputField (
489
595
# copied from pydantic's Field
490
596
# TODO: Can we support default_factory?
@@ -575,93 +681,6 @@ def InputField(
575
681
field_kind = FieldKind .Input ,
576
682
)
577
683
578
- if ui_type is not None :
579
- if (
580
- ui_model_base is not None
581
- or ui_model_type is not None
582
- or ui_model_variant is not None
583
- or ui_model_format is not None
584
- ):
585
- logger .warning ("InputField: Use either ui_type or ui_model_[base|type|variant|format]. Ignoring ui_type." )
586
- # Map old-style UIType to new-style ui_model_[base|type|variant|format]
587
- elif ui_type is UIType .MainModel :
588
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
589
- elif ui_type is UIType .CogView4MainModel :
590
- json_schema_extra_ .ui_model_base = [BaseModelType .CogView4 ]
591
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
592
- elif ui_type is UIType .FluxMainModel :
593
- json_schema_extra_ .ui_model_base = [BaseModelType .Flux ]
594
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
595
- elif ui_type is UIType .SD3MainModel :
596
- json_schema_extra_ .ui_model_base = [BaseModelType .StableDiffusion3 ]
597
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
598
- elif ui_type is UIType .SDXLMainModel :
599
- json_schema_extra_ .ui_model_base = [BaseModelType .StableDiffusionXL ]
600
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
601
- elif ui_type is UIType .SDXLRefinerModel :
602
- json_schema_extra_ .ui_model_base = [BaseModelType .StableDiffusionXLRefiner ]
603
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
604
- # Think this UIType is unused...?
605
- # elif ui_type is UIType.ONNXModel:
606
- # json_schema_extra_.ui_model_base =
607
- # json_schema_extra_.ui_model_type =
608
- elif ui_type is UIType .VAEModel :
609
- json_schema_extra_ .ui_model_type = [ModelType .VAE ]
610
- elif ui_type is UIType .FluxVAEModel :
611
- json_schema_extra_ .ui_model_base = [BaseModelType .Flux ]
612
- json_schema_extra_ .ui_model_type = [ModelType .VAE ]
613
- elif ui_type is UIType .LoRAModel :
614
- json_schema_extra_ .ui_model_type = [ModelType .LoRA ]
615
- elif ui_type is UIType .ControlNetModel :
616
- json_schema_extra_ .ui_model_type = [ModelType .ControlNet ]
617
- elif ui_type is UIType .IPAdapterModel :
618
- json_schema_extra_ .ui_model_type = [ModelType .IPAdapter ]
619
- elif ui_type is UIType .T2IAdapterModel :
620
- json_schema_extra_ .ui_model_type = [ModelType .T2IAdapter ]
621
- elif ui_type is UIType .T5EncoderModel :
622
- json_schema_extra_ .ui_model_type = [ModelType .T5Encoder ]
623
- elif ui_type is UIType .CLIPEmbedModel :
624
- json_schema_extra_ .ui_model_type = [ModelType .CLIPEmbed ]
625
- elif ui_type is UIType .CLIPLEmbedModel :
626
- json_schema_extra_ .ui_model_type = [ModelType .CLIPEmbed ]
627
- json_schema_extra_ .ui_model_variant = [ClipVariantType .L ]
628
- elif ui_type is UIType .CLIPGEmbedModel :
629
- json_schema_extra_ .ui_model_type = [ModelType .CLIPEmbed ]
630
- json_schema_extra_ .ui_model_variant = [ClipVariantType .G ]
631
- elif ui_type is UIType .SpandrelImageToImageModel :
632
- json_schema_extra_ .ui_model_type = [ModelType .SpandrelImageToImage ]
633
- elif ui_type is UIType .ControlLoRAModel :
634
- json_schema_extra_ .ui_model_type = [ModelType .ControlLoRa ]
635
- elif ui_type is UIType .SigLipModel :
636
- json_schema_extra_ .ui_model_type = [ModelType .SigLIP ]
637
- elif ui_type is UIType .FluxReduxModel :
638
- json_schema_extra_ .ui_model_type = [ModelType .FluxRedux ]
639
- elif ui_type is UIType .LlavaOnevisionModel :
640
- json_schema_extra_ .ui_model_type = [ModelType .LlavaOnevision ]
641
- elif ui_type is UIType .Imagen3Model :
642
- json_schema_extra_ .ui_model_base = [BaseModelType .Imagen3 ]
643
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
644
- elif ui_type is UIType .Imagen4Model :
645
- json_schema_extra_ .ui_model_base = [BaseModelType .Imagen4 ]
646
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
647
- elif ui_type is UIType .ChatGPT4oModel :
648
- json_schema_extra_ .ui_model_base = [BaseModelType .ChatGPT4o ]
649
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
650
- elif ui_type is UIType .Gemini2_5Model :
651
- json_schema_extra_ .ui_model_base = [BaseModelType .Gemini2_5 ]
652
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
653
- elif ui_type is UIType .FluxKontextModel :
654
- json_schema_extra_ .ui_model_base = [BaseModelType .FluxKontext ]
655
- json_schema_extra_ .ui_model_type = [ModelType .Main ]
656
- elif ui_type is UIType .Veo3Model :
657
- json_schema_extra_ .ui_model_base = [BaseModelType .Veo3 ]
658
- json_schema_extra_ .ui_model_type = [ModelType .Video ]
659
- elif ui_type is UIType .RunwayModel :
660
- json_schema_extra_ .ui_model_base = [BaseModelType .Runway ]
661
- json_schema_extra_ .ui_model_type = [ModelType .Video ]
662
- else :
663
- json_schema_extra_ .ui_type = ui_type
664
-
665
684
if ui_component is not None :
666
685
json_schema_extra_ .ui_component = ui_component
667
686
if ui_hidden is not None :
@@ -690,6 +709,8 @@ def InputField(
690
709
json_schema_extra_ .ui_model_format = ui_model_format
691
710
else :
692
711
json_schema_extra_ .ui_model_format = [ui_model_format ]
712
+ if ui_type is not None :
713
+ json_schema_extra_ .ui_type = ui_type
693
714
694
715
"""
695
716
There is a conflict between the typing of invocation definitions and the typing of an invocation's
0 commit comments