feat: Add valid ComfyUI SD1.5 workflow to comfy-agent

- Replace placeholder workflow with complete SD1.5 pipeline
- Support dynamic prompt, negative_prompt, steps, seed, width, height
- Nodes: CheckpointLoader -> CLIP -> KSampler -> VAE -> SaveImage

Co-Authored-By: Warp <agent@warp.dev>
This commit is contained in:
Apple
2026-02-10 04:39:40 -08:00
parent 42599787a6
commit 25e57d8221

View File

@@ -7,12 +7,66 @@ from .worker import enqueue
router = APIRouter()
def _build_workflow_t2i(req: GenerateImageRequest) -> dict:
# MVP: placeholder graph; you will replace with your canonical Comfy workflow JSON.
# Keep it deterministic and param-driven.
# Basic SD 1.5 workflow
# Node structure: CheckpointLoader -> CLIP Encode -> KSampler -> VAE Decode -> SaveImage
return {
"1": {"class_type": "CLIPTextEncode", "inputs": {"text": req.prompt, "clip": ["2", 0]}},
"2": {"class_type": "CheckpointLoaderSimple", "inputs": {"ckpt_name": "sdxl.safetensors"}},
# TODO: Add complete workflow JSON for text-to-image
"3": {
"inputs": {
"seed": req.seed if req.seed else 42,
"steps": req.steps,
"cfg": 7.0,
"sampler_name": "euler",
"scheduler": "normal",
"denoise": 1,
"model": ["4", 0],
"positive": ["6", 0],
"negative": ["7", 0],
"latent_image": ["5", 0]
},
"class_type": "KSampler"
},
"4": {
"inputs": {
"ckpt_name": "v1-5-pruned-emaonly.safetensors"
},
"class_type": "CheckpointLoaderSimple"
},
"5": {
"inputs": {
"width": req.width,
"height": req.height,
"batch_size": 1
},
"class_type": "EmptyLatentImage"
},
"6": {
"inputs": {
"text": req.prompt,
"clip": ["4", 1]
},
"class_type": "CLIPTextEncode"
},
"7": {
"inputs": {
"text": req.negative_prompt if req.negative_prompt else "text, watermark, blurry",
"clip": ["4", 1]
},
"class_type": "CLIPTextEncode"
},
"8": {
"inputs": {
"samples": ["3", 0],
"vae": ["4", 2]
},
"class_type": "VAEDecode"
},
"9": {
"inputs": {
"filename_prefix": "comfy-agent",
"images": ["8", 0]
},
"class_type": "SaveImage"
}
}
def _build_workflow_t2v(req: GenerateVideoRequest) -> dict: