{
  "name": "dssat-rag",
  "nodes": [
    {
      "parameters": {
        "public": true,
        "initialMessages": "Hi there! \ud83d\udc4b\nHow can I assist you today?",
        "options": {
          "allowFileUploads": true
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.4,
      "position": [
        -2224,
        144
      ],
      "id": "e9640bc7-db9b-4641-9c46-8ed8f4285d01",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "model": "sfr-embedding-mistral",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        -640,
        624
      ],
      "id": "b104ae7b-75e4-46d0-8e60-a15bd029cb80",
      "name": "Embeddings OpenAI1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "You are a DSSAT expert. answer the question, based on the tool, very concisely in upto 2 sentence. do not provide clutter or explanations, just the curated answer.\n\ndo NOT provide answers outside the available data, answer only from the provided data. for some queries you would need to relate different runs to drive insights and key points.\n\nIf the query involves crop that is not available, ask user to run dssat for new crop and provide overview file to process then only you can answer for that.\n\nif the query involves question with varying parameter values, if exact parameter value is not available, try to get answer from available data with nearest available parameter value and in your response, inform user to run dssat if exact parameter value to be used in calculation.\nif the parameter value is present already, then answer as usual.",
          "maxIterations": 5
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        -1312,
        208
      ],
      "id": "bad841da-496b-44ae-85d3-8eeaa4480f9b",
      "name": "AI Agent2"
    },
    {
      "parameters": {
        "dataType": "binary",
        "loader": "textLoader",
        "textSplittingMode": "custom",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1.1,
      "position": [
        -800,
        64
      ],
      "id": "3b090d38-d8bc-461e-a142-a6ac3535a5b2",
      "name": "Default Data Loader2"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "aab9b788-f2ee-4149-a6d0-4ba26fc51692",
              "leftValue": "={{ $json.files[0] }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -1968,
        144
      ],
      "id": "e10ddd76-e6ef-4401-bc8c-9b1fa013da0d",
      "name": "If2"
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolDescription": "Use this tool to look up DSSAT simulation results, including crop yield (kg/ha), anthesis dates, and maturity dates from the uploaded files.",
        "memoryKey": {
          "__rl": true,
          "value": "={{ $json.sessionId }}",
          "mode": "id"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "typeVersion": 1.3,
      "position": [
        -1088,
        448
      ],
      "id": "52e51e54-b679-4f81-acbf-335bc1ed4716",
      "name": "Simple Vector Store5"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-oss-120b",
          "mode": "list",
          "cachedResultName": "gpt-oss-120b"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        -1424,
        480
      ],
      "id": "e306efc1-44a9-47c8-b508-251e8049a3db",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "value": "={{ $json.sessionId }}",
          "mode": "id"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "typeVersion": 1.3,
      "position": [
        -912,
        -96
      ],
      "id": "1a03b213-7f68-49e0-a1cb-abc275336829",
      "name": "Simple Vector Store"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        -560,
        -96
      ],
      "id": "93266923-b2f6-44bf-9bb1-42905ea68ae3",
      "name": "Limit"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1aac015e-af48-49cc-87cc-49d9c503fe09",
              "name": "output",
              "value": "=file processed",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -352,
        -96
      ],
      "id": "5b3255da-6816-4459-b2be-2b1c1c09f433",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "chunkSize": 10000,
        "chunkOverlap": 2000
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        -608,
        272
      ],
      "id": "0b0d4fad-87e8-42c9-b6dd-52c2a67329f0",
      "name": "Character Text Splitter"
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Simple Vector Store5",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Simple Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader2": {
      "ai_document": [
        [
          {
            "node": "Simple Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "Simple Vector Store",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Vector Store5": {
      "ai_tool": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Vector Store": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        []
      ]
    },
    "Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader2",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "ab59e186-5b0c-4086-a043-df26eb3cfd39",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "daf6x7QwOhRZFxpe",
  "tags": []
}