#!/bin/bash
# Submit test workflow to ComfyUI
# CLIPLoader + UnetLoaderGGUF + KSampler + VAEDecode

WORKFLOW='{
  "prompt": {
    "1": {
      "class_type": "UnetLoaderGGUF",
      "inputs": {
        "unet_name": "z_image_turbo-Q5_K_S.gguf"
      }
    },
    "2": {
      "class_type": "CLIPLoader",
      "inputs": {
        "clip_name": "gemma2_2b_lumina2.safetensors",
        "type": "lumina2"
      }
    },
    "3": {
      "class_type": "CLIPTextEncode",
      "inputs": {
        "text": "a photo of a cat sitting on a windowsill",
        "clip": ["2", 0]
      }
    },
    "4": {
      "class_type": "CLIPTextEncode",
      "inputs": {
        "text": "blurry, ugly, deformed",
        "clip": ["2", 0]
      }
    },
    "5": {
      "class_type": "EmptyLatentImage",
      "inputs": {
        "width": 256,
        "height": 256,
        "batch_size": 1
      }
    },
    "6": {
      "class_type": "KSampler",
      "inputs": {
        "model": ["1", 0],
        "seed": 42,
        "steps": 4,
        "cfg": 2.0,
        "sampler_name": "euler",
        "scheduler": "normal",
        "positive": ["3", 0],
        "negative": ["4", 0],
        "latent_image": ["5", 0],
        "denoise": 1.0
      }
    },
    "7": {
      "class_type": "VAELoader",
      "inputs": {
        "vae_name": "ae.safetensors"
      }
    },
    "8": {
      "class_type": "VAEDecode",
      "inputs": {
        "samples": ["6", 0],
        "vae": ["7", 0]
      }
    },
    "9": {
      "class_type": "SaveImage",
      "inputs": {
        "images": ["8", 0],
        "filename_prefix": "bc250_test"
      }
    }
  }
}'

echo "Submitting workflow..."
RESPONSE=$(curl -s -X POST http://localhost:8188/prompt \
  -H "Content-Type: application/json" \
  -d "$WORKFLOW")
echo "Response: $RESPONSE"
echo ""
echo "Timestamp: $(date)"
