{
 "schema_version": "1.0",
 "nodes": [
  {
   "id": "product",
   "type": "input/image",
   "label": "Product",
   "parameters": {
    "image": "__JAR__",
    "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": "Scene",
   "parameters": {
    "aspect_ratio": "4_5",
    "custom_prompt": "The jar stands on the marble counter of an old Italian pharmacy, among wooden drawers and glass bottles, seen from a three-quarter angle slightly above, warm afternoon light."
   }
  },
  {
   "id": "find",
   "type": "ai/locate_subject",
   "label": "The product in the scene",
   "parameters": {
    "framing": "subject",
    "margin": 0.06
   }
  },
  {
   "id": "judge",
   "type": "ai/decide",
   "label": "Same product?",
   "parameters": {
    "image_detail": "high",
    "questions": {
     "schema": "madoo.decision-questions/v1",
     "questions": [
      {
       "name": "faithfulness",
       "type": "score",
       "threshold": 0.6,
       "instructions": "How faithfully Picture 1 reproduces the product of Picture 2. Judge only what a change of viewpoint cannot explain: the decoration and its motifs, any portrait or figure, the colours of the glaze or print, and any lettering letter for letter. Ignore the background, the light, the framing, the perspective and the apparent proportions due to the camera angle.",
       "levels": [
        {
         "label": "different",
         "description": "Another product"
        },
        {
         "label": "similar",
         "description": "Similar shape, different decoration"
        },
        {
         "label": "close",
         "description": "The same product with visible changes in shape or decoration"
        },
        {
         "label": "faithful",
         "description": "The same product, no visible changes"
        }
       ]
      }
     ]
    }
   }
  },
  {
   "id": "grade",
   "type": "utility/calculate",
   "label": "Score 0-1",
   "parameters": {
    "expression": "if(found, faithfulness / 3, 0)"
   }
  },
  {
   "id": "both",
   "type": "utility/boolean_combine",
   "label": "Found and faithful",
   "parameters": {
    "mode": "all"
   }
  },
  {
   "id": "faithful",
   "type": "utility/predicate",
   "label": "Faithful?",
   "parameters": {
    "operation": "equals",
    "compare_text": "faithful"
   }
  },
  {
   "id": "ask",
   "type": "text/expression",
   "label": "What to look for",
   "parameters": {
    "expression": "Picture 1 is the product cut out of a generated photograph; Picture 2 is the real product. A judge rated how faithfully it reproduces the product as: {{ level }}{{ if level != \"faithful\" }}, so the product differs from Picture 2 somewhere{{ end }}. List, as short instructions to the photographer, every difference in the product itself that a change of viewpoint cannot explain — decoration and motifs, portraits or figures, colours, lettering letter for letter — so that Picture 1 shows exactly the product of Picture 2. Do not ask to change proportions, perspective, background, light or framing: the scene and the camera angle are chosen on purpose.{{ if level == \"faithful\" }} If there is no difference, answer: none.{{ end }}"
   }
  },
  {
   "id": "diff",
   "type": "ai/image_analysis",
   "label": "What differs"
  },
  {
   "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": "find",
   "to_input": "image"
  },
  {
   "from_node": "product",
   "from_output": "image",
   "to_node": "find",
   "to_input": "references"
  },
  {
   "from_node": "find",
   "from_output": "crop",
   "to_node": "judge",
   "to_input": "images"
  },
  {
   "from_node": "product",
   "from_output": "image",
   "to_node": "judge",
   "to_input": "images"
  },
  {
   "from_node": "judge",
   "from_output": "faithfulness",
   "to_node": "grade",
   "to_input": "faithfulness"
  },
  {
   "from_node": "find",
   "from_output": "found",
   "to_node": "grade",
   "to_input": "found"
  },
  {
   "from_node": "find",
   "from_output": "found",
   "to_node": "both",
   "to_input": "conditions"
  },
  {
   "from_node": "faithful",
   "from_output": "result",
   "to_node": "both",
   "to_input": "conditions"
  },
  {
   "from_node": "judge",
   "from_output": "faithfulness_level",
   "to_node": "faithful",
   "to_input": "a"
  },
  {
   "from_node": "judge",
   "from_output": "faithfulness_level",
   "to_node": "ask",
   "to_input": "level"
  },
  {
   "from_node": "ask",
   "from_output": "text",
   "to_node": "diff",
   "to_input": "prompt"
  },
  {
   "from_node": "find",
   "from_output": "crop",
   "to_node": "diff",
   "to_input": "images"
  },
  {
   "from_node": "product",
   "from_output": "image",
   "to_node": "diff",
   "to_input": "images"
  },
  {
   "from_node": "shot",
   "from_output": "result",
   "to_node": "o_cand",
   "to_input": "image"
  },
  {
   "from_node": "both",
   "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": "diff",
   "from_output": "result",
   "to_node": "o_fb",
   "to_input": "text"
  }
 ],
 "layout": {
  "nodes": {
   "product": {
    "x": 80,
    "y": 80
   },
   "attempt_number": {
    "x": 80,
    "y": 280
   },
   "previous_feedback": {
    "x": 80,
    "y": 480
   },
   "shot": {
    "x": 420,
    "y": 80
   },
   "find": {
    "x": 760,
    "y": 80
   },
   "judge": {
    "x": 1100,
    "y": 80
   },
   "grade": {
    "x": 1440,
    "y": 80
   },
   "both": {
    "x": 1780,
    "y": 80
   },
   "faithful": {
    "x": 1440,
    "y": 280
   },
   "ask": {
    "x": 1440,
    "y": 480
   },
   "diff": {
    "x": 1780,
    "y": 280
   },
   "o_cand": {
    "x": 760,
    "y": 280
   },
   "o_acc": {
    "x": 2120,
    "y": 80
   },
   "o_score": {
    "x": 1780,
    "y": 480
   },
   "o_fb": {
    "x": 2120,
    "y": 280
   }
  }
 }
}
