{
  "name": "Agent-Trainer-Micro",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "trainer-micro",
        "options": {
          "rawBody": false
        }
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -500,
        200
      ],
      "id": "webhook-trainer",
      "name": "Webhook: Receive Training Data"
    },
    {
      "parameters": {
        "operation": "xlsx",
        "binaryPropertyName": "file",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        -100,
        0
      ],
      "id": "parse-excel",
      "name": "Parse Excel"
    },
    {
      "parameters": {
        "operation": "pdf",
        "binaryPropertyName": "file",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        -100,
        400
      ],
      "id": "parse-pdf",
      "name": "Parse PDF"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "type": "string"
          },
          "conditions": [
            {
              "id": "is-pdf",
              "leftValue": "={{ $('Webhook: Receive Training Data').item.json.body?.type }}",
              "rightValue": "checker",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.1,
      "position": [
        -300,
        200
      ],
      "id": "if-file-type",
      "name": "If Checker (PDF)"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Webhook: Receive Training Data').item.json.body?.prompt }}\n\nData to parse:\n{{ JSON.stringify($('Parse Excel').item.json) }}\n\nReturn the results strictly in JSON format.",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        150,
        0
      ],
      "id": "ai-trainer-maker",
      "name": "AI Trainer Maker"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Webhook: Receive Training Data').item.json.body?.prompt }}\n\nData to parse:\n{{ $('Parse PDF').item.json.text }}\n\nReturn the results strictly in JSON format.",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        150,
        400
      ],
      "id": "ai-trainer-checker",
      "name": "AI Trainer Checker"
    },
    {
      "parameters": {
        "modelSource": "inferenceProfile",
        "model": "us.anthropic.claude-opus-4-20250514-v1:0",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAwsBedrock",
      "typeVersion": 1.1,
      "position": [
        150,
        200
      ],
      "id": "bedrock-trainer",
      "name": "AWS Bedrock",
      "credentials": {
        "aws": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"cusip\": \"\",\n  \"eventType\": \"\",\n  \"principalRate\": 1000,\n  \"premiumRate\": 0,\n  \"securityCalledAmount\": 0,\n  \"securityDescription\": \"\",\n  \"payableDate\": \"\",\n  \"publicationDate\": \"\",\n  \"recordDate\": \"\",\n  \"status\": \"Created\",\n  \"confidenceScore\": 0.0\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        350,
        -100
      ],
      "id": "json-formatter-maker",
      "name": "JSON Formatter (Maker)"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"cusip\": \"\",\n  \"payableDate\": \"\",\n  \"publicationDate\": \"\",\n  \"eventType\": \"\",\n  \"securityCalledAmount\": 0,\n  \"securityDescription\": \"\",\n  \"confidenceScore\": 0.0\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        350,
        500
      ],
      "id": "json-formatter-checker",
      "name": "JSON Formatter (Checker)"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Webhook: Receive Training Data').item.json.body?.baseUrl }}/api/training/callback",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { sessionId: $('Webhook: Receive Training Data').item.json.body?.sessionId, type: $('Webhook: Receive Training Data').item.json.body?.type, result: JSON.stringify($json.output) } }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        600,
        200
      ],
      "id": "trainer-callback",
      "name": "Trainer Callback"
    }
  ],
  "connections": {
    "Webhook: Receive Training Data": {
      "main": [
        [
          {
            "node": "If Checker (PDF)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Checker (PDF)": {
      "main": [
        [
          {
            "node": "Parse PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Parse Excel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Excel": {
      "main": [
        [
          {
            "node": "AI Trainer Maker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse PDF": {
      "main": [
        [
          {
            "node": "AI Trainer Checker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Trainer Maker": {
      "main": [
        [
          {
            "node": "Trainer Callback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Trainer Checker": {
      "main": [
        [
          {
            "node": "Trainer Callback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AWS Bedrock": {
      "ai_languageModel": [
        [
          {
            "node": "AI Trainer Maker",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Trainer Checker",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "JSON Formatter (Maker)": {
      "ai_outputParser": [
        [
          {
            "node": "AI Trainer Maker",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "JSON Formatter (Checker)": {
      "ai_outputParser": [
        [
          {
            "node": "AI Trainer Checker",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateId": "2315"
  }
}