refactored workflow parameters to include a component property for the frontend, updated docs

This commit is contained in:
donny committed 2026-01-05 16:50:56 -07:00
1 parent 59ff3365e9
commit 37e901bc30
4 files changed
+236 -52

No files matched your search

+158 -28
View File
@@ -1,6 +1,6 @@
# ImageLab External API Documentation
**Version:** 2.0
**Version:** 2.1
**Base URL:** `http://127.0.0.1:8188`
REST API endpoints for executing ComfyScript workflows with real-time progress monitoring.
@@ -27,11 +27,20 @@ REST API endpoints for executing ComfyScript workflows with real-time progress m
The ImageLab External API extends ComfyUI with:
- **Workflow Execution**: Execute ComfyScript-based workflows via REST API
- **YAML Schema System**: Auto-generated UI schemas from Pydantic models
- **YAML Schema System**: Auto-generated UI schemas from Pydantic models with type/component separation
- **Resource Discovery**: List and index models with CivitAI metadata
- **Progress Broadcasting**: Real-time updates via WebSocket binary events
- **Hot Reloading**: Workflows reload from disk on each execution
### Schema Design
The YAML schema separates concerns:
- **`type`**: Data type (int, float, str, bool, enum, object)
- **`component`**: Optional UI component hint (seed, prompt, sampler, etc.)
This allows the frontend to use generic components based on type while supporting custom UI for specific fields.
### Technology Stack
| Component | Technology |
@@ -162,7 +171,8 @@ Get the UI parameter schema for a workflow. Returns resolved options from `optio
"parameters": [
{
"name": "prompt",
"type": "text",
"type": "str",
"component": "prompt",
"category": "prompts",
"multiline": true,
"required": true,
@@ -174,6 +184,7 @@ Get the UI parameter schema for a workflow. Returns resolved options from `optio
{
"name": "sampler",
"type": "enum",
"component": "sampler",
"options_source": "samplers",
"category": "parameters",
"default": "euler",
@@ -187,6 +198,28 @@ Get the UI parameter schema for a workflow. Returns resolved options from `optio
"metadata": null
}
]
},
{
"name": "seed",
"type": "int",
"component": "seed",
"category": "parameters",
"required": true,
"label": "Seed"
},
{
"name": "loras",
"type": "object",
"multiple": true,
"component": "loras",
"options_source": "loras",
"category": "models",
"default": [],
"label": "Loras",
"params": [
{ "name": "strength_model", "type": "float", "default": 1.0 },
{ "name": "strength_clip", "type": "float", "default": 1.0 }
]
}
]
}
@@ -538,39 +571,62 @@ UI parameter schemas are auto-generated from Pydantic `WorkflowParams` models us
### Annotated Types (parameters.py)
The `component` property specifies the UI component to render (optional). The `type` is inferred from the Python type and metadata.
```python
from typing import Annotated, List
from pydantic import Field
# Text fields
# Text fields - component specifies custom UI
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}
)]
# Generated: type: str, component: prompt
# Special types
# Special types - int with custom UI component
Seed = Annotated[int, Field(
json_schema_extra={"ui_type": "seed", "category": "parameters"}
json_schema_extra={"component": "seed", "category": "parameters"}
)]
# Generated: type: int, component: seed
# Enum types (options resolved from resources)
# Enum types - options_source triggers type: enum
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"}
)]
# Generated: type: enum, component: sampler, options_source: samplers
# Model selectors
# Model selectors - multiple selection from options_source
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"}
)]
# Generated: type: enum, multiple: true, component: checkpoints
# Dimension fields
# Dimension fields - no component = generic slider
Width = Annotated[int, Field(
ge=64, le=2048, multiple_of=8,
json_schema_extra={"category": "composition"}
json_schema_extra={"component": "dimensions", "category": "composition"}
)]
# Generated: type: int, component: dimensions, min: 64, max: 2048, step: 8
```
### Type Inference Rules
The `type` property represents the **data type**, inferred automatically:
| Condition | Inferred `type` |
| ---------------------------- | ---------------------------- |
| Has `options_source` | `enum` |
| Has `params` (complex model) | `object` |
| Python `int` | `int` |
| Python `float` | `float` |
| Python `str` (no options) | `str` |
| Python `bool` | `bool` |
| Python `List[T]` | type of T + `multiple: true` |
### YAML Format
The schema separates **data type** (`type`) from **UI component** (`component`):
```yaml
name: Basic SDXL Text to Image
description: Workflow with SDXL presets for quick iteration.
@@ -579,26 +635,76 @@ model_types:
- SDXL
parameters:
# Text field with custom component
- name: prompt
type: text
type: str # Data type
component: prompt # UI component (optional)
category: prompts
multiline: true
required: true
label: Your Creative Prompt
rows: 4
placeholder: Describe your image...
description: Enter a detailed description
# Seed - int with custom component
- name: seed
type: int # Data type
component: seed # Custom UI component
category: parameters
required: true
label: Seed
# Enum - selection from options_source
- name: sampler
type: enum
type: enum # Selection type (has options_source)
component: sampler # UI component (optional)
options_source: samplers
category: parameters
default: euler
label: Sampler
searchable: true
# Multiple selection
- name: checkpoints
type: enum
multiple: true # List[str] -> multiple selections
component: checkpoints
options_source: checkpoints
category: models
required: true
label: Checkpoints
# Complex type with params
- name: loras
type: object # Complex type (has params)
multiple: true
component: loras
options_source: loras
category: models
default: []
label: Loras
params:
- name: strength_model
type: float
default: 1.0
- name: strength_clip
type: float
default: 1.0
# Plain int with constraints (no custom component)
- name: steps
type: int
category: parameters
min: 1
max: 150
default: 20
label: Steps
# No component = frontend uses generic SliderField
# Dimensions with custom component
- name: width
type: int
component: dimensions
category: composition
min: 64
max: 2048
@@ -619,23 +725,47 @@ When regenerating YAML schemas:
**Updated** (from code):
- `type`, `default`, `required`
- `type`, `component`, `default`, `required`
- `min`, `max`, `step`
- `category`, `options_source`
- `multiple`, `params`, `multiline`
### Parameter Types
### Data Types (`type`)
| Type | Description | Properties |
| ------------------- | ------------------- | ---------------------------------- |
| `text` | Text input | `multiline`, `rows`, `placeholder` |
| `int` | Integer | `min`, `max`, `step` |
| `float` | Decimal | `min`, `max`, `step` |
| `bool` | Boolean toggle | - |
| `enum` | Dropdown | `options_source`, `searchable` |
| `seed` | Random seed | - |
| `model` | Model selector | `options_source`, `multiple` |
| `model_with_params` | Model with settings | `options_source`, `params` |
The `type` property represents the semantic data type:
| Type | Description | Properties |
| -------- | ----------------------- | ------------------------------ |
| `str` | Text/string | `multiline`, `rows` |
| `int` | Integer | `min`, `max`, `step` |
| `float` | Decimal | `min`, `max`, `step` |
| `bool` | Boolean toggle | - |
| `enum` | Selection from list | `options_source`, `searchable` |
| `object` | Complex with parameters | `options_source`, `params` |
### UI Components (`component`)
The `component` property is an **optional** UI hint for custom rendering:
| Component | Description |
| ----------------- | ----------------------------------------- |
| `prompt` | Multi-line text area for prompts |
| `negative_prompt` | Multi-line text area for negative prompts |
| `seed` | Seed input with randomize button |
| `sampler` | Sampler dropdown with search |
| `scheduler` | Scheduler dropdown |
| `checkpoints` | Model multi-select with metadata |
| `loras` | LoRA selector with strength sliders |
| `dimensions` | Width/Height linked inputs |
**Component Resolution (Frontend):**
| Priority | Check | Example |
| -------- | ------------------------- | ------------------------------------------ |
| 1 | `component` property | `component: "seed"` → SeedField |
| 2 | `options_source` property | `options_source: "samplers"` → SelectField |
| 3 | `type` + constraints | `type: "int"` + min/max → SliderField |
| 4 | `type` only | `type: "bool"` → ToggleField |
### options_source Values