{
  "name": "Generate dynamic JSON output formats for AI agents with Mistral",
  "nodes": [
    {
      "id": "d8b4728f-23bb-42cf-aff4-128e61d141ad",
      "name": "Mistral Cloud Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
      "position": [
        1020,
        80
      ]
    },
    {
      "id": "66103c5a-f12d-4505-a1b5-2e294bb3f827",
      "name": "JSON Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1020,
        -140
      ]
    },
    {
      "id": "608baf6f-daa5-4f8c-8edb-643decee6197",
      "name": "JSON Generator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        740,
        -280
      ]
    },
    {
      "id": "53456018-4071-4442-a132-83eb1fad40f7",
      "name": "JSON Validator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1240,
        -280
      ]
    },
    {
      "id": "5eaac98d-84b9-4e03-8ea0-980a375f4cae",
      "name": "JSON Output Parser 2",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1400,
        -20
      ]
    },
    {
      "id": "8f1dbe6a-d35e-43bd-b5d1-6553f223bf89",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -500,
        -140
      ]
    },
    {
      "id": "426b7257-a0b3-4ce3-a8f9-c02222d5582f",
      "name": "Prepare Input",
      "type": "n8n-nodes-base.set",
      "position": [
        -240,
        -140
      ]
    },
    {
      "id": "f9de1d71-8da8-4a5a-a8d3-9aad4f0b6821",
      "name": "Loop Until it Works",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        420,
        -80
      ]
    },
    {
      "id": "733867ee-9d1a-4cca-a82f-51d87ee53b35",
      "name": "Update Input",
      "type": "n8n-nodes-base.set",
      "position": [
        1820,
        280
      ]
    },
    {
      "id": "397a0c82-fab4-43c4-bbc6-7716cc087738",
      "name": "If Valid JSON",
      "type": "n8n-nodes-base.if",
      "position": [
        1580,
        -100
      ]
    },
    {
      "id": "60d59670-4f1e-43a4-ab88-80db611fd810",
      "name": "JSON Reviewer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1900,
        -240
      ]
    },
    {
      "id": "051fa8d6-aef4-49c9-8e3b-55f2781bba53",
      "name": "Guarantee Input",
      "type": "n8n-nodes-base.set",
      "position": [
        20,
        -100
      ]
    },
    {
      "id": "b202d5ce-5386-42ce-8825-5562a56fff55",
      "name": "Mistral Cloud Chat Model 2",
      "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
      "position": [
        1900,
        -20
      ]
    },
    {
      "id": "d013093a-da21-433c-8a27-57cca6a4439e",
      "name": "Advanced JSON Output Parser",
      "type": "n8n-nodes-advanced-output-parser.advancedOutputParser",
      "position": [
        2060,
        -20
      ]
    },
    {
      "id": "cce477a7-a9d6-4427-abbd-39812c18dbfa",
      "name": "Update Input 2",
      "type": "n8n-nodes-base.set",
      "position": [
        2280,
        340
      ]
    },
    {
      "id": "c744a93e-2f1c-4695-85e5-e33bf7bd133c",
      "name": "JSON Format Works!",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2600,
        -260
      ]
    },
    {
      "id": "d252e5ee-a4f0-488c-9af7-fd72941425fa",
      "name": "Prepare Output",
      "type": "n8n-nodes-base.set",
      "position": [
        2820,
        -260
      ]
    },
    {
      "id": "2be9cb84-bc58-4d3d-8768-7bd2cf4d6e10",
      "name": "If No More Rounds",
      "type": "n8n-nodes-base.if",
      "position": [
        200,
        -100
      ]
    },
    {
      "id": "2f70e3b8-18b3-47cb-9edd-de4bb3c327ac",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1440,
        -600
      ],
      "parameters": {
        "width": 840,
        "height": 820,
        "content": "## JSON Architect - Dynamically Generate JSON Output Formats for Any AI Agent\n\n\n\n**Version** : 1.0\n**Creator** : Hybroht\n**Website** : hybroht.com\n\n\n\n\n\n**Description**: This workflow will instruct AI "
      }
    },
    {
      "id": "b4a5da69-fb3e-4db6-b41a-cae237c1523c",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        -520
      ],
      "parameters": {
        "width": 150,
        "height": null,
        "content": "![Hybroht](https://hybroht.com/assets/favicon.png \"Hybroht Logo\")"
      }
    },
    {
      "id": "06e1b233-f22c-4219-8367-24c18921404b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -680
      ],
      "parameters": {
        "width": 2560,
        "height": 1240,
        "content": "# JSON Construction\n\n**Round Start** will initiate the round of JSON construction.\n**JSON Generation & Validation** will generate and validate the JSON according to the input from the start of the rou"
      }
    },
    {
      "id": "4a528b75-cf8e-4534-8bc4-7f875047bd03",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        -500
      ],
      "parameters": {
        "width": 1080,
        "height": 720,
        "content": "## JSON Generation & Validation \n**JSON Generator** will attempt to create an appropriate JSON format for the input, preserving as much of its information as possible.\n**JSON Validator** will check if"
      }
    },
    {
      "id": "110676e0-1bcd-431b-bb3b-b62709e675a9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1800,
        -400
      ],
      "parameters": {
        "width": 660,
        "height": 560,
        "content": "## JSON Test\n**JSON Reviewer** will test the generated JSON format. If the test fails, the latest iteration of the JSON format will be sent back for a new round along with the error that occurred.\n**A"
      }
    },
    {
      "id": "80045779-5409-4662-8b89-1a142e750f7a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        240
      ],
      "parameters": {
        "width": 1800,
        "height": 300,
        "content": "## Validation or Test fails\n\n- If the **JSON Validator** rejects the generated JSON or if it fails the test conducted by the JSON Reviewer, it will be sent back to the beginning.\n- The loop will resta"
      }
    },
    {
      "id": "8815f509-8644-4a1b-991e-6213efa58d26",
      "name": "Round Limit Reached",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        420,
        -280
      ]
    },
    {
      "id": "ade7be68-4ad1-4884-b38a-2abdf52c80fe",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -400
      ],
      "parameters": {
        "width": 680,
        "height": 560,
        "content": "## Round Start\n**Guarantee Input** will ensure that the input going into the loop is as expected.\n**If No More Rounds** will check the number of rounds passed to see if it has reached the limit.\n**Loo"
      }
    },
    {
      "id": "240025e4-8d07-406f-bb96-c1ec875d8c23",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2540,
        -440
      ],
      "parameters": {
        "width": 580,
        "height": 820,
        "content": "## JSON Architect Results\n**Prepare Output** will capture the results of the JSON Architect and prepare them to be released as an output."
      }
    },
    {
      "id": "b3659bca-2065-4b12-b065-4e02a63bc626",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -400
      ],
      "parameters": {
        "width": 480,
        "height": 720,
        "content": "## Setup and Start\n**Prepare Input** will simulate the acquisition of the expected data for better compatibility with eventually turning this workflow into a sub-workflow."
      }
    },
    {
      "id": "992d3320-5cfd-4a61-8924-75461afb6778",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -680
      ],
      "parameters": {
        "width": 480,
        "height": 260,
        "content": "### Information - n8n setup\n- n8n Version\n1.100.1\n\n- n8n-nodes-advanced-output-parser\n1.0.1\n\n- Running n8n via:\nPodman 4.3.1\n\n- Operating system:\nLinux"
      }
    },
    {
      "id": "0fa743a0-19f7-4999-b023-85bee0edc506",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        60
      ],
      "parameters": {
        "width": 380,
        "height": 220,
        "content": "**Expected Input**:\n\n- **input** : The input that requires a proper JSON structure.\n- **max_rounds** : The maximum number of rounds before stopping the loop if it fails to produce and test a valid JSO"
      }
    },
    {
      "id": "4abd3949-dec0-4292-a6fd-5b4d815f9896",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2580,
        -60
      ],
      "parameters": {
        "width": 480,
        "height": 360,
        "content": "**Expected Output**:\n\n- **input** : The original input used to create the JSON structure.\n- **json_format_name** : A snake_case identifier for the generated JSON format, created by the AI agents based"
      }
    },
    {
      "id": "33a162fa-5031-4443-814b-12e120ea3787",
      "name": "Sticky Note17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        200
      ],
      "parameters": {
        "width": 380,
        "height": 220,
        "content": "**Round Args**:\n\n- **correction_required** : If a round fails, the AI agents will indicate why it failed. This information will be provided to the JSON Generator in the next round in an attempt to fix"
      }
    },
    {
      "id": "47f5a6d6-7405-49e2-89a2-91d62518b56b",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1420,
        340
      ],
      "parameters": {
        "width": 1340,
        "height": 1980,
        "content": "### Input & Output Example\n\n\n---\n\n**Input**: \"A scenario where two characters are speaking with each other. It is during the night. They are talking about their respective magical powers: the ability "
      }
    },
    {
      "id": "fa3c77db-ff57-435b-94fc-8ac91011a249",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        700
      ],
      "parameters": {
        "width": 1000,
        "height": 1620,
        "content": "- **json_format_structure** : \n{\n  \"type\": \"object\",\n  \"properties\": {\n\t\"conversation\": {\n\t  \"type\": \"object\",\n\t  \"properties\": {\n\t\t\"time\": {\n\t\t  \"type\": \"string\",\n\t\t  \"description\": \"The time of the "
      }
    }
  ],
  "connections": {
    "Update Input": {
      "main": [
        [
          {
            "node": "Guarantee Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Valid JSON": {
      "main": [
        [
          {
            "node": "JSON Reviewer",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Reviewer": {
      "main": [
        [
          {
            "node": "JSON Format Works!",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Input 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Input": {
      "main": [
        [
          {
            "node": "Guarantee Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Generator": {
      "main": [
        [
          {
            "node": "JSON Validator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Validator": {
      "main": [
        [
          {
            "node": "If Valid JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Input 2": {
      "main": [
        [
          {
            "node": "Guarantee Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Guarantee Input": {
      "main": [
        [
          {
            "node": "If No More Rounds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If No More Rounds": {
      "main": [
        [
          {
            "node": "Round Limit Reached",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Until it Works",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Format Works!": {
      "main": [
        [
          {
            "node": "Prepare Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "JSON Generator",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Loop Until it Works": {
      "main": [
        [],
        [
          {
            "node": "JSON Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Output Parser 2": {
      "ai_outputParser": [
        [
          {
            "node": "JSON Validator",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Mistral Cloud Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "JSON Generator",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "JSON Validator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Mistral Cloud Chat Model 2": {
      "ai_languageModel": [
        [
          {
            "node": "JSON Reviewer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Advanced JSON Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "JSON Reviewer",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Prepare Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}