{
  "name": "Split test different agent prompts with Supabase and OpenAI",
  "nodes": [
    {
      "id": "e8404493-4297-4169-a72f-89e668ae5fbc",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1460,
        -140
      ]
    },
    {
      "id": "582e1c1b-12ff-42ff-8130-48f94eebd706",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        220,
        -160
      ]
    },
    {
      "id": "39ca5c70-11d4-4f86-bde5-0f9827297be9",
      "name": "Check If Session Exists",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -960,
        -140
      ]
    },
    {
      "id": "35f2c270-9571-41ba-ab7c-47a6742d7d90",
      "name": "If Session Does Exist",
      "type": "n8n-nodes-base.if",
      "position": [
        -720,
        -140
      ]
    },
    {
      "id": "ec00ad92-96e9-4936-a547-2a2715ff5c32",
      "name": "Assign Path To Session",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -400,
        -20
      ]
    },
    {
      "id": "92ee7145-30ae-41e9-bc04-eef03b84485e",
      "name": "Define Path Values",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        -140
      ]
    },
    {
      "id": "23c1b4e2-2ba2-4237-bb4b-b92da127d201",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        300,
        60
      ]
    },
    {
      "id": "be3f14b9-68c7-457d-b5bf-a6abbadf5b67",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        480,
        60
      ]
    },
    {
      "id": "1c20d274-2482-4551-a4ea-64860eb35276",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -260
      ],
      "parameters": {
        "width": 220,
        "height": 300,
        "content": "## 1. Receive Message\n\n"
      }
    },
    {
      "id": "ee22d3b1-d447-4e35-8ac4-d093edf6deee",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        -340
      ],
      "parameters": {
        "width": 1340,
        "height": 500,
        "content": "## 2. Determine Prompt for LLM\n"
      }
    },
    {
      "id": "7d90ec00-5fca-4b0d-bc1f-e8b8c179b960",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -240
      ],
      "parameters": {
        "width": 520,
        "height": 440,
        "content": "## 3. AI Agent"
      }
    },
    {
      "id": "b9b9e0e8-53c1-4d6a-bbdc-c2a13d740dfb",
      "name": "Get Correct Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        -80,
        -160
      ]
    },
    {
      "id": "2b78ce9b-e6b4-4744-8ddf-00f8ae990fc8",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1260,
        -240
      ],
      "parameters": {
        "width": 220,
        "height": 260,
        "content": "### Modification\nSet the values of the  baseline and alternative prompts"
      }
    },
    {
      "id": "0646f176-407a-41ee-b602-34bd681fc421",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        40
      ],
      "parameters": {
        "width": 340,
        "height": 140,
        "content": "### Modification\nReplace this sub-node \nto use a different language\n model"
      }
    },
    {
      "id": "a391018c-5d28-4384-89e1-0435758a6945",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1480,
        -600
      ],
      "parameters": {
        "width": 520,
        "height": 240,
        "content": "### Setup\n1. Create a table in Supabase called **split_test_sessions**. It needs to have the following columns: **session_id** (`text`) and **show_alternative** (`bool`)\n2. Add your **Supabase**, **Op"
      }
    },
    {
      "id": "2382d146-f0c1-4de6-9e90-b17c304df692",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2120,
        -360
      ],
      "parameters": {
        "width": 560,
        "height": 480,
        "content": "\n## Split Test Different Agent Prompts with Supabase and OpenAI\n### Use Case\nOftentimes, it's useful to test different settings for a large language model in production against various metrics. Split "
      }
    }
  ],
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Define Path Values": {
      "main": [
        [
          {
            "node": "Check If Session Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Correct Prompt": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "If Session Does Exist": {
      "main": [
        [
          {
            "node": "Get Correct Prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Assign Path To Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assign Path To Session": {
      "main": [
        [
          {
            "node": "Get Correct Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Session Exists": {
      "main": [
        [
          {
            "node": "If Session Does Exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Define Path Values",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}