{
 "name": "[노드 한 장] Simple Vector Store · 가상 정책을 다른 표현으로 검색",
 "nodes": [
  {
   "id": "m",
   "name": "Run manually",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    0
   ],
   "parameters": {}
  },
  {
   "id": "p",
   "name": "Prepare three sample policies",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    220,
    0
   ],
   "parameters": {
    "jsCode": "// 교육용 가상 정책만. 실제 회사 문서/개인정보 없음\nconst policies=[\"[교육용 가상 정책: 휴가] 실제 회사 규정이 아닙니다. 연차는 예정일 사흘 전에 신청합니다. 갑자기 병원에 가야 하는 긴급 사유는 당일 신청도 가능합니다.\",\"[교육용 가상 정책: 재택 장비] 실제 회사 규정이 아닙니다. 재택근무 장비를 지급받으면 처음 온라인 업무를 시작하기 전에 운영체제 보안 업데이트를 설치하고 VPN 접속 시험을 마칩니다.\",\"[교육용 가상 정책: 비용 정산] 실제 회사 규정이 아닙니다. 출장 교통비는 택시 영수증과 사용 사유를 붙여 다음 주 월요일까지 제출합니다. 증빙 없는 비용은 승인하지 않습니다.\"];const data=await this.helpers.prepareBinaryData(Buffer.from(JSON.stringify(policies.map(policy=>({policy}))),\"utf8\"),\"sample-policies.json\",\"application/json\");return [{json:{sample:true,policyCount:3},binary:{data}}];"
   }
  },
  {
   "id": "i",
   "name": "Insert sample policies",
   "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
   "typeVersion": 1.3,
   "position": [
    440,
    0
   ],
   "parameters": {
    "mode": "insert",
    "memoryKey": {
     "__rl": true,
     "mode": "id",
     "value": "TEST_VECTOR_STORE_KEY"
    },
    "clearStore": false,
    "embeddingBatchSize": 200
   }
  },
  {
   "id": "q",
   "name": "Prepare one search",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    660,
    0
   ],
   "parameters": {
    "jsCode": "return [{json:{sample:true,query:\"집에서 업무 볼 노트북을 받았는데 인터넷 연결 전에 뭘 해야 하죠?\",insertOutputItems:$input.all().length}}];"
   }
  },
  {
   "id": "s",
   "name": "Search same memory",
   "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
   "typeVersion": 1.3,
   "position": [
    880,
    0
   ],
   "parameters": {
    "mode": "load",
    "memoryKey": {
     "__rl": true,
     "mode": "id",
     "value": "TEST_VECTOR_STORE_KEY"
    },
    "prompt": "={{ $json.query }}",
    "topK": 3,
    "includeDocumentMetadata": true
   }
  },
  {
   "id": "v",
   "name": "Verify retrieved content",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    1100,
    0
   ],
   "parameters": {
    "jsCode": "const expected=[\"[교육용 가상 정책: 휴가] 실제 회사 규정이 아닙니다. 연차는 예정일 사흘 전에 신청합니다. 갑자기 병원에 가야 하는 긴급 사유는 당일 신청도 가능합니다.\",\"[교육용 가상 정책: 재택 장비] 실제 회사 규정이 아닙니다. 재택근무 장비를 지급받으면 처음 온라인 업무를 시작하기 전에 운영체제 보안 업데이트를 설치하고 VPN 접속 시험을 마칩니다.\",\"[교육용 가상 정책: 비용 정산] 실제 회사 규정이 아닙니다. 출장 교통비는 택시 영수증과 사용 사유를 붙여 다음 주 월요일까지 제출합니다. 증빙 없는 비용은 승인하지 않습니다.\"];const rows=$input.all().map(i=>i.json);const docs=rows.map(r=>r.document?.pageContent??r.pageContent);return [{json:{sample:true,retrievedItems:rows.length,uniqueContents:new Set(docs).size,allMatchSamples:docs.every(c=>expected.includes(c)),allPoliciesPresent:expected.every(c=>docs.includes(c)),results:rows}}];"
   }
  },
  {
   "id": "d",
   "name": "Default Data Loader",
   "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
   "typeVersion": 1.1,
   "position": [
    440,
    250
   ],
   "parameters": {
    "dataType": "binary",
    "binaryMode": "specificField",
    "binaryDataKey": "data",
    "loader": "jsonLoader",
    "textSplittingMode": "simple",
    "options": {
     "pointers": "/policy"
    }
   }
  },
  {
   "id": "e",
   "name": "Embeddings OpenAI",
   "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
   "typeVersion": 1.2,
   "position": [
    700,
    250
   ],
   "parameters": {
    "model": "text-embedding-3-small",
    "options": {}
   }
  }
 ],
 "connections": {
  "Run manually": {
   "main": [
    [
     {
      "node": "Prepare three sample policies",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Prepare three sample policies": {
   "main": [
    [
     {
      "node": "Insert sample policies",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Insert sample policies": {
   "main": [
    [
     {
      "node": "Prepare one search",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Prepare one search": {
   "main": [
    [
     {
      "node": "Search same memory",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Search same memory": {
   "main": [
    [
     {
      "node": "Verify retrieved content",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Default Data Loader": {
   "ai_document": [
    [
     {
      "node": "Insert sample policies",
      "type": "ai_document",
      "index": 0
     }
    ]
   ]
  },
  "Embeddings OpenAI": {
   "ai_embedding": [
    [
     {
      "node": "Insert sample policies",
      "type": "ai_embedding",
      "index": 0
     },
     {
      "node": "Search same memory",
      "type": "ai_embedding",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1",
  "timezone": "Asia/Seoul"
 },
 "meta": {
  "templateCredsSetupCompleted": false,
  "source": "datapopcorn.ai/workflow/nodes"
 }
}