{
  "name": "Evaluations metric: answer similarity",
  "nodes": [
    {
      "id": "c5365531-2d66-4e67-9db2-37059e9e97a3",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1512,
        420
      ]
    },
    {
      "id": "3881b831-b575-4b2f-8ebb-ac956a714f10",
      "name": "When fetching a dataset row",
      "type": "n8n-nodes-base.evaluationTrigger",
      "position": [
        -2040,
        100
      ]
    },
    {
      "id": "dd5a14f7-7321-4dfd-9f08-1f35efba1a07",
      "name": "Remap Input",
      "type": "n8n-nodes-base.set",
      "position": [
        -1820,
        100
      ]
    },
    {
      "id": "78d87631-7d52-4fbb-9313-f47263bd101f",
      "name": "Evaluation",
      "type": "n8n-nodes-base.evaluation",
      "position": [
        -1180,
        200
      ]
    },
    {
      "id": "1d8b12ba-ec63-4f92-a4dc-1885cbcd4d95",
      "name": "Set Input Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -960,
        100
      ]
    },
    {
      "id": "518cecea-9bcc-47dd-83b1-73ef0880e808",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -960,
        300
      ]
    },
    {
      "id": "c1a9cf2f-8e5d-4db9-a29b-b426e1932ab3",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1600,
        200
      ]
    },
    {
      "id": "6c5602d1-59c0-479e-b9aa-fb8ce037d4b1",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1820,
        300
      ]
    },
    {
      "id": "6fb01095-7b93-41dd-8d7c-364cb685ddbb",
      "name": "Update Output",
      "type": "n8n-nodes-base.evaluation",
      "position": [
        520,
        300
      ]
    },
    {
      "id": "18e8dbb6-df98-4d36-9686-9ec481a37754",
      "name": "Update Metrics",
      "type": "n8n-nodes-base.evaluation",
      "position": [
        700,
        300
      ]
    },
    {
      "id": "a685c9e7-0b21-4873-a502-5826a916e31f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2120,
        -120
      ],
      "parameters": {
        "width": 840,
        "height": 720,
        "content": "## 1. Setup Your AI Workflow to Use Evaluations\n[Learn more about the Evaluations Trigger](https://docs.n8n.io/integrations/builtin/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&u"
      }
    },
    {
      "id": "2e57d911-8fef-456d-8e5c-3849350553e1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1240,
        -120
      ],
      "parameters": {
        "width": 1700,
        "height": 720,
        "content": "## 2. Answer Similarity: How similar is the AI response to the Ground Truth?\n[Learn more about the Evaluations Trigger](https://docs.n8n.io/integrations/builtin/?utm_source=n8n_app&utm_medium=node_set"
      }
    },
    {
      "id": "9962bbf8-01bc-463c-ad3b-499618c5b1f9",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2580,
        -120
      ],
      "parameters": {
        "width": 420,
        "height": 720,
        "content": "## Try It Out!\n### This n8n template demonstrates how to calculate the evaluation metric \"Similarity\" which in this scenario, measures the consistency of the agent.\n\nThe scoring approach is adapted fr"
      }
    },
    {
      "id": "47699677-545f-4eca-8b46-89c6862a56f1",
      "name": "Get Embeddings",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -520,
        300
      ]
    },
    {
      "id": "1a022046-80f2-4df3-b075-be8e9294b951",
      "name": "GroundTruth to Items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -720,
        300
      ]
    },
    {
      "id": "0cea3a79-23ab-4d0f-9c6c-2522af6a506f",
      "name": "Get Embeddings1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -520,
        100
      ]
    },
    {
      "id": "1b5740cc-4b79-4690-88ae-fa31c5a1c16c",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -120,
        300
      ]
    },
    {
      "id": "d32f979b-7d96-4730-8324-de0d34ed659a",
      "name": "Remap Embeddings",
      "type": "n8n-nodes-base.set",
      "position": [
        -320,
        100
      ]
    },
    {
      "id": "188864fb-3d6a-4c01-9d23-73c731de023d",
      "name": "Remap Embeddings1",
      "type": "n8n-nodes-base.set",
      "position": [
        -320,
        300
      ]
    },
    {
      "id": "5cc6c1c7-240b-4129-b57a-e7d0ef2e72e6",
      "name": "Create Embeddings Result",
      "type": "n8n-nodes-base.merge",
      "position": [
        80,
        300
      ]
    },
    {
      "id": "7aa037d2-31a6-4efe-81b1-26a95c4c6d38",
      "name": "Calculate Similarity Score",
      "type": "n8n-nodes-base.code",
      "position": [
        280,
        300
      ]
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Evaluation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Create Embeddings Result",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Evaluation": {
      "main": [
        [
          {
            "node": "Set Input Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remap Input": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Output": {
      "main": [
        [
          {
            "node": "Update Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Embeddings": {
      "main": [
        [
          {
            "node": "Remap Embeddings1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Embeddings1": {
      "main": [
        [
          {
            "node": "Remap Embeddings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remap Embeddings": {
      "main": [
        [
          {
            "node": "Create Embeddings Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Input Fields": {
      "main": [
        [
          {
            "node": "Get Embeddings1",
            "type": "main",
            "index": 0
          },
          {
            "node": "GroundTruth to Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remap Embeddings1": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "GroundTruth to Items": {
      "main": [
        [
          {
            "node": "Get Embeddings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Embeddings Result": {
      "main": [
        [
          {
            "node": "Calculate Similarity Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Similarity Score": {
      "main": [
        [
          {
            "node": "Update Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When fetching a dataset row": {
      "main": [
        [
          {
            "node": "Remap Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}