{
 "schema_version": "1.0",
 "nodes": [
  {
   "id": "product",
   "type": "input/image",
   "label": "Product",
   "parameters": {
    "image": "__TEAPOT__",
    "required": true
   }
  },
  {
   "id": "brand_colors",
   "type": "input/text",
   "label": "Brand colours",
   "parameters": {
    "text": "#1F3A6E, #2F55A4, #F2EBDD, #C9963B",
    "required": true
   }
  },
  {
   "id": "attempt_number",
   "type": "input/number",
   "label": "Attempt number",
   "parameters": {
    "required": true
   }
  },
  {
   "id": "previous_feedback",
   "type": "input/text",
   "label": "Previous feedback",
   "parameters": {
    "text": "",
    "multiline": true,
    "required": false
   }
  },
  {
   "id": "shot",
   "type": "ai/lifestyle",
   "label": "Campaign picture",
   "parameters": {
    "aspect_ratio": "4_5",
    "custom_prompt": "A cosy autumn afternoon: the product on a table by a window at golden hour, with a knitted blanket, pumpkins and a lit candle."
   }
  },
  {
   "id": "colours",
   "type": "image/color_palette",
   "label": "Brand colours?",
   "parameters": {
    "count": 8,
    "reference_colors": "#1F3A6E, #2F55A4, #F2EBDD, #C9963B",
    "max_distance": 0.12,
    "max_off_palette": 0.3,
    "require_all": false
   }
  },
  {
   "id": "status",
   "type": "utility/extract",
   "label": "Status",
   "parameters": {
    "path": "status",
    "expected_type": "text"
   }
  },
  {
   "id": "on_brand",
   "type": "utility/predicate",
   "label": "On brand?",
   "parameters": {
    "operation": "equals",
    "compare_text": "passed"
   }
  },
  {
   "id": "grade",
   "type": "utility/calculate",
   "label": "Score",
   "parameters": {
    "expression": "round(1 - check.metrics.off_palette_proportion, 3)"
   }
  },
  {
   "id": "why",
   "type": "text/expression",
   "label": "Correction",
   "parameters": {
    "expression": "{{ if check.status == \"passed\" }}On brand: {{ check.summary }}{{ else }}The picture is off brand: {{ check.summary }}{{ for v in check.violations }} {{ v.message }}{{ end }} Keep the product exactly as it is. Change the setting, the props and the light so that the picture keeps to the brand colours {{ brand_colors }}: no warm orange, red or brown tones.{{ end }}"
   }
  },
  {
   "id": "o_cand",
   "type": "output/image",
   "label": "candidate",
   "parameters": {
    "output_name": "candidate"
   }
  },
  {
   "id": "o_acc",
   "type": "output/json",
   "label": "accepted",
   "parameters": {
    "output_name": "accepted"
   }
  },
  {
   "id": "o_score",
   "type": "output/json",
   "label": "score",
   "parameters": {
    "output_name": "score"
   }
  },
  {
   "id": "o_fb",
   "type": "output/text",
   "label": "feedback",
   "parameters": {
    "output_name": "feedback"
   }
  }
 ],
 "connections": [
  {
   "from_node": "product",
   "from_output": "image",
   "to_node": "shot",
   "to_input": "product_image"
  },
  {
   "from_node": "previous_feedback",
   "from_output": "text",
   "to_node": "shot",
   "to_input": "instructions"
  },
  {
   "from_node": "shot",
   "from_output": "result",
   "to_node": "colours",
   "to_input": "image"
  },
  {
   "from_node": "colours",
   "from_output": "quality_check",
   "to_node": "status",
   "to_input": "json"
  },
  {
   "from_node": "status",
   "from_output": "value",
   "to_node": "on_brand",
   "to_input": "a"
  },
  {
   "from_node": "colours",
   "from_output": "quality_check",
   "to_node": "grade",
   "to_input": "check"
  },
  {
   "from_node": "colours",
   "from_output": "quality_check",
   "to_node": "why",
   "to_input": "check"
  },
  {
   "from_node": "brand_colors",
   "from_output": "text",
   "to_node": "why",
   "to_input": "brand_colors"
  },
  {
   "from_node": "shot",
   "from_output": "result",
   "to_node": "o_cand",
   "to_input": "image"
  },
  {
   "from_node": "on_brand",
   "from_output": "result",
   "to_node": "o_acc",
   "to_input": "json"
  },
  {
   "from_node": "grade",
   "from_output": "result",
   "to_node": "o_score",
   "to_input": "json"
  },
  {
   "from_node": "why",
   "from_output": "text",
   "to_node": "o_fb",
   "to_input": "text"
  }
 ],
 "layout": {
  "nodes": {
   "product": {
    "x": 80,
    "y": 80
   },
   "brand_colors": {
    "x": 80,
    "y": 280
   },
   "attempt_number": {
    "x": 80,
    "y": 480
   },
   "previous_feedback": {
    "x": 80,
    "y": 680
   },
   "shot": {
    "x": 420,
    "y": 80
   },
   "colours": {
    "x": 760,
    "y": 80
   },
   "status": {
    "x": 1100,
    "y": 80
   },
   "on_brand": {
    "x": 1440,
    "y": 80
   },
   "grade": {
    "x": 1100,
    "y": 280
   },
   "why": {
    "x": 1100,
    "y": 480
   },
   "o_cand": {
    "x": 760,
    "y": 280
   },
   "o_acc": {
    "x": 1780,
    "y": 80
   },
   "o_score": {
    "x": 1440,
    "y": 280
   },
   "o_fb": {
    "x": 1440,
    "y": 480
   }
  }
 }
}
