Archived
refactored workflow parameters to include a component property for the frontend, updated docs
This commit is contained in:
1 parent
59ff3365e9
commit
37e901bc30
4 files changed
+236
-52
No files matched your search
+36
-9
@@ -8,41 +8,52 @@ from typing import Annotated, List, Optional
|
||||
# =============================================================================
|
||||
# Annotated Types for UI Schema Generation
|
||||
# =============================================================================
|
||||
#
|
||||
# Each type specifies:
|
||||
# - component: The frontend UI component to render (optional, for custom UX)
|
||||
# - category: Which tab/section to display the field in
|
||||
# - options_source: For selections, where to get the options from
|
||||
#
|
||||
# If no component is specified, frontend uses generic components based on type.
|
||||
|
||||
# Text fields
|
||||
Prompt = Annotated[str, Field(
|
||||
json_schema_extra={"ui_type": "text", "category": "prompts", "multiline": True, "rows": 4}
|
||||
json_schema_extra={"component": "prompt", "category": "prompts", "multiline": True, "rows": 4}
|
||||
)]
|
||||
NegativePrompt = Annotated[str, Field(
|
||||
json_schema_extra={"ui_type": "text", "category": "prompts", "multiline": True, "rows": 2}
|
||||
json_schema_extra={"component": "negative_prompt", "category": "prompts", "multiline": True, "rows": 2}
|
||||
)]
|
||||
|
||||
# Special types
|
||||
Seed = Annotated[int, Field(
|
||||
json_schema_extra={"ui_type": "seed", "category": "parameters"}
|
||||
json_schema_extra={"component": "seed", "category": "parameters"}
|
||||
)]
|
||||
|
||||
# Enum types
|
||||
# Enum types (selections from options_source)
|
||||
Sampler = Annotated[str, Field(
|
||||
json_schema_extra={"ui_type": "enum", "options_source": "samplers", "category": "parameters"}
|
||||
json_schema_extra={"component": "sampler", "options_source": "samplers", "category": "parameters"}
|
||||
)]
|
||||
Scheduler = Annotated[str, Field(
|
||||
json_schema_extra={"ui_type": "enum", "options_source": "schedulers", "category": "parameters"}
|
||||
json_schema_extra={"component": "scheduler", "options_source": "schedulers", "category": "parameters"}
|
||||
)]
|
||||
|
||||
# Model selectors
|
||||
Checkpoint = Annotated[List[str], Field(
|
||||
json_schema_extra={"ui_type": "model", "options_source": "checkpoints", "category": "models"}
|
||||
json_schema_extra={"component": "checkpoints", "options_source": "checkpoints", "category": "models"}
|
||||
)]
|
||||
|
||||
# Loras - uses Lora class defined below
|
||||
# The actual type is defined after Lora class, see Loras below
|
||||
|
||||
# Dimension fields (uses Pydantic's built-in constraints)
|
||||
# No component specified - frontend uses generic slider based on type + constraints
|
||||
Width = Annotated[int, Field(
|
||||
ge=64, le=2048, multiple_of=8,
|
||||
json_schema_extra={"category": "composition"}
|
||||
json_schema_extra={"component": "dimensions", "category": "composition"}
|
||||
)]
|
||||
Height = Annotated[int, Field(
|
||||
ge=64, le=2048, multiple_of=8,
|
||||
json_schema_extra={"category": "composition"}
|
||||
json_schema_extra={"component": "dimensions", "category": "composition"}
|
||||
)]
|
||||
|
||||
# =============================================================================
|
||||
@@ -75,4 +86,20 @@ class Controlnet(BaseModel):
|
||||
disabled: bool = False
|
||||
parameters: ControlnetParameters = ControlnetParameters()
|
||||
|
||||
# =============================================================================
|
||||
# Annotated List Types (for model_with_params with category)
|
||||
# =============================================================================
|
||||
|
||||
# Loras - List of Lora models with parameters
|
||||
Loras = Annotated[List[Lora], Field(
|
||||
default=[],
|
||||
json_schema_extra={"component": "loras", "options_source": "loras", "category": "models"}
|
||||
)]
|
||||
|
||||
# Controlnets - List of Controlnet models with parameters
|
||||
Controlnets = Annotated[List[Controlnet], Field(
|
||||
default=[],
|
||||
json_schema_extra={"component": "controlnets", "options_source": "controlnets", "category": "models"}
|
||||
)]
|
||||
|
||||
# Add more shared types as needed
|
||||
Reference in new issue
Block a user