{
  "name": "Update Knowledge",
  "nodes": [
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "query",
              "type": "object"
            }
          ]
        }
      },
      "id": "b4060667-6d76-467b-b763-ea02f117cb23",
      "typeVersion": 1.1,
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -680,
        400
      ]
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nreturn $input.first().json.query;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -460,
        400
      ],
      "id": "1cd25377-4448-4f4b-9a47-c0e19176032c",
      "name": "Code"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        -20,
        220
      ],
      "id": "87ac51c3-a150-4cb4-a6b5-d67a7b21f431",
      "name": "Embeddings OpenAI1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonMode": "expressionData",
        "jsonData": "={{ $json.text }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1,
      "position": [
        120,
        240
      ],
      "id": "02951879-d76c-410d-be0a-fcbcbe7cbebb",
      "name": "Default Data Loader"
    },
    {
      "parameters": {
        "chunkSize": 10000000000,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        200,
        420
      ],
      "id": "797fa68b-1f9f-4318-9b62-d902505102e2",
      "name": "Recursive Character Text Splitter"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.action }}",
                    "rightValue": "insert",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "100fd104-79ec-4d9d-997b-1a60731a1933"
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "319262f1-0879-4e23-a8d1-6c7df0ed392a",
                    "leftValue": "={{ $json.action }}",
                    "rightValue": "delete",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -240,
        400
      ],
      "id": "b08dd34a-9e06-4d5c-b1ea-124ffdd1c5f4",
      "name": "Switch"
    },
    {
      "parameters": {
        "mode": "insert",
        "pineconeIndex": {
          "__rl": true,
          "value": "knowlege-agent",
          "mode": "list",
          "cachedResultName": "knowlege-agent"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "id": "91c68c18-0560-41a6-84bb-363b915d1d36",
      "name": "Pinecone Insert",
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://knowlege-agent-hp0i744.svc.aped-4627-b74a.pinecone.io/vectors/delete",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "pineconeApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"ids\": [\"{{ Object.keys($json.vectors)[0] }}\"]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        600
      ],
      "id": "dc52899c-7c65-4deb-ab6a-345bc3f5b3f7",
      "name": "Delete Document",
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "https://knowlege-agent-hp0i744.svc.aped-4627-b74a.pinecone.io/vectors/fetch",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "pineconeApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"ids\": [\"{{ $json.id }}\"]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        140,
        600
      ],
      "id": "3329c213-730e-4816-a54a-a07d96e1efb2",
      "name": "Fetch Document",
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Insert",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Insert",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Pinecone Insert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fetch Document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Document": {
      "main": [
        [
          {
            "node": "Delete Document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a93d6ace-7d90-4b1f-a7e0-ad0b0e7c26e8",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "Abv7ymSJQeE7tieS",
  "tags": []
}