@n8n/n8n-nodes-langchain 1.93.0 → 1.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js +4 -21
  2. package/dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js.map +1 -1
  3. package/dist/nodes/agents/Agent/Agent.node.js +19 -394
  4. package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
  5. package/dist/nodes/agents/Agent/V1/AgentV1.node.js +427 -0
  6. package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -0
  7. package/dist/nodes/agents/Agent/V2/AgentV2.node.js +162 -0
  8. package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -0
  9. package/dist/nodes/agents/Agent/agents/ToolsAgent/{description.js → V1/description.js} +2 -34
  10. package/dist/nodes/agents/Agent/agents/ToolsAgent/V1/description.js.map +1 -0
  11. package/dist/nodes/agents/Agent/agents/ToolsAgent/V1/execute.js +119 -0
  12. package/dist/nodes/agents/Agent/agents/ToolsAgent/V1/execute.js.map +1 -0
  13. package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js +40 -0
  14. package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js.map +1 -0
  15. package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js +139 -0
  16. package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js.map +1 -0
  17. package/dist/nodes/agents/Agent/agents/ToolsAgent/{execute.js → common.js} +7 -97
  18. package/dist/nodes/agents/Agent/agents/ToolsAgent/common.js.map +1 -0
  19. package/dist/nodes/agents/Agent/agents/ToolsAgent/options.js +62 -0
  20. package/dist/nodes/agents/Agent/agents/ToolsAgent/options.js.map +1 -0
  21. package/dist/nodes/chains/ChainLLM/ChainLlm.node.js +69 -51
  22. package/dist/nodes/chains/ChainLLM/ChainLlm.node.js.map +1 -1
  23. package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js +8 -0
  24. package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js.map +1 -1
  25. package/dist/nodes/chains/ChainLLM/methods/config.js +5 -0
  26. package/dist/nodes/chains/ChainLLM/methods/config.js.map +1 -1
  27. package/dist/nodes/chains/ChainLLM/methods/processItem.js +66 -0
  28. package/dist/nodes/chains/ChainLLM/methods/processItem.js.map +1 -0
  29. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +71 -95
  30. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
  31. package/dist/nodes/chains/ChainRetrievalQA/constants.js +49 -0
  32. package/dist/nodes/chains/ChainRetrievalQA/constants.js.map +1 -0
  33. package/dist/nodes/chains/ChainRetrievalQA/processItem.js +91 -0
  34. package/dist/nodes/chains/ChainRetrievalQA/processItem.js.map +1 -0
  35. package/dist/nodes/chains/ChainSummarization/ChainSummarization.node.js +3 -2
  36. package/dist/nodes/chains/ChainSummarization/ChainSummarization.node.js.map +1 -1
  37. package/dist/nodes/chains/ChainSummarization/V2/ChainSummarizationV2.node.js +55 -78
  38. package/dist/nodes/chains/ChainSummarization/V2/ChainSummarizationV2.node.js.map +1 -1
  39. package/dist/nodes/chains/ChainSummarization/V2/processItem.js +95 -0
  40. package/dist/nodes/chains/ChainSummarization/V2/processItem.js.map +1 -0
  41. package/dist/nodes/chains/InformationExtractor/InformationExtractor.node.js +56 -33
  42. package/dist/nodes/chains/InformationExtractor/InformationExtractor.node.js.map +1 -1
  43. package/dist/nodes/chains/InformationExtractor/constants.js +31 -0
  44. package/dist/nodes/chains/InformationExtractor/constants.js.map +1 -0
  45. package/dist/nodes/chains/InformationExtractor/processItem.js +56 -0
  46. package/dist/nodes/chains/InformationExtractor/processItem.js.map +1 -0
  47. package/dist/nodes/chains/SentimentAnalysis/SentimentAnalysis.node.js +198 -71
  48. package/dist/nodes/chains/SentimentAnalysis/SentimentAnalysis.node.js.map +1 -1
  49. package/dist/nodes/chains/TextClassifier/TextClassifier.node.js +83 -54
  50. package/dist/nodes/chains/TextClassifier/TextClassifier.node.js.map +1 -1
  51. package/dist/nodes/chains/TextClassifier/constants.js +29 -0
  52. package/dist/nodes/chains/TextClassifier/constants.js.map +1 -0
  53. package/dist/nodes/chains/TextClassifier/processItem.js +65 -0
  54. package/dist/nodes/chains/TextClassifier/processItem.js.map +1 -0
  55. package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js +7 -3
  56. package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
  57. package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +4 -1
  58. package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
  59. package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +6 -1
  60. package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
  61. package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js +4 -1
  62. package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js.map +1 -1
  63. package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js +4 -0
  64. package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js.map +1 -1
  65. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +4 -0
  66. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
  67. package/dist/nodes/llms/LmChatAzureOpenAi/credentials/N8nOAuth2TokenCredential.js +16 -2
  68. package/dist/nodes/llms/LmChatAzureOpenAi/credentials/N8nOAuth2TokenCredential.js.map +1 -1
  69. package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js +3 -1
  70. package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js.map +1 -1
  71. package/dist/nodes/llms/LmChatGroq/LmChatGroq.node.js +2 -0
  72. package/dist/nodes/llms/LmChatGroq/LmChatGroq.node.js.map +1 -1
  73. package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js +3 -1
  74. package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js.map +1 -1
  75. package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js +3 -1
  76. package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js.map +1 -1
  77. package/dist/nodes/mcp/McpTrigger/McpTrigger.node.js +2 -2
  78. package/dist/nodes/mcp/McpTrigger/McpTrigger.node.js.map +1 -1
  79. package/dist/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.js +1 -0
  80. package/dist/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.js.map +1 -1
  81. package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js +2 -1
  82. package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js.map +1 -1
  83. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +1 -1
  84. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
  85. package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js +109 -17
  86. package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js.map +1 -1
  87. package/dist/nodes/vector_store/shared/MemoryManager/MemoryVectorStoreManager.js +3 -0
  88. package/dist/nodes/vector_store/shared/MemoryManager/MemoryVectorStoreManager.js.map +1 -1
  89. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +2 -1
  90. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -1
  91. package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js.map +1 -1
  92. package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js +6 -1
  93. package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js.map +1 -1
  94. package/dist/types/credentials.json +1 -1
  95. package/dist/types/nodes.json +20 -19
  96. package/dist/utils/httpProxyAgent.js +33 -0
  97. package/dist/utils/httpProxyAgent.js.map +1 -0
  98. package/dist/utils/sharedFields.js +29 -0
  99. package/dist/utils/sharedFields.js.map +1 -1
  100. package/package.json +7 -6
  101. package/dist/nodes/agents/Agent/agents/ToolsAgent/description.js.map +0 -1
  102. package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js.map +0 -1
@@ -21,23 +21,37 @@ __export(VectorStoreInMemory_node_exports, {
21
21
  VectorStoreInMemory: () => VectorStoreInMemory
22
22
  });
23
23
  module.exports = __toCommonJS(VectorStoreInMemory_node_exports);
24
+ var import_n8n_workflow = require("n8n-workflow");
24
25
  var import_createVectorStoreNode = require("../shared/createVectorStoreNode/createVectorStoreNode");
25
26
  var import_MemoryVectorStoreManager = require("../shared/MemoryManager/MemoryVectorStoreManager");
27
+ const warningBanner = {
28
+ displayName: '<strong>For experimental use only</strong>: Data is stored in memory and will be lost if n8n restarts. Data may also be cleared if available memory gets low, and is accessible to all users of this instance. <a href="https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/">More info</a>',
29
+ name: "notice",
30
+ type: "notice",
31
+ default: ""
32
+ };
26
33
  const insertFields = [
27
- {
28
- displayName: '<strong>For experimental use only</strong>: Data is stored in memory and will be lost if n8n restarts. Data may also be cleared if available memory gets low. <a href="https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/">More info</a>',
29
- name: "notice",
30
- type: "notice",
31
- default: ""
32
- },
33
34
  {
34
35
  displayName: "Clear Store",
35
36
  name: "clearStore",
36
37
  type: "boolean",
37
38
  default: false,
38
39
  description: "Whether to clear the store before inserting new data"
39
- }
40
+ },
41
+ warningBanner
40
42
  ];
43
+ const DEFAULT_MEMORY_KEY = "vector_store_key";
44
+ function getMemoryKey(context, itemIndex) {
45
+ const node = context.getNode();
46
+ if (node.typeVersion <= 1.1) {
47
+ const memoryKeyParam = context.getNodeParameter("memoryKey", itemIndex);
48
+ const workflowId = context.getWorkflow().id;
49
+ return `${workflowId}__${memoryKeyParam}`;
50
+ } else {
51
+ const memoryKeyParam = context.getNodeParameter("memoryKey", itemIndex);
52
+ return memoryKeyParam.value;
53
+ }
54
+ }
41
55
  class VectorStoreInMemory extends (0, import_createVectorStoreNode.createVectorStoreNode)({
42
56
  meta: {
43
57
  displayName: "Simple Vector Store",
@@ -52,25 +66,103 @@ class VectorStoreInMemory extends (0, import_createVectorStoreNode.createVectorS
52
66
  displayName: "Memory Key",
53
67
  name: "memoryKey",
54
68
  type: "string",
55
- default: "vector_store_key",
56
- description: "The key to use to store the vector memory in the workflow data. The key will be prefixed with the workflow ID to avoid collisions."
69
+ default: DEFAULT_MEMORY_KEY,
70
+ description: "The key to use to store the vector memory in the workflow data. The key will be prefixed with the workflow ID to avoid collisions.",
71
+ displayOptions: {
72
+ show: {
73
+ "@version": [{ _cnd: { lte: 1.1 } }]
74
+ }
75
+ }
76
+ },
77
+ {
78
+ displayName: "Memory Key",
79
+ name: "memoryKey",
80
+ type: "resourceLocator",
81
+ required: true,
82
+ default: { mode: "list", value: DEFAULT_MEMORY_KEY },
83
+ description: "The key to use to store the vector memory in the workflow data. These keys are shared between workflows.",
84
+ displayOptions: {
85
+ show: {
86
+ "@version": [{ _cnd: { gte: 1.2 } }]
87
+ }
88
+ },
89
+ modes: [
90
+ {
91
+ displayName: "From List",
92
+ name: "list",
93
+ type: "list",
94
+ typeOptions: {
95
+ searchListMethod: "vectorStoresSearch",
96
+ searchable: true,
97
+ allowNewResource: {
98
+ label: "resourceLocator.mode.list.addNewResource.vectorStoreInMemory",
99
+ defaultName: DEFAULT_MEMORY_KEY,
100
+ method: "createVectorStore"
101
+ }
102
+ }
103
+ },
104
+ {
105
+ displayName: "Manual",
106
+ name: "id",
107
+ type: "string",
108
+ placeholder: DEFAULT_MEMORY_KEY
109
+ }
110
+ ]
57
111
  }
58
112
  ],
113
+ methods: {
114
+ listSearch: {
115
+ async vectorStoresSearch(filter) {
116
+ const vectorStoreSingleton = import_MemoryVectorStoreManager.MemoryVectorStoreManager.getInstance(
117
+ {},
118
+ // Real Embeddings are provided when executing the node
119
+ this.logger
120
+ );
121
+ const searchOptions = vectorStoreSingleton.getMemoryKeysList().map((key) => {
122
+ return {
123
+ name: key,
124
+ value: key
125
+ };
126
+ });
127
+ let results = searchOptions;
128
+ if (filter) {
129
+ results = results.filter((option) => option.name.includes(filter));
130
+ }
131
+ return {
132
+ results
133
+ };
134
+ }
135
+ },
136
+ actionHandler: {
137
+ async createVectorStore(payload) {
138
+ if (!payload || typeof payload === "string") {
139
+ throw new import_n8n_workflow.ApplicationError("Invalid payload type");
140
+ }
141
+ const { name } = payload;
142
+ const vectorStoreSingleton = import_MemoryVectorStoreManager.MemoryVectorStoreManager.getInstance(
143
+ {},
144
+ // Real Embeddings are provided when executing the node
145
+ this.logger
146
+ );
147
+ const memoryKey = !!name ? name : DEFAULT_MEMORY_KEY;
148
+ await vectorStoreSingleton.getVectorStore(memoryKey);
149
+ return memoryKey;
150
+ }
151
+ }
152
+ },
59
153
  insertFields,
60
- loadFields: [],
61
- retrieveFields: [],
154
+ loadFields: [warningBanner],
155
+ retrieveFields: [warningBanner],
62
156
  async getVectorStoreClient(context, _filter, embeddings, itemIndex) {
63
- const workflowId = context.getWorkflow().id;
64
- const memoryKey = context.getNodeParameter("memoryKey", itemIndex);
157
+ const memoryKey = getMemoryKey(context, itemIndex);
65
158
  const vectorStoreSingleton = import_MemoryVectorStoreManager.MemoryVectorStoreManager.getInstance(embeddings, context.logger);
66
- return await vectorStoreSingleton.getVectorStore(`${workflowId}__${memoryKey}`);
159
+ return await vectorStoreSingleton.getVectorStore(memoryKey);
67
160
  },
68
161
  async populateVectorStore(context, embeddings, documents, itemIndex) {
69
- const memoryKey = context.getNodeParameter("memoryKey", itemIndex);
162
+ const memoryKey = getMemoryKey(context, itemIndex);
70
163
  const clearStore = context.getNodeParameter("clearStore", itemIndex);
71
- const workflowId = context.getWorkflow().id;
72
164
  const vectorStoreInstance = import_MemoryVectorStoreManager.MemoryVectorStoreManager.getInstance(embeddings, context.logger);
73
- await vectorStoreInstance.addDocuments(`${workflowId}__${memoryKey}`, documents, clearStore);
165
+ await vectorStoreInstance.addDocuments(memoryKey, documents, clearStore);
74
166
  }
75
167
  }) {
76
168
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.ts"],"sourcesContent":["import type { MemoryVectorStore } from 'langchain/vectorstores/memory';\nimport type { INodeProperties } from 'n8n-workflow';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\nimport { MemoryVectorStoreManager } from '../shared/MemoryManager/MemoryVectorStoreManager';\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName:\n\t\t\t'<strong>For experimental use only</strong>: Data is stored in memory and will be lost if n8n restarts. Data may also be cleared if available memory gets low. <a href=\"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/\">More info</a>',\n\t\tname: 'notice',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t},\n\t{\n\t\tdisplayName: 'Clear Store',\n\t\tname: 'clearStore',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription: 'Whether to clear the store before inserting new data',\n\t},\n];\n\nexport class VectorStoreInMemory extends createVectorStoreNode<MemoryVectorStore>({\n\tmeta: {\n\t\tdisplayName: 'Simple Vector Store',\n\t\tname: 'vectorStoreInMemory',\n\t\tdescription:\n\t\t\t\"Work with your data in a Simple Vector Store. Don't use this for production usage.\",\n\t\ticon: 'fa:database',\n\t\ticonColor: 'black',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/',\n\t},\n\tsharedFields: [\n\t\t{\n\t\t\tdisplayName: 'Memory Key',\n\t\t\tname: 'memoryKey',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'vector_store_key',\n\t\t\tdescription:\n\t\t\t\t'The key to use to store the vector memory in the workflow data. The key will be prefixed with the workflow ID to avoid collisions.',\n\t\t},\n\t],\n\tinsertFields,\n\tloadFields: [],\n\tretrieveFields: [],\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {\n\t\tconst workflowId = context.getWorkflow().id;\n\t\tconst memoryKey = context.getNodeParameter('memoryKey', itemIndex) as string;\n\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(embeddings, context.logger);\n\n\t\treturn await vectorStoreSingleton.getVectorStore(`${workflowId}__${memoryKey}`);\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\tconst memoryKey = context.getNodeParameter('memoryKey', itemIndex) as string;\n\t\tconst clearStore = context.getNodeParameter('clearStore', itemIndex) as boolean;\n\t\tconst workflowId = context.getWorkflow().id;\n\t\tconst vectorStoreInstance = MemoryVectorStoreManager.getInstance(embeddings, context.logger);\n\n\t\tawait vectorStoreInstance.addDocuments(`${workflowId}__${memoryKey}`, documents, clearStore);\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mCAAsC;AACtC,sCAAyC;AAEzC,MAAM,eAAkC;AAAA,EACvC;AAAA,IACC,aACC;AAAA,IACD,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACV;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AACD;AAEO,MAAM,gCAA4B,oDAAyC;AAAA,EACjF,MAAM;AAAA,IACL,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aACC;AAAA,IACD,MAAM;AAAA,IACN,WAAW;AAAA,IACX,SACC;AAAA,EACF;AAAA,EACA,cAAc;AAAA,IACb;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACC;AAAA,IACF;AAAA,EACD;AAAA,EACA;AAAA,EACA,YAAY,CAAC;AAAA,EACb,gBAAgB,CAAC;AAAA,EACjB,MAAM,qBAAqB,SAAS,SAAS,YAAY,WAAW;AACnE,UAAM,aAAa,QAAQ,YAAY,EAAE;AACzC,UAAM,YAAY,QAAQ,iBAAiB,aAAa,SAAS;AACjE,UAAM,uBAAuB,yDAAyB,YAAY,YAAY,QAAQ,MAAM;AAE5F,WAAO,MAAM,qBAAqB,eAAe,GAAG,UAAU,KAAK,SAAS,EAAE;AAAA,EAC/E;AAAA,EACA,MAAM,oBAAoB,SAAS,YAAY,WAAW,WAAW;AACpE,UAAM,YAAY,QAAQ,iBAAiB,aAAa,SAAS;AACjE,UAAM,aAAa,QAAQ,iBAAiB,cAAc,SAAS;AACnE,UAAM,aAAa,QAAQ,YAAY,EAAE;AACzC,UAAM,sBAAsB,yDAAyB,YAAY,YAAY,QAAQ,MAAM;AAE3F,UAAM,oBAAoB,aAAa,GAAG,UAAU,KAAK,SAAS,IAAI,WAAW,UAAU;AAAA,EAC5F;AACD,CAAC,EAAE;AAAC;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { MemoryVectorStore } from 'langchain/vectorstores/memory';\nimport {\n\ttype INodeProperties,\n\ttype ILoadOptionsFunctions,\n\ttype INodeListSearchResult,\n\ttype IDataObject,\n\ttype NodeParameterValueType,\n\ttype IExecuteFunctions,\n\ttype ISupplyDataFunctions,\n\tApplicationError,\n} from 'n8n-workflow';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\nimport { MemoryVectorStoreManager } from '../shared/MemoryManager/MemoryVectorStoreManager';\n\nconst warningBanner: INodeProperties = {\n\tdisplayName:\n\t\t'<strong>For experimental use only</strong>: Data is stored in memory and will be lost if n8n restarts. Data may also be cleared if available memory gets low, and is accessible to all users of this instance. <a href=\"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/\">More info</a>',\n\tname: 'notice',\n\ttype: 'notice',\n\tdefault: '',\n};\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Clear Store',\n\t\tname: 'clearStore',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription: 'Whether to clear the store before inserting new data',\n\t},\n\twarningBanner,\n];\n\nconst DEFAULT_MEMORY_KEY = 'vector_store_key';\n\nfunction getMemoryKey(context: IExecuteFunctions | ISupplyDataFunctions, itemIndex: number) {\n\tconst node = context.getNode();\n\tif (node.typeVersion <= 1.1) {\n\t\tconst memoryKeyParam = context.getNodeParameter('memoryKey', itemIndex) as string;\n\t\tconst workflowId = context.getWorkflow().id;\n\n\t\treturn `${workflowId}__${memoryKeyParam}`;\n\t} else {\n\t\tconst memoryKeyParam = context.getNodeParameter('memoryKey', itemIndex) as {\n\t\t\tmode: string;\n\t\t\tvalue: string;\n\t\t};\n\n\t\treturn memoryKeyParam.value;\n\t}\n}\n\nexport class VectorStoreInMemory extends createVectorStoreNode<MemoryVectorStore>({\n\tmeta: {\n\t\tdisplayName: 'Simple Vector Store',\n\t\tname: 'vectorStoreInMemory',\n\t\tdescription:\n\t\t\t\"Work with your data in a Simple Vector Store. Don't use this for production usage.\",\n\t\ticon: 'fa:database',\n\t\ticonColor: 'black',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/',\n\t},\n\tsharedFields: [\n\t\t{\n\t\t\tdisplayName: 'Memory Key',\n\t\t\tname: 'memoryKey',\n\t\t\ttype: 'string',\n\t\t\tdefault: DEFAULT_MEMORY_KEY,\n\t\t\tdescription:\n\t\t\t\t'The key to use to store the vector memory in the workflow data. The key will be prefixed with the workflow ID to avoid collisions.',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\t'@version': [{ _cnd: { lte: 1.1 } }],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Memory Key',\n\t\t\tname: 'memoryKey',\n\t\t\ttype: 'resourceLocator',\n\t\t\trequired: true,\n\t\t\tdefault: { mode: 'list', value: DEFAULT_MEMORY_KEY },\n\t\t\tdescription:\n\t\t\t\t'The key to use to store the vector memory in the workflow data. These keys are shared between workflows.',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t},\n\t\t\t},\n\t\t\tmodes: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\tname: 'list',\n\t\t\t\t\ttype: 'list',\n\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\tsearchListMethod: 'vectorStoresSearch',\n\t\t\t\t\t\tsearchable: true,\n\t\t\t\t\t\tallowNewResource: {\n\t\t\t\t\t\t\tlabel: 'resourceLocator.mode.list.addNewResource.vectorStoreInMemory',\n\t\t\t\t\t\t\tdefaultName: DEFAULT_MEMORY_KEY,\n\t\t\t\t\t\t\tmethod: 'createVectorStore',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Manual',\n\t\t\t\t\tname: 'id',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tplaceholder: DEFAULT_MEMORY_KEY,\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n\tmethods: {\n\t\tlistSearch: {\n\t\t\tasync vectorStoresSearch(\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tfilter?: string,\n\t\t\t): Promise<INodeListSearchResult> {\n\t\t\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(\n\t\t\t\t\t{} as Embeddings, // Real Embeddings are provided when executing the node\n\t\t\t\t\tthis.logger,\n\t\t\t\t);\n\n\t\t\t\tconst searchOptions: INodeListSearchResult['results'] = vectorStoreSingleton\n\t\t\t\t\t.getMemoryKeysList()\n\t\t\t\t\t.map((key) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tname: key,\n\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\tlet results = searchOptions;\n\t\t\t\tif (filter) {\n\t\t\t\t\tresults = results.filter((option) => option.name.includes(filter));\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tresults,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\tactionHandler: {\n\t\t\tasync createVectorStore(\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tpayload: string | IDataObject | undefined,\n\t\t\t): Promise<NodeParameterValueType> {\n\t\t\t\tif (!payload || typeof payload === 'string') {\n\t\t\t\t\tthrow new ApplicationError('Invalid payload type');\n\t\t\t\t}\n\n\t\t\t\tconst { name } = payload;\n\n\t\t\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(\n\t\t\t\t\t{} as Embeddings, // Real Embeddings are provided when executing the node\n\t\t\t\t\tthis.logger,\n\t\t\t\t);\n\n\t\t\t\tconst memoryKey = !!name ? (name as string) : DEFAULT_MEMORY_KEY;\n\t\t\t\tawait vectorStoreSingleton.getVectorStore(memoryKey);\n\n\t\t\t\treturn memoryKey;\n\t\t\t},\n\t\t},\n\t},\n\tinsertFields,\n\tloadFields: [warningBanner],\n\tretrieveFields: [warningBanner],\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {\n\t\tconst memoryKey = getMemoryKey(context, itemIndex);\n\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(embeddings, context.logger);\n\n\t\treturn await vectorStoreSingleton.getVectorStore(memoryKey);\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\tconst memoryKey = getMemoryKey(context, itemIndex);\n\t\tconst clearStore = context.getNodeParameter('clearStore', itemIndex) as boolean;\n\t\tconst vectorStoreInstance = MemoryVectorStoreManager.getInstance(embeddings, context.logger);\n\n\t\tawait vectorStoreInstance.addDocuments(memoryKey, documents, clearStore);\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BASO;AAEP,mCAAsC;AACtC,sCAAyC;AAEzC,MAAM,gBAAiC;AAAA,EACtC,aACC;AAAA,EACD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACV;AAEA,MAAM,eAAkC;AAAA,EACvC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA;AACD;AAEA,MAAM,qBAAqB;AAE3B,SAAS,aAAa,SAAmD,WAAmB;AAC3F,QAAM,OAAO,QAAQ,QAAQ;AAC7B,MAAI,KAAK,eAAe,KAAK;AAC5B,UAAM,iBAAiB,QAAQ,iBAAiB,aAAa,SAAS;AACtE,UAAM,aAAa,QAAQ,YAAY,EAAE;AAEzC,WAAO,GAAG,UAAU,KAAK,cAAc;AAAA,EACxC,OAAO;AACN,UAAM,iBAAiB,QAAQ,iBAAiB,aAAa,SAAS;AAKtE,WAAO,eAAe;AAAA,EACvB;AACD;AAEO,MAAM,gCAA4B,oDAAyC;AAAA,EACjF,MAAM;AAAA,IACL,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aACC;AAAA,IACD,MAAM;AAAA,IACN,WAAW;AAAA,IACX,SACC;AAAA,EACF;AAAA,EACA,cAAc;AAAA,IACb;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACC;AAAA,MACD,gBAAgB;AAAA,QACf,MAAM;AAAA,UACL,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;AAAA,QACpC;AAAA,MACD;AAAA,I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M,EAAE,KAAK,IAAI;AAEjB,cAAM,uBAAuB,yDAAyB;AAAA,UACrD,CAAC;AAAA;AAAA,UACD,KAAK;AAAA,QACN;AAEA,cAAM,YAAY,CAAC,CAAC,OAAQ,OAAkB;AAC9C,cAAM,qBAAqB,eAAe,SAAS;AAEnD,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,EACA,YAAY,CAAC,aAAa;AAAA,EAC1B,gBAAgB,CAAC,aAAa;AAAA,EAC9B,MAAM,qBAAqB,SAAS,SAAS,YAAY,WAAW;AACnE,UAAM,YAAY,aAAa,SAAS,SAAS;AACjD,UAAM,uBAAuB,yDAAyB,YAAY,YAAY,QAAQ,MAAM;AAE5F,WAAO,MAAM,qBAAqB,eAAe,SAAS;AAAA,EAC3D;AAAA,EACA,MAAM,oBAAoB,SAAS,YAAY,WAAW,WAAW;AACpE,UAAM,YAAY,aAAa,SAAS,SAAS;AACjD,UAAM,aAAa,QAAQ,iBAAiB,cAAc,SAAS;AACnE,UAAM,sBAAsB,yDAAyB,YAAY,YAAY,QAAQ,MAAM;AAE3F,UAAM,oBAAoB,aAAa,WAAW,WAAW,UAAU;AAAA,EACxE;AACD,CAAC,EAAE;AAAC;","names":[]}
@@ -93,6 +93,9 @@ const _MemoryVectorStoreManager = class _MemoryVectorStoreManager {
93
93
  );
94
94
  }
95
95
  }
96
+ getMemoryKeysList() {
97
+ return Array.from(this.vectorStoreBuffer.keys());
98
+ }
96
99
  /**
97
100
  * Get or create a vector store by key
98
101
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../nodes/vector_store/shared/MemoryManager/MemoryVectorStoreManager.ts"],"sourcesContent":["import type { Document } from '@langchain/core/documents';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport { MemoryVectorStore } from 'langchain/vectorstores/memory';\nimport type { Logger } from 'n8n-workflow';\n\nimport { getConfig, mbToBytes, hoursToMs } from './config';\nimport { MemoryCalculator } from './MemoryCalculator';\nimport { StoreCleanupService } from './StoreCleanupService';\nimport type { VectorStoreMetadata, VectorStoreStats } from './types';\n\n/**\n * Manages in-memory vector stores with memory limits and auto-cleanup\n */\nexport class MemoryVectorStoreManager {\n\tprivate static instance: MemoryVectorStoreManager | null = null;\n\n\t// Storage\n\tprotected vectorStoreBuffer: Map<string, MemoryVectorStore>;\n\n\tprotected storeMetadata: Map<string, VectorStoreMetadata>;\n\n\tprotected memoryUsageBytes: number = 0;\n\n\t// Dependencies\n\tprotected memoryCalculator: MemoryCalculator;\n\n\tprotected cleanupService: StoreCleanupService;\n\n\tprotected static logger: Logger;\n\n\t// Config values\n\tprotected maxMemorySizeBytes: number;\n\n\tprotected inactiveTtlMs: number;\n\n\t// Inactive TTL cleanup timer\n\tprotected ttlCleanupIntervalId: NodeJS.Timeout | null = null;\n\n\tprotected constructor(\n\t\tprotected embeddings: Embeddings,\n\t\tprotected logger: Logger,\n\t) {\n\t\t// Initialize storage\n\t\tthis.vectorStoreBuffer = new Map();\n\t\tthis.storeMetadata = new Map();\n\t\tthis.logger = logger;\n\n\t\tconst config = getConfig();\n\t\tthis.maxMemorySizeBytes = mbToBytes(config.maxMemoryMB);\n\t\tthis.inactiveTtlMs = hoursToMs(config.ttlHours);\n\n\t\t// Initialize services\n\t\tthis.memoryCalculator = new MemoryCalculator();\n\t\tthis.cleanupService = new StoreCleanupService(\n\t\t\tthis.maxMemorySizeBytes,\n\t\t\tthis.inactiveTtlMs,\n\t\t\tthis.vectorStoreBuffer,\n\t\t\tthis.storeMetadata,\n\t\t\tthis.handleCleanup.bind(this),\n\t\t);\n\n\t\tthis.setupTtlCleanup();\n\t}\n\n\t/**\n\t * Get singleton instance\n\t */\n\tstatic getInstance(embeddings: Embeddings, logger: Logger): MemoryVectorStoreManager {\n\t\tif (!MemoryVectorStoreManager.instance) {\n\t\t\tMemoryVectorStoreManager.instance = new MemoryVectorStoreManager(embeddings, logger);\n\t\t} else {\n\t\t\t// We need to update the embeddings in the existing instance.\n\t\t\t// This is important as embeddings instance is wrapped in a logWrapper,\n\t\t\t// which relies on supplyDataFunctions context which changes on each workflow run\n\t\t\tMemoryVectorStoreManager.instance.embeddings = embeddings;\n\t\t\tMemoryVectorStoreManager.instance.vectorStoreBuffer.forEach((vectorStoreInstance) => {\n\t\t\t\tvectorStoreInstance.embeddings = embeddings;\n\t\t\t});\n\t\t}\n\n\t\treturn MemoryVectorStoreManager.instance;\n\t}\n\n\t/**\n\t * Set up timer for TTL-based cleanup\n\t */\n\tprivate setupTtlCleanup(): void {\n\t\t// Skip setup if TTL is disabled\n\t\tif (this.inactiveTtlMs <= 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Cleanup check interval (run every hour)\n\t\tconst CLEANUP_INTERVAL_MS = 60 * 60 * 1000;\n\n\t\t// Clear any existing interval\n\t\tif (this.ttlCleanupIntervalId) {\n\t\t\tclearInterval(this.ttlCleanupIntervalId);\n\t\t}\n\n\t\t// Setup new interval for TTL cleanup\n\t\tthis.ttlCleanupIntervalId = setInterval(() => {\n\t\t\tthis.cleanupService.cleanupInactiveStores();\n\t\t}, CLEANUP_INTERVAL_MS);\n\t}\n\n\t/**\n\t * Handle cleanup events from the cleanup service\n\t */\n\tprivate handleCleanup(removedKeys: string[], freedBytes: number, reason: 'ttl' | 'memory'): void {\n\t\t// Update total memory usage\n\t\tthis.memoryUsageBytes -= freedBytes;\n\n\t\t// Log cleanup event\n\t\tif (reason === 'ttl') {\n\t\t\tconst ttlHours = Math.round(this.inactiveTtlMs / (60 * 60 * 1000));\n\t\t\tthis.logger.info(\n\t\t\t\t`TTL cleanup: removed ${removedKeys.length} inactive vector stores (${ttlHours}h TTL) to free ${Math.round(freedBytes / (1024 * 1024))}MB of memory`,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.logger.info(\n\t\t\t\t`Memory cleanup: removed ${removedKeys.length} oldest vector stores to free ${Math.round(freedBytes / (1024 * 1024))}MB of memory`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get or create a vector store by key\n\t */\n\tasync getVectorStore(memoryKey: string): Promise<MemoryVectorStore> {\n\t\tlet vectorStoreInstance = this.vectorStoreBuffer.get(memoryKey);\n\n\t\tif (!vectorStoreInstance) {\n\t\t\tvectorStoreInstance = await MemoryVectorStore.fromExistingIndex(this.embeddings);\n\t\t\tthis.vectorStoreBuffer.set(memoryKey, vectorStoreInstance);\n\n\t\t\tthis.storeMetadata.set(memoryKey, {\n\t\t\t\tsize: 0,\n\t\t\t\tcreatedAt: new Date(),\n\t\t\t\tlastAccessed: new Date(),\n\t\t\t});\n\t\t} else {\n\t\t\tconst metadata = this.storeMetadata.get(memoryKey);\n\t\t\tif (metadata) {\n\t\t\t\tmetadata.lastAccessed = new Date();\n\t\t\t}\n\t\t}\n\n\t\treturn vectorStoreInstance;\n\t}\n\n\t/**\n\t * Reset a store's metadata when it's cleared\n\t */\n\tprotected clearStoreMetadata(memoryKey: string): void {\n\t\tconst metadata = this.storeMetadata.get(memoryKey);\n\t\tif (metadata) {\n\t\t\tthis.memoryUsageBytes -= metadata.size;\n\t\t\tmetadata.size = 0;\n\t\t\tmetadata.lastAccessed = new Date();\n\t\t}\n\t}\n\n\t/**\n\t * Get memory usage in bytes\n\t */\n\tgetMemoryUsage(): number {\n\t\treturn this.memoryUsageBytes;\n\t}\n\n\t/**\n\t * Get memory usage as a formatted string (MB)\n\t */\n\tgetMemoryUsageFormatted(): string {\n\t\treturn `${Math.round(this.memoryUsageBytes / (1024 * 1024))}MB`;\n\t}\n\n\t/**\n\t * Recalculate memory usage from actual vector store contents\n\t * This ensures tracking accuracy for large stores\n\t */\n\trecalculateMemoryUsage(): void {\n\t\tthis.memoryUsageBytes = 0;\n\n\t\t// Recalculate for each store\n\t\tfor (const [key, vectorStore] of this.vectorStoreBuffer.entries()) {\n\t\t\tconst storeSize = this.memoryCalculator.calculateVectorStoreSize(vectorStore);\n\n\t\t\t// Update metadata\n\t\t\tconst metadata = this.storeMetadata.get(key);\n\t\t\tif (metadata) {\n\t\t\t\tmetadata.size = storeSize;\n\t\t\t\tthis.memoryUsageBytes += storeSize;\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.debug(`Recalculated vector store memory: ${this.getMemoryUsageFormatted()}`);\n\t}\n\n\t/**\n\t * Add documents to a vector store\n\t */\n\tasync addDocuments(\n\t\tmemoryKey: string,\n\t\tdocuments: Document[],\n\t\tclearStore?: boolean,\n\t): Promise<void> {\n\t\tif (clearStore) {\n\t\t\tthis.clearStoreMetadata(memoryKey);\n\t\t\tthis.vectorStoreBuffer.delete(memoryKey);\n\t\t}\n\n\t\t// Fast batch estimation instead of per-document calculation\n\t\tconst estimatedAddedSize = this.memoryCalculator.estimateBatchSize(documents);\n\n\t\t// Clean up old stores if necessary\n\t\tthis.cleanupService.cleanupOldestStores(estimatedAddedSize);\n\n\t\tconst vectorStoreInstance = await this.getVectorStore(memoryKey);\n\n\t\t// Get vector count before adding documents\n\t\tconst vectorCountBefore = vectorStoreInstance.memoryVectors?.length || 0;\n\n\t\tawait vectorStoreInstance.addDocuments(documents);\n\n\t\t// Update store metadata and memory tracking\n\t\tconst metadata = this.storeMetadata.get(memoryKey);\n\t\tif (metadata) {\n\t\t\tmetadata.size += estimatedAddedSize;\n\t\t\tmetadata.lastAccessed = new Date();\n\t\t\tthis.memoryUsageBytes += estimatedAddedSize;\n\t\t}\n\n\t\t// Get updated vector count\n\t\tconst vectorCount = vectorStoreInstance.memoryVectors?.length || 0;\n\n\t\t// Periodically recalculate actual memory usage to avoid drift\n\t\tif (\n\t\t\t(vectorCount > 0 && vectorCount % 100 === 0) ||\n\t\t\tdocuments.length > 20 ||\n\t\t\t(vectorCountBefore === 0 && vectorCount > 0)\n\t\t) {\n\t\t\tthis.recalculateMemoryUsage();\n\t\t}\n\n\t\t// Logging memory usage\n\t\tconst maxMemoryMB =\n\t\t\tthis.maxMemorySizeBytes > 0\n\t\t\t\t? (this.maxMemorySizeBytes / (1024 * 1024)).toFixed(0)\n\t\t\t\t: 'unlimited';\n\n\t\tthis.logger.debug(\n\t\t\t`Vector store memory: ${this.getMemoryUsageFormatted()}/${maxMemoryMB}MB (${vectorCount} vectors in ${this.vectorStoreBuffer.size} stores)`,\n\t\t);\n\t}\n\n\t/**\n\t * Get statistics about the vector store memory usage\n\t */\n\tgetStats(): VectorStoreStats {\n\t\tconst now = Date.now();\n\t\tlet inactiveStoreCount = 0;\n\n\t\t// Always recalculate when getting stats to ensure accuracy\n\t\tthis.recalculateMemoryUsage();\n\n\t\tconst stats: VectorStoreStats = {\n\t\t\ttotalSizeBytes: this.memoryUsageBytes,\n\t\t\ttotalSizeMB: Math.round((this.memoryUsageBytes / (1024 * 1024)) * 100) / 100,\n\t\t\tpercentOfLimit:\n\t\t\t\tthis.maxMemorySizeBytes > 0\n\t\t\t\t\t? Math.round((this.memoryUsageBytes / this.maxMemorySizeBytes) * 100)\n\t\t\t\t\t: 0,\n\t\t\tmaxMemoryMB: this.maxMemorySizeBytes > 0 ? this.maxMemorySizeBytes / (1024 * 1024) : -1, // -1 indicates unlimited\n\t\t\tstoreCount: this.vectorStoreBuffer.size,\n\t\t\tinactiveStoreCount: 0,\n\t\t\tttlHours: this.inactiveTtlMs > 0 ? this.inactiveTtlMs / (60 * 60 * 1000) : -1, // -1 indicates disabled\n\t\t\tstores: {},\n\t\t};\n\n\t\t// Add stats for each store\n\t\tfor (const [key, metadata] of this.storeMetadata.entries()) {\n\t\t\tconst store = this.vectorStoreBuffer.get(key);\n\n\t\t\tif (store) {\n\t\t\t\tconst lastAccessedTime = metadata.lastAccessed.getTime();\n\t\t\t\tconst inactiveTimeMs = now - lastAccessedTime;\n\t\t\t\tconst isInactive = this.cleanupService.isStoreInactive(metadata);\n\n\t\t\t\tif (isInactive) {\n\t\t\t\t\tinactiveStoreCount++;\n\t\t\t\t}\n\n\t\t\t\tstats.stores[key] = {\n\t\t\t\t\tsizeBytes: metadata.size,\n\t\t\t\t\tsizeMB: Math.round((metadata.size / (1024 * 1024)) * 100) / 100,\n\t\t\t\t\tpercentOfTotal: Math.round((metadata.size / this.memoryUsageBytes) * 100) || 0,\n\t\t\t\t\tvectors: store.memoryVectors?.length || 0,\n\t\t\t\t\tcreatedAt: metadata.createdAt.toISOString(),\n\t\t\t\t\tlastAccessed: metadata.lastAccessed.toISOString(),\n\t\t\t\t\tinactive: isInactive,\n\t\t\t\t\tinactiveForHours: Math.round(inactiveTimeMs / (60 * 60 * 1000)),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tstats.inactiveStoreCount = inactiveStoreCount;\n\n\t\treturn stats;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAkC;AAGlC,oBAAgD;AAChD,8BAAiC;AACjC,iCAAoC;AAM7B,MAAM,4BAAN,MAAM,0BAAyB;AAAA,EAyB3B,YACC,YACA,QACT;AAFS;AACA;AAnBX,SAAU,mBAA2B;AAerC;AAAA,SAAU,uBAA8C;AAOvD,SAAK,oBAAoB,oBAAI,IAAI;AACjC,SAAK,gBAAgB,oBAAI,IAAI;AAC7B,SAAK,SAAS;AAEd,UAAM,aAAS,yBAAU;AACzB,SAAK,yBAAqB,yBAAU,OAAO,WAAW;AACtD,SAAK,oBAAgB,yBAAU,OAAO,QAAQ;AAG9C,SAAK,mBAAmB,IAAI,yCAAiB;AAC7C,SAAK,iBAAiB,IAAI;AAAA,MACzB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,cAAc,KAAK,IAAI;AAAA,IAC7B;AAEA,SAAK,gBAAgB;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,YAAY,YAAwB,QAA0C;AACpF,QAAI,CAAC,0BAAyB,UAAU;AACvC,gCAAyB,WAAW,IAAI,0BAAyB,YAAY,MAAM;AAAA,IACpF,OAAO;AAIN,gCAAyB,SAAS,aAAa;AAC/C,gCAAyB,SAAS,kBAAkB,QAAQ,CAAC,wBAAwB;AACpF,4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Aa,KAAK,eAAe,gBAAgB,QAAQ;AAE/D,YAAI,YAAY;AACf;AAAA,QACD;AAEA,cAAM,OAAO,GAAG,IAAI;AAAA,UACnB,WAAW,SAAS;AAAA,UACpB,QAAQ,KAAK,MAAO,SAAS,QAAQ,OAAO,QAAS,GAAG,IAAI;AAAA,UAC5D,gBAAgB,KAAK,MAAO,SAAS,OAAO,KAAK,mBAAoB,GAAG,KAAK;AAAA,UAC7E,SAAS,MAAM,eAAe,UAAU;AAAA,UACxC,WAAW,SAAS,UAAU,YAAY;AAAA,UAC1C,cAAc,SAAS,aAAa,YAAY;AAAA,UAChD,UAAU;AAAA,UACV,kBAAkB,KAAK,MAAM,kBAAkB,KAAK,KAAK,IAAK;AAAA,QAC/D;AAAA,MACD;AAAA,IACD;AAEA,UAAM,qBAAqB;AAE3B,WAAO;AAAA,EACR;AACD;AAzSa,0BACG,WAA4C;AADrD,IAAM,2BAAN;","names":[]}
1
+ {"version":3,"sources":["../../../../../nodes/vector_store/shared/MemoryManager/MemoryVectorStoreManager.ts"],"sourcesContent":["import type { Document } from '@langchain/core/documents';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport { MemoryVectorStore } from 'langchain/vectorstores/memory';\nimport type { Logger } from 'n8n-workflow';\n\nimport { getConfig, mbToBytes, hoursToMs } from './config';\nimport { MemoryCalculator } from './MemoryCalculator';\nimport { StoreCleanupService } from './StoreCleanupService';\nimport type { VectorStoreMetadata, VectorStoreStats } from './types';\n\n/**\n * Manages in-memory vector stores with memory limits and auto-cleanup\n */\nexport class MemoryVectorStoreManager {\n\tprivate static instance: MemoryVectorStoreManager | null = null;\n\n\t// Storage\n\tprotected vectorStoreBuffer: Map<string, MemoryVectorStore>;\n\n\tprotected storeMetadata: Map<string, VectorStoreMetadata>;\n\n\tprotected memoryUsageBytes: number = 0;\n\n\t// Dependencies\n\tprotected memoryCalculator: MemoryCalculator;\n\n\tprotected cleanupService: StoreCleanupService;\n\n\tprotected static logger: Logger;\n\n\t// Config values\n\tprotected maxMemorySizeBytes: number;\n\n\tprotected inactiveTtlMs: number;\n\n\t// Inactive TTL cleanup timer\n\tprotected ttlCleanupIntervalId: NodeJS.Timeout | null = null;\n\n\tprotected constructor(\n\t\tprotected embeddings: Embeddings,\n\t\tprotected logger: Logger,\n\t) {\n\t\t// Initialize storage\n\t\tthis.vectorStoreBuffer = new Map();\n\t\tthis.storeMetadata = new Map();\n\t\tthis.logger = logger;\n\n\t\tconst config = getConfig();\n\t\tthis.maxMemorySizeBytes = mbToBytes(config.maxMemoryMB);\n\t\tthis.inactiveTtlMs = hoursToMs(config.ttlHours);\n\n\t\t// Initialize services\n\t\tthis.memoryCalculator = new MemoryCalculator();\n\t\tthis.cleanupService = new StoreCleanupService(\n\t\t\tthis.maxMemorySizeBytes,\n\t\t\tthis.inactiveTtlMs,\n\t\t\tthis.vectorStoreBuffer,\n\t\t\tthis.storeMetadata,\n\t\t\tthis.handleCleanup.bind(this),\n\t\t);\n\n\t\tthis.setupTtlCleanup();\n\t}\n\n\t/**\n\t * Get singleton instance\n\t */\n\tstatic getInstance(embeddings: Embeddings, logger: Logger): MemoryVectorStoreManager {\n\t\tif (!MemoryVectorStoreManager.instance) {\n\t\t\tMemoryVectorStoreManager.instance = new MemoryVectorStoreManager(embeddings, logger);\n\t\t} else {\n\t\t\t// We need to update the embeddings in the existing instance.\n\t\t\t// This is important as embeddings instance is wrapped in a logWrapper,\n\t\t\t// which relies on supplyDataFunctions context which changes on each workflow run\n\t\t\tMemoryVectorStoreManager.instance.embeddings = embeddings;\n\t\t\tMemoryVectorStoreManager.instance.vectorStoreBuffer.forEach((vectorStoreInstance) => {\n\t\t\t\tvectorStoreInstance.embeddings = embeddings;\n\t\t\t});\n\t\t}\n\n\t\treturn MemoryVectorStoreManager.instance;\n\t}\n\n\t/**\n\t * Set up timer for TTL-based cleanup\n\t */\n\tprivate setupTtlCleanup(): void {\n\t\t// Skip setup if TTL is disabled\n\t\tif (this.inactiveTtlMs <= 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Cleanup check interval (run every hour)\n\t\tconst CLEANUP_INTERVAL_MS = 60 * 60 * 1000;\n\n\t\t// Clear any existing interval\n\t\tif (this.ttlCleanupIntervalId) {\n\t\t\tclearInterval(this.ttlCleanupIntervalId);\n\t\t}\n\n\t\t// Setup new interval for TTL cleanup\n\t\tthis.ttlCleanupIntervalId = setInterval(() => {\n\t\t\tthis.cleanupService.cleanupInactiveStores();\n\t\t}, CLEANUP_INTERVAL_MS);\n\t}\n\n\t/**\n\t * Handle cleanup events from the cleanup service\n\t */\n\tprivate handleCleanup(removedKeys: string[], freedBytes: number, reason: 'ttl' | 'memory'): void {\n\t\t// Update total memory usage\n\t\tthis.memoryUsageBytes -= freedBytes;\n\n\t\t// Log cleanup event\n\t\tif (reason === 'ttl') {\n\t\t\tconst ttlHours = Math.round(this.inactiveTtlMs / (60 * 60 * 1000));\n\t\t\tthis.logger.info(\n\t\t\t\t`TTL cleanup: removed ${removedKeys.length} inactive vector stores (${ttlHours}h TTL) to free ${Math.round(freedBytes / (1024 * 1024))}MB of memory`,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.logger.info(\n\t\t\t\t`Memory cleanup: removed ${removedKeys.length} oldest vector stores to free ${Math.round(freedBytes / (1024 * 1024))}MB of memory`,\n\t\t\t);\n\t\t}\n\t}\n\n\tgetMemoryKeysList(): string[] {\n\t\treturn Array.from(this.vectorStoreBuffer.keys());\n\t}\n\n\t/**\n\t * Get or create a vector store by key\n\t */\n\tasync getVectorStore(memoryKey: string): Promise<MemoryVectorStore> {\n\t\tlet vectorStoreInstance = this.vectorStoreBuffer.get(memoryKey);\n\n\t\tif (!vectorStoreInstance) {\n\t\t\tvectorStoreInstance = await MemoryVectorStore.fromExistingIndex(this.embeddings);\n\t\t\tthis.vectorStoreBuffer.set(memoryKey, vectorStoreInstance);\n\n\t\t\tthis.storeMetadata.set(memoryKey, {\n\t\t\t\tsize: 0,\n\t\t\t\tcreatedAt: new Date(),\n\t\t\t\tlastAccessed: new Date(),\n\t\t\t});\n\t\t} else {\n\t\t\tconst metadata = this.storeMetadata.get(memoryKey);\n\t\t\tif (metadata) {\n\t\t\t\tmetadata.lastAccessed = new Date();\n\t\t\t}\n\t\t}\n\n\t\treturn vectorStoreInstance;\n\t}\n\n\t/**\n\t * Reset a store's metadata when it's cleared\n\t */\n\tprotected clearStoreMetadata(memoryKey: string): void {\n\t\tconst metadata = this.storeMetadata.get(memoryKey);\n\t\tif (metadata) {\n\t\t\tthis.memoryUsageBytes -= metadata.size;\n\t\t\tmetadata.size = 0;\n\t\t\tmetadata.lastAccessed = new Date();\n\t\t}\n\t}\n\n\t/**\n\t * Get memory usage in bytes\n\t */\n\tgetMemoryUsage(): number {\n\t\treturn this.memoryUsageBytes;\n\t}\n\n\t/**\n\t * Get memory usage as a formatted string (MB)\n\t */\n\tgetMemoryUsageFormatted(): string {\n\t\treturn `${Math.round(this.memoryUsageBytes / (1024 * 1024))}MB`;\n\t}\n\n\t/**\n\t * Recalculate memory usage from actual vector store contents\n\t * This ensures tracking accuracy for large stores\n\t */\n\trecalculateMemoryUsage(): void {\n\t\tthis.memoryUsageBytes = 0;\n\n\t\t// Recalculate for each store\n\t\tfor (const [key, vectorStore] of this.vectorStoreBuffer.entries()) {\n\t\t\tconst storeSize = this.memoryCalculator.calculateVectorStoreSize(vectorStore);\n\n\t\t\t// Update metadata\n\t\t\tconst metadata = this.storeMetadata.get(key);\n\t\t\tif (metadata) {\n\t\t\t\tmetadata.size = storeSize;\n\t\t\t\tthis.memoryUsageBytes += storeSize;\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.debug(`Recalculated vector store memory: ${this.getMemoryUsageFormatted()}`);\n\t}\n\n\t/**\n\t * Add documents to a vector store\n\t */\n\tasync addDocuments(\n\t\tmemoryKey: string,\n\t\tdocuments: Document[],\n\t\tclearStore?: boolean,\n\t): Promise<void> {\n\t\tif (clearStore) {\n\t\t\tthis.clearStoreMetadata(memoryKey);\n\t\t\tthis.vectorStoreBuffer.delete(memoryKey);\n\t\t}\n\n\t\t// Fast batch estimation instead of per-document calculation\n\t\tconst estimatedAddedSize = this.memoryCalculator.estimateBatchSize(documents);\n\n\t\t// Clean up old stores if necessary\n\t\tthis.cleanupService.cleanupOldestStores(estimatedAddedSize);\n\n\t\tconst vectorStoreInstance = await this.getVectorStore(memoryKey);\n\n\t\t// Get vector count before adding documents\n\t\tconst vectorCountBefore = vectorStoreInstance.memoryVectors?.length || 0;\n\n\t\tawait vectorStoreInstance.addDocuments(documents);\n\n\t\t// Update store metadata and memory tracking\n\t\tconst metadata = this.storeMetadata.get(memoryKey);\n\t\tif (metadata) {\n\t\t\tmetadata.size += estimatedAddedSize;\n\t\t\tmetadata.lastAccessed = new Date();\n\t\t\tthis.memoryUsageBytes += estimatedAddedSize;\n\t\t}\n\n\t\t// Get updated vector count\n\t\tconst vectorCount = vectorStoreInstance.memoryVectors?.length || 0;\n\n\t\t// Periodically recalculate actual memory usage to avoid drift\n\t\tif (\n\t\t\t(vectorCount > 0 && vectorCount % 100 === 0) ||\n\t\t\tdocuments.length > 20 ||\n\t\t\t(vectorCountBefore === 0 && vectorCount > 0)\n\t\t) {\n\t\t\tthis.recalculateMemoryUsage();\n\t\t}\n\n\t\t// Logging memory usage\n\t\tconst maxMemoryMB =\n\t\t\tthis.maxMemorySizeBytes > 0\n\t\t\t\t? (this.maxMemorySizeBytes / (1024 * 1024)).toFixed(0)\n\t\t\t\t: 'unlimited';\n\n\t\tthis.logger.debug(\n\t\t\t`Vector store memory: ${this.getMemoryUsageFormatted()}/${maxMemoryMB}MB (${vectorCount} vectors in ${this.vectorStoreBuffer.size} stores)`,\n\t\t);\n\t}\n\n\t/**\n\t * Get statistics about the vector store memory usage\n\t */\n\tgetStats(): VectorStoreStats {\n\t\tconst now = Date.now();\n\t\tlet inactiveStoreCount = 0;\n\n\t\t// Always recalculate when getting stats to ensure accuracy\n\t\tthis.recalculateMemoryUsage();\n\n\t\tconst stats: VectorStoreStats = {\n\t\t\ttotalSizeBytes: this.memoryUsageBytes,\n\t\t\ttotalSizeMB: Math.round((this.memoryUsageBytes / (1024 * 1024)) * 100) / 100,\n\t\t\tpercentOfLimit:\n\t\t\t\tthis.maxMemorySizeBytes > 0\n\t\t\t\t\t? Math.round((this.memoryUsageBytes / this.maxMemorySizeBytes) * 100)\n\t\t\t\t\t: 0,\n\t\t\tmaxMemoryMB: this.maxMemorySizeBytes > 0 ? this.maxMemorySizeBytes / (1024 * 1024) : -1, // -1 indicates unlimited\n\t\t\tstoreCount: this.vectorStoreBuffer.size,\n\t\t\tinactiveStoreCount: 0,\n\t\t\tttlHours: this.inactiveTtlMs > 0 ? this.inactiveTtlMs / (60 * 60 * 1000) : -1, // -1 indicates disabled\n\t\t\tstores: {},\n\t\t};\n\n\t\t// Add stats for each store\n\t\tfor (const [key, metadata] of this.storeMetadata.entries()) {\n\t\t\tconst store = this.vectorStoreBuffer.get(key);\n\n\t\t\tif (store) {\n\t\t\t\tconst lastAccessedTime = metadata.lastAccessed.getTime();\n\t\t\t\tconst inactiveTimeMs = now - lastAccessedTime;\n\t\t\t\tconst isInactive = this.cleanupService.isStoreInactive(metadata);\n\n\t\t\t\tif (isInactive) {\n\t\t\t\t\tinactiveStoreCount++;\n\t\t\t\t}\n\n\t\t\t\tstats.stores[key] = {\n\t\t\t\t\tsizeBytes: metadata.size,\n\t\t\t\t\tsizeMB: Math.round((metadata.size / (1024 * 1024)) * 100) / 100,\n\t\t\t\t\tpercentOfTotal: Math.round((metadata.size / this.memoryUsageBytes) * 100) || 0,\n\t\t\t\t\tvectors: store.memoryVectors?.length || 0,\n\t\t\t\t\tcreatedAt: metadata.createdAt.toISOString(),\n\t\t\t\t\tlastAccessed: metadata.lastAccessed.toISOString(),\n\t\t\t\t\tinactive: isInactive,\n\t\t\t\t\tinactiveForHours: Math.round(inactiveTimeMs / (60 * 60 * 1000)),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tstats.inactiveStoreCount = inactiveStoreC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AAO,KAAK,mBAAoB,GAAG,KAAK;AAAA,UAC7E,SAAS,MAAM,eAAe,UAAU;AAAA,UACxC,WAAW,SAAS,UAAU,YAAY;AAAA,UAC1C,cAAc,SAAS,aAAa,YAAY;AAAA,UAChD,UAAU;AAAA,UACV,kBAAkB,KAAK,MAAM,kBAAkB,KAAK,KAAK,IAAK;AAAA,QAC/D;AAAA,MACD;AAAA,IACD;AAEA,UAAM,qBAAqB;AAE3B,WAAO;AAAA,EACR;AACD;AA7Sa,0BACG,WAA4C;AADrD,IAAM,2BAAN;","names":[]}
@@ -34,7 +34,8 @@ const createVectorStoreNode = (args) => class VectorStoreNodeType {
34
34
  icon: args.meta.icon,
35
35
  iconColor: args.meta.iconColor,
36
36
  group: ["transform"],
37
- version: [1, 1.1],
37
+ // 1.2 has changes to VectorStoreInMemory node.
38
+ version: [1, 1.1, 1.2],
38
39
  defaults: {
39
40
  name: args.meta.displayName
40
41
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-filename-against-convention */\n/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeTypeDescription,\n\tSupplyData,\n\tISupplyDataFunctions,\n\tINodeType,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\n// Import custom types\nimport {\n\thandleLoadOperation,\n\thandleInsertOperation,\n\thandleUpdateOperation,\n\thandleRetrieveOperation,\n\thandleRetrieveAsToolOperation,\n} from './operations';\nimport type { NodeOperationMode, VectorStoreNodeConstructorArgs } from './types';\n// Import utility functions\nimport { transformDescriptionForOperationMode, getOperationModeOptions } from './utils';\n\n// Import operation handlers\n\n/**\n * Creates a vector store node with the given configuration\n * This factory function produces a complete node class that implements all vector store operations\n */\nexport const createVectorStoreNode = <T extends VectorStore = VectorStore>(\n\targs: VectorStoreNodeConstructorArgs<T>,\n) =>\n\tclass VectorStoreNodeType implements INodeType {\n\t\tdescription: INodeTypeDescription = {\n\t\t\tdisplayName: args.meta.displayName,\n\t\t\tname: args.meta.name,\n\t\t\tdescription: args.meta.description,\n\t\t\ticon: args.meta.icon,\n\t\t\ticonColor: args.meta.iconColor,\n\t\t\tgroup: ['transform'],\n\t\t\tversion: [1, 1.1],\n\t\t\tdefaults: {\n\t\t\t\tname: args.meta.displayName,\n\t\t\t},\n\t\t\tcodex: {\n\t\t\t\tcategories: ['AI'],\n\t\t\t\tsubcategories: {\n\t\t\t\t\tAI: ['Vector Stores', 'Tools', 'Root Nodes'],\n\t\t\t\t\tTools: ['Other Tools'],\n\t\t\t\t},\n\t\t\t\tresources: {\n\t\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl: args.meta.docsUrl,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\tcredentials: args.meta.credentials,\n\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\t\tinputs: `={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"${NodeConnectionTypes.AiEmbedding}\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\t\treturn inputs;\n\t\t\t\t}\n\n\t\t\t\tif (['insert', 'load', 'update'].includes(mode)) {\n\t\t\t\t\tinputs.push({ displayName: \"\", type: \"${NodeConnectionTypes.Main}\"})\n\t\t\t\t}\n\n\t\t\t\tif (['insert'].includes(mode)) {\n\t\t\t\t\tinputs.push({ displayName: \"Document\", type: \"${NodeConnectionTypes.AiDocument}\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}`,\n\t\t\toutputs: `={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode ?? 'retrieve';\n\n\t\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\t\treturn [{ displayName: \"Tool\", type: \"${NodeConnectionTypes.AiTool}\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"${NodeConnectionTypes.AiVectorStore}\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"${NodeConnectionTypes.Main}\"}]\n\t\t\t})($parameter)\n\t\t}}`,\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Operation Mode',\n\t\t\t\t\tname: 'mode',\n\t\t\t\t\ttype: 'options',\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdefault: 'retrieve',\n\t\t\t\t\toptions: getOperationModeOptions(args),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...getConnectionHintNoticeField([NodeConnectionTypes.AiRetriever]),\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Name',\n\t\t\t\t\tname: 'toolName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription: 'Name of the vector store',\n\t\t\t\t\tplaceholder: 'e.g. company_knowledge_base',\n\t\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Description',\n\t\t\t\t\tname: 'toolDescription',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttypeOptions: { rows: 2 },\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often',\n\t\t\t\t\tplaceholder: `e.g. ${args.meta.description}`,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...args.sharedFields,\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Embedding Batch Size',\n\t\t\t\t\tname: 'embeddingBatchSize',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 200,\n\t\t\t\t\tdescription: 'Number of documents to embed in a single batch',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['insert'],\n\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...transformDescriptionForOperationMode(args.insertFields ?? [], 'insert'),\n\t\t\t\t// Prompt and topK are always used for the load operation\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Prompt',\n\t\t\t\t\tname: 'prompt',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Search prompt to retrieve matching documents from the vector store using similarity-based ranking',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Limit',\n\t\t\t\t\tname: 'topK',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 4,\n\t\t\t\t\tdescription: 'Number of top results to fetch from vector store',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Include Metadata',\n\t\t\t\t\tname: 'includeDocumentMetadata',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: true,\n\t\t\t\t\tdescription: 'Whether or not to include document metadata',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// ID is always used for update operation\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'ID',\n\t\t\t\t\tname: 'id',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription: 'ID of an embedding entry',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['update'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...transformDescriptionForOperationMode(args.loadFields ?? [], [\n\t\t\t\t\t'load',\n\t\t\t\t\t'retrieve-as-tool',\n\t\t\t\t]),\n\t\t\t\t...transformDescriptionForOperationMode(args.retrieveFields ?? [], 'retrieve'),\n\t\t\t\t...transformDescriptionForOperationMode(args.updateFields ?? [], 'update'),\n\t\t\t],\n\t\t};\n\n\t\tmethods = args.methods;\n\n\t\t/**\n\t\t * Method to execute the node in regular workflow mode\n\t\t * Supports 'load', 'insert', and 'update' operation modes\n\t\t */\n\t\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\t\tconst mode = this.getNodeParameter('mode', 0) as NodeOperationMode;\n\n\t\t\t// Get the embeddings model connected to this node\n\t\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t\t0,\n\t\t\t)) as Embeddings;\n\n\t\t\t// Handle each operation mode with dedicated modules\n\t\t\tif (mode === 'load') {\n\t\t\t\tconst items = this.getInputData(0);\n\t\t\t\tconst resultData = [];\n\n\t\t\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\t\t\tconst docs = await handleLoadOperation(this, args, embeddings, itemIndex);\n\t\t\t\t\tresultData.push(...docs);\n\t\t\t\t}\n\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tif (mode === 'insert') {\n\t\t\t\tconst resultData = await handleInsertOperation(this, args, embeddings);\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tif (mode === 'update') {\n\t\t\t\tconst resultData = await handleUpdateOperation(this, args, embeddings);\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Only the \"load\", \"update\" and \"insert\" operation modes are supported with execute',\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Method to supply data to AI nodes\n\t\t * Supports 'retrieve' and 'retrieve-as-tool' operation modes\n\t\t */\n\t\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\t\tconst mode = this.getNodeParameter('mode', 0) as NodeOperationMode;\n\n\t\t\t// Get the embeddings model connected to this node\n\t\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t\t0,\n\t\t\t)) as Embeddings;\n\n\t\t\t// Handle each supply data operation mode with dedicated modules\n\t\t\tif (mode === 'retrieve') {\n\t\t\t\treturn await handleRetrieveOperation(this, args, embeddings, itemIndex);\n\t\t\t}\n\n\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\treturn await handleRetrieveAsToolOperation(this, args, embeddings, itemIndex);\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Only the \"retrieve\" and \"retrieve-as-tool\" operation mode is supported to supply data',\n\t\t\t);\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAwD;AAUxD,0BAA6C;AAG7C,wBAMO;AAGP,mBAA8E;AAQvE,MAAM,wBAAwB,CACpC,SAEA,MAAM,oBAAyC;AAAA,EAA/C;AACC,uBAAoC;AAAA,MACnC,aAAa,KAAK,KAAK;AAAA,MACvB,MAAM,KAAK,KAAK;AAAA,MAChB,aAAa,KAAK,KAAK;AAAA,MACvB,MAAM,KAAK,KAAK;AAAA,MAChB,WAAW,KAAK,KAAK;AAAA,MACrB,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,UAAU;AAAA,QACT,MAAM,KAAK,KAAK;AAAA,MACjB;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,iBAAiB,SAAS,YAAY;AAAA,UAC3C,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK,KAAK,KAAK;AAAA,YAChB;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,aAAa,KAAK,KAAK;AAAA;AAAA,MAEvB,QAAQ;AAAA;AAAA;AAAA,yDAG8C,wCAAoB,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6CAO3C,wCAAoB,IAAI;AAAA;AAAA;AAAA;AAAA,qDAIhB,wCAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,MAKhF,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,6CAKiC,wCAAoB,MA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M,OAAO,KAAK,iBAAiB,QAAQ,CAAC;AAG5C,UAAM,aAAc,MAAM,KAAK;AAAA,MAC9B,wCAAoB;AAAA,MACpB;AAAA,IACD;AAGA,QAAI,SAAS,QAAQ;AACpB,YAAM,QAAQ,KAAK,aAAa,CAAC;AACjC,YAAM,aAAa,CAAC;AAEpB,eAAS,YAAY,GAAG,YAAY,MAAM,QAAQ,aAAa;AAC9D,cAAM,OAAO,UAAM,uCAAoB,MAAM,MAAM,YAAY,SAAS;AACxE,mBAAW,KAAK,GAAG,IAAI;AAAA,MACxB;AAEA,aAAO,CAAC,UAAU;AAAA,IACnB;AAEA,QAAI,SAAS,UAAU;AACtB,YAAM,aAAa,UAAM,yCAAsB,MAAM,MAAM,UAAU;AACrE,aAAO,CAAC,UAAU;AAAA,IACnB;AAEA,QAAI,SAAS,UAAU;AACtB,YAAM,aAAa,UAAM,yCAAsB,MAAM,MAAM,UAAU;AACrE,aAAO,CAAC,UAAU;AAAA,IACnB;AAEA,UAAM,IAAI;AAAA,MACT,KAAK,QAAQ;AAAA,MACb;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAuC,WAAwC;AACpF,UAAM,OAAO,KAAK,iBAAiB,QAAQ,CAAC;AAG5C,UAAM,aAAc,MAAM,KAAK;AAAA,MAC9B,wCAAoB;AAAA,MACpB;AAAA,IACD;AAGA,QAAI,SAAS,YAAY;AACxB,aAAO,UAAM,2CAAwB,MAAM,MAAM,YAAY,SAAS;AAAA,IACvE;AAEA,QAAI,SAAS,oBAAoB;AAChC,aAAO,UAAM,iDAA8B,MAAM,MAAM,YAAY,SAAS;AAAA,IAC7E;AAEA,UAAM,IAAI;AAAA,MACT,KAAK,QAAQ;AAAA,MACb;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../../nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-filename-against-convention */\n/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeTypeDescription,\n\tSupplyData,\n\tISupplyDataFunctions,\n\tINodeType,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\n// Import custom types\nimport {\n\thandleLoadOperation,\n\thandleInsertOperation,\n\thandleUpdateOperation,\n\thandleRetrieveOperation,\n\thandleRetrieveAsToolOperation,\n} from './operations';\nimport type { NodeOperationMode, VectorStoreNodeConstructorArgs } from './types';\n// Import utility functions\nimport { transformDescriptionForOperationMode, getOperationModeOptions } from './utils';\n\n// Import operation handlers\n\n/**\n * Creates a vector store node with the given configuration\n * This factory function produces a complete node class that implements all vector store operations\n */\nexport const createVectorStoreNode = <T extends VectorStore = VectorStore>(\n\targs: VectorStoreNodeConstructorArgs<T>,\n) =>\n\tclass VectorStoreNodeType implements INodeType {\n\t\tdescription: INodeTypeDescription = {\n\t\t\tdisplayName: args.meta.displayName,\n\t\t\tname: args.meta.name,\n\t\t\tdescription: args.meta.description,\n\t\t\ticon: args.meta.icon,\n\t\t\ticonColor: args.meta.iconColor,\n\t\t\tgroup: ['transform'],\n\t\t\t// 1.2 has changes to VectorStoreInMemory node.\n\t\t\tversion: [1, 1.1, 1.2],\n\t\t\tdefaults: {\n\t\t\t\tname: args.meta.displayName,\n\t\t\t},\n\t\t\tcodex: {\n\t\t\t\tcategories: ['AI'],\n\t\t\t\tsubcategories: {\n\t\t\t\t\tAI: ['Vector Stores', 'Tools', 'Root Nodes'],\n\t\t\t\t\tTools: ['Other Tools'],\n\t\t\t\t},\n\t\t\t\tresources: {\n\t\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl: args.meta.docsUrl,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\tcredentials: args.meta.credentials,\n\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\t\tinputs: `={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"${NodeConnectionTypes.AiEmbedding}\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\t\treturn inputs;\n\t\t\t\t}\n\n\t\t\t\tif (['insert', 'load', 'update'].includes(mode)) {\n\t\t\t\t\tinputs.push({ displayName: \"\", type: \"${NodeConnectionTypes.Main}\"})\n\t\t\t\t}\n\n\t\t\t\tif (['insert'].includes(mode)) {\n\t\t\t\t\tinputs.push({ displayName: \"Document\", type: \"${NodeConnectionTypes.AiDocument}\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}`,\n\t\t\toutputs: `={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode ?? 'retrieve';\n\n\t\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\t\treturn [{ displayName: \"Tool\", type: \"${NodeConnectionTypes.AiTool}\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"${NodeConnectionTypes.AiVectorStore}\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"${NodeConnectionTypes.Main}\"}]\n\t\t\t})($parameter)\n\t\t}}`,\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Operation Mode',\n\t\t\t\t\tname: 'mode',\n\t\t\t\t\ttype: 'options',\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdefault: 'retrieve',\n\t\t\t\t\toptions: getOperationModeOptions(args),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...getConnectionHintNoticeField([NodeConnectionTypes.AiRetriever]),\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Name',\n\t\t\t\t\tname: 'toolName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription: 'Name of the vector store',\n\t\t\t\t\tplaceholder: 'e.g. company_knowledge_base',\n\t\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Description',\n\t\t\t\t\tname: 'toolDescription',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttypeOptions: { rows: 2 },\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often',\n\t\t\t\t\tplaceholder: `e.g. ${args.meta.description}`,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...args.sharedFields,\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Embedding Batch Size',\n\t\t\t\t\tname: 'embeddingBatchSize',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 200,\n\t\t\t\t\tdescription: 'Number of documents to embed in a single batch',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['insert'],\n\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...transformDescriptionForOperationMode(args.insertFields ?? [], 'insert'),\n\t\t\t\t// Prompt and topK are always used for the load operation\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Prompt',\n\t\t\t\t\tname: 'prompt',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Search prompt to retrieve matching documents from the vector store using similarity-based ranking',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Limit',\n\t\t\t\t\tname: 'topK',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 4,\n\t\t\t\t\tdescription: 'Number of top results to fetch from vector store',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Include Metadata',\n\t\t\t\t\tname: 'includeDocumentMetadata',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: true,\n\t\t\t\t\tdescription: 'Whether or not to include document metadata',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// ID is always used for update operation\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'ID',\n\t\t\t\t\tname: 'id',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription: 'ID of an embedding entry',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['update'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...transformDescriptionForOperationMode(args.loadFields ?? [], [\n\t\t\t\t\t'load',\n\t\t\t\t\t'retrieve-as-tool',\n\t\t\t\t]),\n\t\t\t\t...transformDescriptionForOperationMode(args.retrieveFields ?? [], 'retrieve'),\n\t\t\t\t...transformDescriptionForOperationMode(args.updateFields ?? [], 'update'),\n\t\t\t],\n\t\t};\n\n\t\tmethods = args.methods;\n\n\t\t/**\n\t\t * Method to execute the node in regular workflow mode\n\t\t * Supports 'load', 'insert', and 'update' operation modes\n\t\t */\n\t\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\t\tconst mode = this.getNodeParameter('mode', 0) as NodeOperationMode;\n\n\t\t\t// Get the embeddings model connected to this node\n\t\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t\t0,\n\t\t\t)) as Embeddings;\n\n\t\t\t// Handle each operation mode with dedicated modules\n\t\t\tif (mode === 'load') {\n\t\t\t\tconst items = this.getInputData(0);\n\t\t\t\tconst resultData = [];\n\n\t\t\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\t\t\tconst docs = await handleLoadOperation(this, args, embeddings, itemIndex);\n\t\t\t\t\tresultData.push(...docs);\n\t\t\t\t}\n\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tif (mode === 'insert') {\n\t\t\t\tconst resultData = await handleInsertOperation(this, args, embeddings);\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tif (mode === 'update') {\n\t\t\t\tconst resultData = await handleUpdateOperation(this, args, embeddings);\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Only the \"load\", \"update\" and \"insert\" operation modes are supported with execute',\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Method to supply data to AI nodes\n\t\t * Supports 'retrieve' and 'retrieve-as-tool' operation modes\n\t\t */\n\t\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\t\tconst mode = this.getNodeParameter('mode', 0) as NodeOperationMode;\n\n\t\t\t// Get the embeddings model connected to this node\n\t\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t\t0,\n\t\t\t)) as Embeddings;\n\n\t\t\t// Handle each supply data operation mode with dedicated modules\n\t\t\tif (mode === 'retrieve') {\n\t\t\t\treturn await handleRetrieveOperation(this, args, embeddings, itemIndex);\n\t\t\t}\n\n\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\treturn await handleRetrieveAsToolOperation(this, args, embeddings, itemIndex);\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Only the \"retrieve\" and \"retrieve-as-tool\" operation mode is supported to supply data',\n\t\t\t);\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAwD;AAUxD,0BAA6C;AAG7C,wBAMO;AAGP,mBAA8E;AAQvE,MAAM,wBAAwB,CACpC,SAEA,MAAM,oBAAyC;AAAA,EAA/C;AACC,uBAAoC;AAAA,MACnC,aAAa,KAAK,KAAK;AAAA,MACvB,MAAM,KAAK,KAAK;AAAA,MAChB,aAAa,KAAK,KAAK;AAAA,MACvB,MAAM,KAAK,KAAK;AAAA,MAChB,WAAW,KAAK,KAAK;AAAA,MACrB,OAAO,CAAC,WAAW;AAAA;AAAA,MAEnB,SAAS,CAAC,GAAG,KAAK,GAAG;AAAA,MACrB,UAAU;AAAA,QACT,MAAM,KAAK,KAAK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Q;AAAA,MACb;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAuC,WAAwC;AACpF,UAAM,OAAO,KAAK,iBAAiB,QAAQ,CAAC;AAG5C,UAAM,aAAc,MAAM,KAAK;AAAA,MAC9B,wCAAoB;AAAA,MACpB;AAAA,IACD;AAGA,QAAI,SAAS,YAAY;AACxB,aAAO,UAAM,2CAAwB,MAAM,MAAM,YAAY,SAAS;AAAA,IACvE;AAEA,QAAI,SAAS,oBAAoB;AAChC,aAAO,UAAM,iDAA8B,MAAM,MAAM,YAAY,SAAS;AAAA,IAC7E;AAEA,UAAM,IAAI;AAAA,MACT,KAAK,QAAQ;AAAA,MACb;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../nodes/vector_store/shared/createVectorStoreNode/types.ts"],"sourcesContent":["import type { Document } from '@langchain/core/documents';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport type {\n\tIExecuteFunctions,\n\tINodeCredentialDescription,\n\tINodeProperties,\n\tILoadOptionsFunctions,\n\tINodeListSearchResult,\n\tIcon,\n\tISupplyDataFunctions,\n\tThemeIconColor,\n} from 'n8n-workflow';\n\nexport type NodeOperationMode = 'insert' | 'load' | 'retrieve' | 'update' | 'retrieve-as-tool';\n\nexport interface NodeMeta {\n\tdisplayName: string;\n\tname: string;\n\tdescription: string;\n\tdocsUrl: string;\n\ticon: Icon;\n\ticonColor?: ThemeIconColor;\n\tcredentials?: INodeCredentialDescription[];\n\toperationModes?: NodeOperationMode[];\n}\n\nexport interface VectorStoreNodeConstructorArgs<T extends VectorStore = VectorStore> {\n\tmeta: NodeMeta;\n\tmethods?: {\n\t\tlistSearch?: {\n\t\t\t[key: string]: (\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tfilter?: string,\n\t\t\t\tpaginationToken?: string,\n\t\t\t) => Promise<INodeListSearchResult>;\n\t\t};\n\t};\n\n\tsharedFields: INodeProperties[];\n\tinsertFields?: INodeProperties[];\n\tloadFields?: INodeProperties[];\n\tretrieveFields?: INodeProperties[];\n\tupdateFields?: INodeProperties[];\n\n\t/**\n\t * Function to populate the vector store with documents\n\t * Used during the 'insert' operation mode\n\t */\n\tpopulateVectorStore: (\n\t\tcontext: IExecuteFunctions | ISupplyDataFunctions,\n\t\tembeddings: Embeddings,\n\t\tdocuments: Array<Document<Record<string, unknown>>>,\n\t\titemIndex: number,\n\t) => Promise<void>;\n\n\t/**\n\t * Function to get the vector store client\n\t * This function is called for all operation modes\n\t */\n\tgetVectorStoreClient: (\n\t\tcontext: IExecuteFunctions | ISupplyDataFunctions,\n\t\tfilter: Record<string, never> | undefined,\n\t\tembeddings: Embeddings,\n\t\titemIndex: number,\n\t) => Promise<T>;\n\n\t/**\n\t * Optional function to release resources associated with the vector store client\n\t * Called after the vector store operations are complete\n\t */\n\treleaseVectorStoreClient?: (vectorStore: T) => void;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../../../nodes/vector_store/shared/createVectorStoreNode/types.ts"],"sourcesContent":["import type { Document } from '@langchain/core/documents';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport type {\n\tIExecuteFunctions,\n\tINodeCredentialDescription,\n\tINodeProperties,\n\tILoadOptionsFunctions,\n\tINodeListSearchResult,\n\tIcon,\n\tISupplyDataFunctions,\n\tThemeIconColor,\n\tIDataObject,\n\tNodeParameterValueType,\n} from 'n8n-workflow';\n\nexport type NodeOperationMode = 'insert' | 'load' | 'retrieve' | 'update' | 'retrieve-as-tool';\n\nexport interface NodeMeta {\n\tdisplayName: string;\n\tname: string;\n\tdescription: string;\n\tdocsUrl: string;\n\ticon: Icon;\n\ticonColor?: ThemeIconColor;\n\tcredentials?: INodeCredentialDescription[];\n\toperationModes?: NodeOperationMode[];\n}\n\nexport interface VectorStoreNodeConstructorArgs<T extends VectorStore = VectorStore> {\n\tmeta: NodeMeta;\n\tmethods?: {\n\t\tlistSearch?: {\n\t\t\t[key: string]: (\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tfilter?: string,\n\t\t\t\tpaginationToken?: string,\n\t\t\t) => Promise<INodeListSearchResult>;\n\t\t};\n\t\tactionHandler?: {\n\t\t\t[functionName: string]: (\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tpayload: IDataObject | string | undefined,\n\t\t\t) => Promise<NodeParameterValueType>;\n\t\t};\n\t};\n\n\tsharedFields: INodeProperties[];\n\tinsertFields?: INodeProperties[];\n\tloadFields?: INodeProperties[];\n\tretrieveFields?: INodeProperties[];\n\tupdateFields?: INodeProperties[];\n\n\t/**\n\t * Function to populate the vector store with documents\n\t * Used during the 'insert' operation mode\n\t */\n\tpopulateVectorStore: (\n\t\tcontext: IExecuteFunctions | ISupplyDataFunctions,\n\t\tembeddings: Embeddings,\n\t\tdocuments: Array<Document<Record<string, unknown>>>,\n\t\titemIndex: number,\n\t) => Promise<void>;\n\n\t/**\n\t * Function to get the vector store client\n\t * This function is called for all operation modes\n\t */\n\tgetVectorStoreClient: (\n\t\tcontext: IExecuteFunctions | ISupplyDataFunctions,\n\t\tfilter: Record<string, never> | undefined,\n\t\tembeddings: Embeddings,\n\t\titemIndex: number,\n\t) => Promise<T>;\n\n\t/**\n\t * Optional function to release resources associated with the vector store client\n\t * Called after the vector store operations are complete\n\t */\n\treleaseVectorStoreClient?: (vectorStore: T) => void;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -231,7 +231,12 @@ const properties = [
231
231
  name: "returnImageUrls",
232
232
  type: "boolean",
233
233
  default: false,
234
- description: "Whether to return image URL(s) instead of binary file(s)"
234
+ description: "Whether to return image URL(s) instead of binary file(s)",
235
+ displayOptions: {
236
+ hide: {
237
+ "/model": ["gpt-image-1"]
238
+ }
239
+ }
235
240
  },
236
241
  {
237
242
  displayName: "Put Output in Field",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/image/generate.operation.ts"],"sourcesContent":["import type {\n\tINodeProperties,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Model',\n\t\tname: 'model',\n\t\ttype: 'options',\n\t\tdefault: 'dall-e-3',\n\t\tdescription: 'The model to use for image generation',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'DALL·E 2',\n\t\t\t\tvalue: 'dall-e-2',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'DALL·E 3',\n\t\t\t\tvalue: 'dall-e-3',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'GPT Image 1',\n\t\t\t\tvalue: 'gpt-image-1',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Prompt',\n\t\tname: 'prompt',\n\t\ttype: 'string',\n\t\tplaceholder: 'e.g. A cute cat eating a dinosaur',\n\t\tdescription:\n\t\t\t'A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3.',\n\t\tdefault: '',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Number of Images',\n\t\t\t\tname: 'n',\n\t\t\t\tdefault: 1,\n\t\t\t\tdescription: 'Number of images to generate',\n\t\t\t\ttype: 'number',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 1,\n\t\t\t\t\tmaxValue: 10,\n\t\t\t\t},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-2'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Quality',\n\t\t\t\tname: 'dalleQuality',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The quality of the image that will be generated, HD creates images with finer details and greater consistency across the image',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'HD',\n\t\t\t\t\t\tvalue: 'hd',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Standard',\n\t\t\t\t\t\tvalue: 'standard',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'standard',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Quality',\n\t\t\t\tname: 'quality',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The quality of the image that will be generated, High creates images with finer details and greater consistency across the image',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'High',\n\t\t\t\t\t\tvalue: 'high',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Medium',\n\t\t\t\t\t\tvalue: 'medium',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Low',\n\t\t\t\t\t\tvalue: 'low',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['gpt-image-1'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'medium',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '256x256',\n\t\t\t\t\t\tvalue: '256x256',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '512x512',\n\t\t\t\t\t\tvalue: '512x512',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-2'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1792x1024',\n\t\t\t\t\t\tvalue: '1792x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1792',\n\t\t\t\t\t\tvalue: '1024x1792',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1536',\n\t\t\t\t\t\tvalue: '1024x1536',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1536x1024',\n\t\t\t\t\t\tvalue: '1536x1024',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['gpt-image-1'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Style',\n\t\t\t\tname: 'style',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Natural',\n\t\t\t\t\t\tvalue: 'natural',\n\t\t\t\t\t\tdescription: 'Produce more natural looking images',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Vivid',\n\t\t\t\t\t\tvalue: 'vivid',\n\t\t\t\t\t\tdescription: 'Lean towards generating hyper-real and dramatic images',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'vivid',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Respond with Image URL(s)',\n\t\t\t\tname: 'returnImageUrls',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to return image URL(s) instead of binary file(s)',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Put Output in Field',\n\t\t\t\tname: 'binaryPropertyOutput',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'data',\n\t\t\t\thint: 'The name of the output field to put the binary file data in',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\treturnImageUrls: [false],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['generate'],\n\t\tresource: ['image'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('model', i) as string;\n\tconst prompt = this.getNodeParameter('prompt', i) as string;\n\tconst options = this.getNodeParameter('options', i, {});\n\tlet response_format = 'b64_json';\n\tlet binaryPropertyOutput = 'data';\n\n\tif (options.returnImageUrls) {\n\t\tresponse_format = 'url';\n\t}\n\n\tif (options.binaryPropertyOutput) {\n\t\tbinaryPropertyOutput = options.binaryPropertyOutput as string;\n\t\tdelete options.binaryPropertyOutput;\n\t}\n\n\tif (options.dalleQuality) {\n\t\toptions.quality = options.dalleQuality;\n\t\tdelete options.dalleQuality;\n\t}\n\n\tdelete options.returnImageUrls;\n\tconst body: IDataObject = {\n\t\tprompt,\n\t\tmodel,\n\t\tresponse_format: model !== 'gpt-image-1' ? response_format : undefined, // gpt-image-1 does not support response_format\n\t\t...options,\n\t};\n\n\tconst { data } = await apiRequest.call(this, 'POST', '/images/generations', { body });\n\tif (response_format === 'url') {\n\t\treturn ((data as IDataObject[]) || []).map((entry) => ({\n\t\t\tjson: entry,\n\t\t\tpairedItem: { item: i },\n\t\t}));\n\t} else {\n\t\tconst returnData: INodeExecutionData[] = [];\n\n\t\tfor (const entry of data) {\n\t\t\tconst binaryData = await this.helpers.prepareBinaryData(\n\t\t\t\tBuffer.from(entry.b64_json as string, 'base64'),\n\t\t\t\t'data',\n\t\t\t);\n\t\t\treturnData.push({\n\t\t\t\tjson: Object.assign({}, binaryData, {\n\t\t\t\t\tdata: undefined,\n\t\t\t\t}),\n\t\t\t\tbinary: {\n\t\t\t\t\t[binaryPropertyOutput]: binaryData,\n\t\t\t\t},\n\t\t\t\tpairedItem: { item: i },\n\t\t\t});\n\t\t}\n\n\t\treturn returnData;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAqC;AAErC,uBAA2B;A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,CAAC;AACtD,MAAI,kBAAkB;AACtB,MAAI,uBAAuB;AAE3B,MAAI,QAAQ,iBAAiB;AAC5B,sBAAkB;AAAA,EACnB;AAEA,MAAI,QAAQ,sBAAsB;AACjC,2BAAuB,QAAQ;AAC/B,WAAO,QAAQ;AAAA,EAChB;AAEA,MAAI,QAAQ,cAAc;AACzB,YAAQ,UAAU,QAAQ;AAC1B,WAAO,QAAQ;AAAA,EAChB;AAEA,SAAO,QAAQ;AACf,QAAM,OAAoB;AAAA,IACzB;AAAA,IACA;AAAA,IACA,iBAAiB,UAAU,gBAAgB,kBAAkB;AAAA;AAAA,IAC7D,GAAG;AAAA,EACJ;AAEA,QAAM,EAAE,KAAK,IAAI,MAAM,4BAAW,KAAK,MAAM,QAAQ,uBAAuB,EAAE,KAAK,CAAC;AACpF,MAAI,oBAAoB,OAAO;AAC9B,YAAS,QAA0B,CAAC,GAAG,IAAI,CAAC,WAAW;AAAA,MACtD,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB,EAAE;AAAA,EACH,OAAO;AACN,UAAM,aAAmC,CAAC;AAE1C,eAAW,SAAS,MAAM;AACzB,YAAM,aAAa,MAAM,KAAK,QAAQ;AAAA,QACrC,OAAO,KAAK,MAAM,UAAoB,QAAQ;AAAA,QAC9C;AAAA,MACD;AACA,iBAAW,KAAK;AAAA,QACf,MAAM,OAAO,OAAO,CAAC,GAAG,YAAY;AAAA,UACnC,MAAM;AAAA,QACP,CAAC;AAAA,QACD,QAAQ;AAAA,UACP,CAAC,oBAAoB,GAAG;AAAA,QACzB;AAAA,QACA,YAAY,EAAE,MAAM,EAAE;AAAA,MACvB,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/image/generate.operation.ts"],"sourcesContent":["import type {\n\tINodeProperties,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Model',\n\t\tname: 'model',\n\t\ttype: 'options',\n\t\tdefault: 'dall-e-3',\n\t\tdescription: 'The model to use for image generation',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'DALL·E 2',\n\t\t\t\tvalue: 'dall-e-2',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'DALL·E 3',\n\t\t\t\tvalue: 'dall-e-3',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'GPT Image 1',\n\t\t\t\tvalue: 'gpt-image-1',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Prompt',\n\t\tname: 'prompt',\n\t\ttype: 'string',\n\t\tplaceholder: 'e.g. A cute cat eating a dinosaur',\n\t\tdescription:\n\t\t\t'A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3.',\n\t\tdefault: '',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Number of Images',\n\t\t\t\tname: 'n',\n\t\t\t\tdefault: 1,\n\t\t\t\tdescription: 'Number of images to generate',\n\t\t\t\ttype: 'number',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 1,\n\t\t\t\t\tmaxValue: 10,\n\t\t\t\t},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-2'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Quality',\n\t\t\t\tname: 'dalleQuality',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The quality of the image that will be generated, HD creates images with finer details and greater consistency across the image',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'HD',\n\t\t\t\t\t\tvalue: 'hd',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Standard',\n\t\t\t\t\t\tvalue: 'standard',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'standard',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Quality',\n\t\t\t\tname: 'quality',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The quality of the image that will be generated, High creates images with finer details and greater consistency across the image',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'High',\n\t\t\t\t\t\tvalue: 'high',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Medium',\n\t\t\t\t\t\tvalue: 'medium',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Low',\n\t\t\t\t\t\tvalue: 'low',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['gpt-image-1'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'medium',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '256x256',\n\t\t\t\t\t\tvalue: '256x256',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '512x512',\n\t\t\t\t\t\tvalue: '512x512',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-2'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1792x1024',\n\t\t\t\t\t\tvalue: '1792x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1792',\n\t\t\t\t\t\tvalue: '1024x1792',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Resolution',\n\t\t\t\tname: 'size',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1024',\n\t\t\t\t\t\tvalue: '1024x1024',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1024x1536',\n\t\t\t\t\t\tvalue: '1024x1536',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: '1536x1024',\n\t\t\t\t\t\tvalue: '1536x1024',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['gpt-image-1'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '1024x1024',\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Style',\n\t\t\t\tname: 'style',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Natural',\n\t\t\t\t\t\tvalue: 'natural',\n\t\t\t\t\t\tdescription: 'Produce more natural looking images',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Vivid',\n\t\t\t\t\t\tvalue: 'vivid',\n\t\t\t\t\t\tdescription: 'Lean towards generating hyper-real and dramatic images',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/model': ['dall-e-3'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: 'vivid',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Respond with Image URL(s)',\n\t\t\t\tname: 'returnImageUrls',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to return image URL(s) instead of binary file(s)',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'/model': ['gpt-image-1'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Put Output in Field',\n\t\t\t\tname: 'binaryPropertyOutput',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'data',\n\t\t\t\thint: 'The name of the output field to put the binary file data in',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\treturnImageUrls: [false],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['generate'],\n\t\tresource: ['image'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('model', i) as string;\n\tconst prompt = this.getNodeParameter('prompt', i) as string;\n\tconst options = this.getNodeParameter('options', i, {});\n\tlet response_format = 'b64_json';\n\tlet binaryPropertyOutput = 'data';\n\n\tif (options.returnImageUrls) {\n\t\tresponse_format = 'url';\n\t}\n\n\tif (options.binaryPropertyOutput) {\n\t\tbinaryPropertyOutput = options.binaryPropertyOutput as string;\n\t\tdelete options.binaryPropertyOutput;\n\t}\n\n\tif (options.dalleQuality) {\n\t\toptions.quality = options.dalleQuality;\n\t\tdelete options.dalleQuality;\n\t}\n\n\tdelete options.returnImageUrls;\n\tconst body: IDataObject = {\n\t\tprompt,\n\t\tmodel,\n\t\tresponse_format: model !== 'gpt-image-1' ? response_format : undefined, // gpt-image-1 does not support response_format\n\t\t...options,\n\t};\n\n\tconst { data } = await apiRequest.call(this, 'POST', '/images/generations', { body });\n\tif (response_format === 'url') {\n\t\treturn ((data as IDataObject[]) || []).map((entry) => ({\n\t\t\tjson: entry,\n\t\t\tpairedItem: { item: i },\n\t\t}));\n\t} else {\n\t\tconst returnData: INodeExecutionData[] = [];\n\n\t\tfor (const entry of data) {\n\t\t\tconst binaryData = await this.helpers.prepareBinaryData(\n\t\t\t\tBuffer.from(entry.b64_json as string, 'base64'),\n\t\t\t\t'data',\n\t\t\t);\n\t\t\treturnData.push({\n\t\t\t\tjson: Object.assign({}, binaryData, {\n\t\t\t\t\tdata: undefined,\n\t\t\t\t}),\n\t\t\t\tbinary: {\n\t\t\t\t\t[binaryPropertyOutput]: binaryData,\n\t\t\t\t},\n\t\t\t\tpairedItem: { item: i },\n\t\t\t});\n\t\t}\n\n\t\treturn returnData;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAqC;AAErC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SA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AACtD,MAAI,kBAAkB;AACtB,MAAI,uBAAuB;AAE3B,MAAI,QAAQ,iBAAiB;AAC5B,sBAAkB;AAAA,EACnB;AAEA,MAAI,QAAQ,sBAAsB;AACjC,2BAAuB,QAAQ;AAC/B,WAAO,QAAQ;AAAA,EAChB;AAEA,MAAI,QAAQ,cAAc;AACzB,YAAQ,UAAU,QAAQ;AAC1B,WAAO,QAAQ;AAAA,EAChB;AAEA,SAAO,QAAQ;AACf,QAAM,OAAoB;AAAA,IACzB;AAAA,IACA;AAAA,IACA,iBAAiB,UAAU,gBAAgB,kBAAkB;AAAA;AAAA,IAC7D,GAAG;AAAA,EACJ;AAEA,QAAM,EAAE,KAAK,IAAI,MAAM,4BAAW,KAAK,MAAM,QAAQ,uBAAuB,EAAE,KAAK,CAAC;AACpF,MAAI,oBAAoB,OAAO;AAC9B,YAAS,QAA0B,CAAC,GAAG,IAAI,CAAC,WAAW;AAAA,MACtD,MAAM;AAAA,MACN,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB,EAAE;AAAA,EACH,OAAO;AACN,UAAM,aAAmC,CAAC;AAE1C,eAAW,SAAS,MAAM;AACzB,YAAM,aAAa,MAAM,KAAK,QAAQ;AAAA,QACrC,OAAO,KAAK,MAAM,UAAoB,QAAQ;AAAA,QAC9C;AAAA,MACD;AACA,iBAAW,KAAK;AAAA,QACf,MAAM,OAAO,OAAO,CAAC,GAAG,YAAY;AAAA,UACnC,MAAM;AAAA,QACP,CAAC;AAAA,QACD,QAAQ;AAAA,UACP,CAAC,oBAAoB,GAAG;AAAA,QACzB;AAAA,QACA,YAAY,EAAE,MAAM,EAAE;AAAA,MACvB,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;","names":[]}
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {"name":"anthropicApi","displayName":"Anthropic","documentationUrl":"anthropic","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Base URL","name":"url","type":"string","default":"https://api.anthropic.com","description":"Override the default base URL for the API"}],"authenticate":{"type":"generic","properties":{"headers":{"x-api-key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{$credentials?.url}}","url":"/v1/messages","method":"POST","headers":{"anthropic-version":"2023-06-01"},"body":{"model":"claude-3-haiku-20240307","messages":[{"role":"user","content":"Hey"}],"max_tokens":1}}},"supportedNodes":["lmChatAnthropic"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LMChatAnthropic/anthropic.svg"},
3
3
  {"name":"azureOpenAiApi","displayName":"Azure Open AI","documentationUrl":"azureopenai","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Resource Name","name":"resourceName","type":"string","required":true,"default":""},{"displayName":"API Version","name":"apiVersion","type":"string","required":true,"default":"2025-03-01-preview"},{"displayName":"Endpoint","name":"endpoint","type":"string","placeholder":"https://westeurope.api.cognitive.microsoft.com"}],"authenticate":{"type":"generic","properties":{"headers":{"api-key":"={{$credentials.apiKey}}"}}},"supportedNodes":["embeddingsAzureOpenAi","lmChatAzureOpenAi"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsAzureOpenAi/azure.svg"},
4
- {"name":"azureEntraCognitiveServicesOAuth2Api","displayName":"Azure Entra ID (Azure Active Directory) API","extends":["oAuth2Api"],"documentationUrl":"azureEntraCognitiveServicesOAuth2Api","properties":[{"displayName":"Grant Type","name":"grantType","type":"hidden","default":"authorizationCode"},{"displayName":"Resource Name","name":"resourceName","type":"string","required":true,"default":""},{"displayName":"API Version","name":"apiVersion","type":"string","required":true,"default":"2025-03-01-preview"},{"displayName":"Endpoint","name":"endpoint","type":"string","placeholder":"https://westeurope.api.cognitive.microsoft.com"},{"displayName":"Tenant ID","name":"tenantId","type":"string","default":"common","description":"Enter your Azure Tenant ID (Directory ID) or keep \"common\" for multi-tenant apps. Using a specific Tenant ID is generally recommended and required for certain authentication flows.","placeholder":"e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or common"},{"displayName":"Authorization URL","name":"authUrl","type":"string","default":"https://login.microsoftonline.com/$TENANT_ID/oauth2/authorize"},{"displayName":"Access Token URL","name":"accessTokenUrl","type":"string","default":"https://login.microsoftonline.com/$TENANT_ID/oauth2/token"},{"displayName":"Client ID","name":"clientId","type":"string","required":true,"default":"","description":"Client ID obtained from the Azure AD App Registration"},{"displayName":"Client Secret","name":"clientSecret","type":"string","required":true,"typeOptions":{"password":true},"default":"","description":"Client Secret obtained from the Azure AD App Registration"},{"displayName":"Additional Body Properties","name":"additionalBodyProperties","type":"hidden","default":"{\"grant_type\": \"client_credentials\", \"resource\": \"https://cognitiveservices.azure.com/\"}"},{"displayName":"Authentication","name":"authentication","type":"hidden","default":"body"},{"displayName":"Custom Scopes","name":"customScopes","type":"boolean","default":false,"description":"Define custom scopes. You might need this if the default scopes are not sufficient or if you want to minimize permissions. Ensure you include \"openid\" and \"offline_access\"."},{"displayName":"Auth URI Query Parameters","name":"authQueryParameters","type":"hidden","default":"","description":"For some services additional query parameters have to be set which can be defined here","placeholder":""},{"displayName":"Enabled Scopes","name":"enabledScopes","type":"string","displayOptions":{"show":{"customScopes":[true]}},"default":"openid offline_access","placeholder":"openid offline_access","description":"Space-separated list of scopes to request."},{"displayName":"Scope","name":"scope","type":"hidden","default":"={{ $self.customScopes ? $self.enabledScopes : \"openid offline_access\"}}"}],"supportedNodes":["lmChatAzureOpenAi"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatAzureOpenAi/azure.svg"},
4
+ {"name":"azureEntraCognitiveServicesOAuth2Api","displayName":"Azure Entra ID (Azure Active Directory) API","extends":["oAuth2Api"],"documentationUrl":"azureEntraCognitiveServicesOAuth2Api","properties":[{"displayName":"Grant Type","name":"grantType","type":"hidden","default":"authorizationCode"},{"displayName":"Resource Name","name":"resourceName","type":"string","required":true,"default":""},{"displayName":"API Version","name":"apiVersion","type":"string","required":true,"default":"2025-03-01-preview"},{"displayName":"Endpoint","name":"endpoint","type":"string","placeholder":"https://westeurope.api.cognitive.microsoft.com"},{"displayName":"Tenant ID","name":"tenantId","type":"string","default":"common","description":"Enter your Azure Tenant ID (Directory ID) or keep \"common\" for multi-tenant apps. Using a specific Tenant ID is generally recommended and required for certain authentication flows.","placeholder":"e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or common"},{"displayName":"Authorization URL","name":"authUrl","type":"hidden","default":"=https://login.microsoftonline.com/{{$self[\"tenantId\"]}}/oauth2/authorize"},{"displayName":"Access Token URL","name":"accessTokenUrl","type":"hidden","default":"=https://login.microsoftonline.com/{{$self[\"tenantId\"]}}/oauth2/token"},{"displayName":"Additional Body Properties","name":"additionalBodyProperties","type":"hidden","default":"{\"grant_type\": \"client_credentials\", \"resource\": \"https://cognitiveservices.azure.com/\"}"},{"displayName":"Authentication","name":"authentication","type":"hidden","default":"body"},{"displayName":"Custom Scopes","name":"customScopes","type":"boolean","default":false,"description":"Define custom scopes. You might need this if the default scopes are not sufficient or if you want to minimize permissions. Ensure you include \"openid\" and \"offline_access\"."},{"displayName":"Auth URI Query Parameters","name":"authQueryParameters","type":"hidden","default":"","description":"For some services additional query parameters have to be set which can be defined here","placeholder":""},{"displayName":"Enabled Scopes","name":"enabledScopes","type":"string","displayOptions":{"show":{"customScopes":[true]}},"default":"openid offline_access","placeholder":"openid offline_access","description":"Space-separated list of scopes to request."},{"displayName":"Scope","name":"scope","type":"hidden","default":"={{ $self.customScopes ? $self.enabledScopes : \"openid offline_access\"}}"}],"supportedNodes":["lmChatAzureOpenAi"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatAzureOpenAi/azure.svg"},
5
5
  {"name":"cohereApi","displayName":"CohereApi","documentationUrl":"cohere","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://api.cohere.ai","url":"/v1/models?page_size=1"}},"supportedNodes":["embeddingsCohere","lmCohere"],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsCohere/cohere.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsCohere/cohere.dark.svg"}},
6
6
  {"name":"deepSeekApi","displayName":"DeepSeek","documentationUrl":"deepseek","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Base URL","name":"url","type":"hidden","default":"https://api.deepseek.com"}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{ $credentials.url }}","url":"/models"}},"supportedNodes":["lmChatDeepSeek"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatDeepSeek/deepseek.svg"},
7
7
  {"name":"googlePalmApi","displayName":"Google Gemini(PaLM) Api","documentationUrl":"google","properties":[{"displayName":"Host","name":"host","required":true,"type":"string","default":"https://generativelanguage.googleapis.com"},{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"qs":{"key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{$credentials.host}}/v1beta/models"}},"supportedNodes":["embeddingsGoogleGemini","lmChatGoogleGemini"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsGoogleGemini/google.svg"},