Archived
79 lines
2.3 KiB
Python
79 lines
2.3 KiB
Python
"""
|
|
Shared type definitions for workflows.
|
|
Keep all reusable parameter types here.
|
|
"""
|
|
from pydantic import BaseModel, Field
|
|
from typing import Annotated, List, Optional
|
|
|
|
# =============================================================================
|
|
# Annotated Types for UI Schema Generation
|
|
# =============================================================================
|
|
|
|
# Text fields
|
|
Prompt = Annotated[str, Field(
|
|
json_schema_extra={"ui_type": "text", "category": "prompts", "multiline": True, "rows": 4}
|
|
)]
|
|
NegativePrompt = Annotated[str, Field(
|
|
json_schema_extra={"ui_type": "text", "category": "prompts", "multiline": True, "rows": 2}
|
|
)]
|
|
|
|
# Special types
|
|
Seed = Annotated[int, Field(
|
|
json_schema_extra={"ui_type": "seed", "category": "parameters"}
|
|
)]
|
|
|
|
# Enum types
|
|
Sampler = Annotated[str, Field(
|
|
json_schema_extra={"ui_type": "enum", "options_source": "samplers", "category": "parameters"}
|
|
)]
|
|
Scheduler = Annotated[str, Field(
|
|
json_schema_extra={"ui_type": "enum", "options_source": "schedulers", "category": "parameters"}
|
|
)]
|
|
|
|
# Model selectors
|
|
Checkpoint = Annotated[List[str], Field(
|
|
json_schema_extra={"ui_type": "model", "options_source": "checkpoints", "category": "models"}
|
|
)]
|
|
|
|
# Dimension fields (uses Pydantic's built-in constraints)
|
|
Width = Annotated[int, Field(
|
|
ge=64, le=2048, multiple_of=8,
|
|
json_schema_extra={"category": "composition"}
|
|
)]
|
|
Height = Annotated[int, Field(
|
|
ge=64, le=2048, multiple_of=8,
|
|
json_schema_extra={"category": "composition"}
|
|
)]
|
|
|
|
# =============================================================================
|
|
# Models with Parameters (for model_with_params type)
|
|
# =============================================================================
|
|
|
|
class LoopbackParameters(BaseModel):
|
|
iterations: int = 1
|
|
upscale: float = 1.0
|
|
denoise: float = 0.5
|
|
steps: int = 10
|
|
cfg: float = 7.0
|
|
|
|
class LoraParameters(BaseModel):
|
|
strength_model: float = 1.0
|
|
strength_clip: float = 1.0
|
|
|
|
class Lora(BaseModel):
|
|
apiName: str
|
|
disabled: bool = False
|
|
parameters: LoraParameters = LoraParameters()
|
|
|
|
class ControlnetParameters(BaseModel):
|
|
strength: float = 1.0
|
|
start_percent: float = 0.0
|
|
end_percent: float = 1.0
|
|
|
|
class Controlnet(BaseModel):
|
|
apiName: str
|
|
disabled: bool = False
|
|
parameters: ControlnetParameters = ControlnetParameters()
|
|
|
|
# Add more shared types as needed
|