@n8n/n8n-nodes-langchain 1.109.1 → 1.110.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.
@@ -22,12 +22,15 @@ __export(VectorStoreMongoDBAtlas_node_exports, {
22
22
  METADATA_FIELD_NAME: () => METADATA_FIELD_NAME,
23
23
  MONGODB_COLLECTION_NAME: () => MONGODB_COLLECTION_NAME,
24
24
  MONGODB_CREDENTIALS: () => MONGODB_CREDENTIALS,
25
+ POST_FILTER_NAME: () => POST_FILTER_NAME,
26
+ PRE_FILTER_NAME: () => PRE_FILTER_NAME,
25
27
  VECTOR_INDEX_NAME: () => VECTOR_INDEX_NAME,
26
28
  VectorStoreMongoDBAtlas: () => VectorStoreMongoDBAtlas,
27
29
  getCollectionName: () => getCollectionName,
28
30
  getCollections: () => getCollections,
29
31
  getDatabase: () => getDatabase,
30
32
  getEmbeddingFieldName: () => getEmbeddingFieldName,
33
+ getFilterValue: () => getFilterValue,
31
34
  getMetadataFieldName: () => getMetadataFieldName,
32
35
  getMongoClient: () => getMongoClient,
33
36
  getParameter: () => getParameter,
@@ -40,9 +43,16 @@ var import_mongodb2 = require("mongodb");
40
43
  var import_n8n_workflow = require("n8n-workflow");
41
44
  var import_sharedFields = require("../../../utils/sharedFields");
42
45
  var import_createVectorStoreNode = require("../shared/createVectorStoreNode/createVectorStoreNode");
46
+ const MONGODB_CREDENTIALS = "mongoDb";
47
+ const MONGODB_COLLECTION_NAME = "mongoCollection";
48
+ const VECTOR_INDEX_NAME = "vectorIndexName";
49
+ const EMBEDDING_NAME = "embedding";
50
+ const METADATA_FIELD_NAME = "metadata_field";
51
+ const PRE_FILTER_NAME = "preFilter";
52
+ const POST_FILTER_NAME = "postFilterPipeline";
43
53
  const mongoCollectionRLC = {
44
54
  displayName: "MongoDB Collection",
45
- name: "mongoCollection",
55
+ name: MONGODB_COLLECTION_NAME,
46
56
  type: "resourceLocator",
47
57
  default: { mode: "list", value: "" },
48
58
  required: true,
@@ -66,7 +76,7 @@ const mongoCollectionRLC = {
66
76
  };
67
77
  const vectorIndexName = {
68
78
  displayName: "Vector Index Name",
69
- name: "vectorIndexName",
79
+ name: VECTOR_INDEX_NAME,
70
80
  type: "string",
71
81
  default: "",
72
82
  description: "The name of the vector index",
@@ -74,7 +84,7 @@ const vectorIndexName = {
74
84
  };
75
85
  const embeddingField = {
76
86
  displayName: "Embedding",
77
- name: "embedding",
87
+ name: EMBEDDING_NAME,
78
88
  type: "string",
79
89
  default: "embedding",
80
90
  description: "The field with the embedding array",
@@ -82,7 +92,7 @@ const embeddingField = {
82
92
  };
83
93
  const metadataField = {
84
94
  displayName: "Metadata Field",
85
- name: "metadata_field",
95
+ name: METADATA_FIELD_NAME,
86
96
  type: "string",
87
97
  default: "text",
88
98
  description: "The text field of the raw data",
@@ -101,6 +111,32 @@ const mongoNamespaceField = {
101
111
  description: "Logical partition for documents. Uses metadata.namespace field for filtering.",
102
112
  default: ""
103
113
  };
114
+ const preFilterField = {
115
+ displayName: "Pre Filter",
116
+ name: PRE_FILTER_NAME,
117
+ type: "json",
118
+ typeOptions: {
119
+ alwaysOpenEditWindow: true
120
+ },
121
+ default: "",
122
+ placeholder: '{ "key": "value" }',
123
+ hint: 'This is a filter applied in the $vectorSearch stage <a href="https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#atlas-vector-search-pre-filter">here</a>',
124
+ required: true,
125
+ description: "MongoDB Atlas Vector Search pre-filter"
126
+ };
127
+ const postFilterField = {
128
+ displayName: "Post Filter Pipeline",
129
+ name: POST_FILTER_NAME,
130
+ type: "json",
131
+ typeOptions: {
132
+ alwaysOpenEditWindow: true
133
+ },
134
+ default: "",
135
+ placeholder: '[{ "$match": { "$gt": "1950-01-01" }, ... }]',
136
+ hint: 'Learn more about aggregation pipeline <a href="https://docs.mongodb.com/manual/core/aggregation-pipeline/">here</a>',
137
+ required: true,
138
+ description: "MongoDB aggregation pipeline in JSON format"
139
+ };
104
140
  const retrieveFields = [
105
141
  {
106
142
  displayName: "Options",
@@ -108,7 +144,7 @@ const retrieveFields = [
108
144
  type: "collection",
109
145
  placeholder: "Add Option",
110
146
  default: {},
111
- options: [mongoNamespaceField, import_sharedFields.metadataFilterField]
147
+ options: [mongoNamespaceField, import_sharedFields.metadataFilterField, preFilterField, postFilterField]
112
148
  }
113
149
  ];
114
150
  const insertFields = [
@@ -132,23 +168,24 @@ const insertFields = [
132
168
  ];
133
169
  const mongoConfig = {
134
170
  client: null,
135
- connectionString: ""
171
+ connectionString: "",
172
+ nodeVersion: 0
136
173
  };
137
- const MONGODB_CREDENTIALS = "mongoDb";
138
- const MONGODB_COLLECTION_NAME = "mongoCollection";
139
- const VECTOR_INDEX_NAME = "vectorIndexName";
140
- const EMBEDDING_NAME = "embedding";
141
- const METADATA_FIELD_NAME = "metadata_field";
142
- async function getMongoClient(context) {
174
+ async function getMongoClient(context, version) {
143
175
  const credentials = await context.getCredentials(MONGODB_CREDENTIALS);
144
176
  const connectionString = credentials.connectionString;
145
- if (!mongoConfig.client || mongoConfig.connectionString !== connectionString) {
177
+ if (!mongoConfig.client || mongoConfig.connectionString !== connectionString || mongoConfig.nodeVersion !== version) {
146
178
  if (mongoConfig.client) {
147
179
  await mongoConfig.client.close();
148
180
  }
149
181
  mongoConfig.connectionString = connectionString;
182
+ mongoConfig.nodeVersion = version;
150
183
  mongoConfig.client = new import_mongodb2.MongoClient(connectionString, {
151
- appName: "devrel.integration.n8n_vector_integ"
184
+ appName: "devrel.integration.n8n_vector_integ",
185
+ driverInfo: {
186
+ name: "n8n_vector",
187
+ version: version.toString()
188
+ }
152
189
  });
153
190
  await mongoConfig.client.connect();
154
191
  }
@@ -160,7 +197,7 @@ async function getDatabase(context, client) {
160
197
  }
161
198
  async function getCollections() {
162
199
  try {
163
- const client = await getMongoClient(this);
200
+ const client = await getMongoClient(this, this.getNode().typeVersion);
164
201
  const db = await getDatabase(this, client);
165
202
  const collections = await db.listCollections().toArray();
166
203
  const results = collections.map((collection) => ({
@@ -185,6 +222,40 @@ const getCollectionName = getParameter.bind(null, MONGODB_COLLECTION_NAME);
185
222
  const getVectorIndexName = getParameter.bind(null, VECTOR_INDEX_NAME);
186
223
  const getEmbeddingFieldName = getParameter.bind(null, EMBEDDING_NAME);
187
224
  const getMetadataFieldName = getParameter.bind(null, METADATA_FIELD_NAME);
225
+ function getFilterValue(name, context, itemIndex) {
226
+ const options = context.getNodeParameter("options", itemIndex, {});
227
+ if (options[name]) {
228
+ if (typeof options[name] === "string") {
229
+ try {
230
+ return JSON.parse(options[name]);
231
+ } catch (error) {
232
+ throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Error: ${error.message}`, {
233
+ itemIndex,
234
+ description: `Could not parse JSON for ${name}`
235
+ });
236
+ }
237
+ }
238
+ throw new import_n8n_workflow.NodeOperationError(context.getNode(), "Error: No JSON string provided.", {
239
+ itemIndex,
240
+ description: `Could not parse JSON for ${name}`
241
+ });
242
+ }
243
+ return void 0;
244
+ }
245
+ class ExtendedMongoDBAtlasVectorSearch extends import_mongodb.MongoDBAtlasVectorSearch {
246
+ constructor(embeddings, options, preFilter, postFilterPipeline) {
247
+ super(embeddings, options);
248
+ this.preFilter = preFilter;
249
+ this.postFilterPipeline = postFilterPipeline;
250
+ }
251
+ async similaritySearchVectorWithScore(query, k) {
252
+ const mergedFilter = {
253
+ preFilter: this.preFilter,
254
+ postFilterPipeline: this.postFilterPipeline
255
+ };
256
+ return await super.similaritySearchVectorWithScore(query, k, mergedFilter);
257
+ }
258
+ }
188
259
  class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVectorStoreNode)({
189
260
  meta: {
190
261
  displayName: "MongoDB Atlas Vector Store",
@@ -207,7 +278,7 @@ class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVec
207
278
  sharedFields,
208
279
  async getVectorStoreClient(context, _filter, embeddings, itemIndex) {
209
280
  try {
210
- const client = await getMongoClient(context);
281
+ const client = await getMongoClient(context, context.getNode().typeVersion);
211
282
  const db = await getDatabase(context, client);
212
283
  const collectionName = getCollectionName(context, itemIndex);
213
284
  const mongoVectorIndexName = getVectorIndexName(context, itemIndex);
@@ -222,15 +293,26 @@ class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVec
222
293
  description: "Please check that the index exists in your collection"
223
294
  });
224
295
  }
225
- return new import_mongodb.MongoDBAtlasVectorSearch(embeddings, {
226
- collection,
227
- indexName: mongoVectorIndexName,
228
- // Default index name
229
- textKey: metadataFieldName,
230
- // Field containing raw text
231
- embeddingKey: embeddingFieldName
232
- // Field containing embeddings
233
- });
296
+ const preFilter = getFilterValue(PRE_FILTER_NAME, context, itemIndex);
297
+ const postFilterPipeline = getFilterValue(
298
+ POST_FILTER_NAME,
299
+ context,
300
+ itemIndex
301
+ );
302
+ return new ExtendedMongoDBAtlasVectorSearch(
303
+ embeddings,
304
+ {
305
+ collection,
306
+ indexName: mongoVectorIndexName,
307
+ // Default index name
308
+ textKey: metadataFieldName,
309
+ // Field containing raw text
310
+ embeddingKey: embeddingFieldName
311
+ // Field containing embeddings
312
+ },
313
+ preFilter ?? {},
314
+ postFilterPipeline
315
+ );
234
316
  } catch (error) {
235
317
  if (error instanceof import_n8n_workflow.NodeOperationError) {
236
318
  throw error;
@@ -243,7 +325,7 @@ class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVec
243
325
  },
244
326
  async populateVectorStore(context, embeddings, documents, itemIndex) {
245
327
  try {
246
- const client = await getMongoClient(context);
328
+ const client = await getMongoClient(context, context.getNode().typeVersion);
247
329
  const db = await getDatabase(context, client);
248
330
  const collectionName = getCollectionName(context, itemIndex);
249
331
  const mongoVectorIndexName = getVectorIndexName(context, itemIndex);
@@ -254,7 +336,7 @@ class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVec
254
336
  await db.createCollection(collectionName);
255
337
  }
256
338
  const collection = db.collection(collectionName);
257
- await import_mongodb.MongoDBAtlasVectorSearch.fromDocuments(documents, embeddings, {
339
+ await ExtendedMongoDBAtlasVectorSearch.fromDocuments(documents, embeddings, {
258
340
  collection,
259
341
  indexName: mongoVectorIndexName,
260
342
  // Default index name
@@ -278,12 +360,15 @@ class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVec
278
360
  METADATA_FIELD_NAME,
279
361
  MONGODB_COLLECTION_NAME,
280
362
  MONGODB_CREDENTIALS,
363
+ POST_FILTER_NAME,
364
+ PRE_FILTER_NAME,
281
365
  VECTOR_INDEX_NAME,
282
366
  VectorStoreMongoDBAtlas,
283
367
  getCollectionName,
284
368
  getCollections,
285
369
  getDatabase,
286
370
  getEmbeddingFieldName,
371
+ getFilterValue,
287
372
  getMetadataFieldName,
288
373
  getMongoClient,
289
374
  getParameter,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts"],"sourcesContent":["import { MongoDBAtlasVectorSearch } from '@langchain/mongodb';\nimport { MongoClient } from 'mongodb';\nimport {\n\ttype ILoadOptionsFunctions,\n\tNodeOperationError,\n\ttype INodeProperties,\n\ttype IExecuteFunctions,\n\ttype ISupplyDataFunctions,\n} from 'n8n-workflow';\nimport { metadataFilterField } from '@utils/sharedFields';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\n\nconst mongoCollectionRLC: INodeProperties = {\n\tdisplayName: 'MongoDB Collection',\n\tname: 'mongoCollection',\n\ttype: 'resourceLocator',\n\tdefault: { mode: 'list', value: '' },\n\trequired: true,\n\tmodes: [\n\t\t{\n\t\t\tdisplayName: 'From List',\n\t\t\tname: 'list',\n\t\t\ttype: 'list',\n\t\t\ttypeOptions: {\n\t\t\t\tsearchListMethod: 'mongoCollectionSearch', // Method to fetch collections\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Name',\n\t\t\tname: 'name',\n\t\t\ttype: 'string',\n\t\t\tplaceholder: 'e.g. my_collection',\n\t\t},\n\t],\n};\n\nconst vectorIndexName: INodeProperties = {\n\tdisplayName: 'Vector Index Name',\n\tname: 'vectorIndexName',\n\ttype: 'string',\n\tdefault: '',\n\tdescription: 'The name of the vector index',\n\trequired: true,\n};\n\nconst embeddingField: INodeProperties = {\n\tdisplayName: 'Embedding',\n\tname: 'embedding',\n\ttype: 'string',\n\tdefault: 'embedding',\n\tdescription: 'The field with the embedding array',\n\trequired: true,\n};\n\nconst metadataField: INodeProperties = {\n\tdisplayName: 'Metadata Field',\n\tname: 'metadata_field',\n\ttype: 'string',\n\tdefault: 'text',\n\tdescription: 'The text field of the raw data',\n\trequired: true,\n};\n\nconst sharedFields: INodeProperties[] = [\n\tmongoCollectionRLC,\n\tembeddingField,\n\tmetadataField,\n\tvectorIndexName,\n];\n\nconst mongoNamespaceField: INodeProperties = {\n\tdisplayName: 'Namespace',\n\tname: 'namespace',\n\ttype: 'string',\n\tdescription: 'Logical partition for documents. Uses metadata.namespace field for filtering.',\n\tdefault: '',\n};\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [mongoNamespaceField, metadataFilterField],\n\t},\n];\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Clear Namespace',\n\t\t\t\tname: 'clearNamespace',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to clear documents in the namespace before inserting new data',\n\t\t\t},\n\t\t\tmongoNamespaceField,\n\t\t],\n\t},\n];\n\nexport const mongoConfig = {\n\tclient: null as MongoClient | null,\n\tconnectionString: '',\n};\n\n/**\n * Constants for the name of the credentials and Node parameters.\n */\nexport const MONGODB_CREDENTIALS = 'mongoDb';\nexport const MONGODB_COLLECTION_NAME = 'mongoCollection';\nexport const VECTOR_INDEX_NAME = 'vectorIndexName';\nexport const EMBEDDING_NAME = 'embedding';\nexport const METADATA_FIELD_NAME = 'metadata_field';\n\n/**\n * Type used for cleaner, more intentional typing.\n */\ntype IFunctionsContext = IExecuteFunctions | ISupplyDataFunctions | ILoadOptionsFunctions;\n\n/**\n * Get the mongo client.\n * @param context - The context.\n * @returns the MongoClient for the node.\n */\nexport async function getMongoClient(context: any) {\n\tconst credentials = await context.getCredentials(MONGODB_CREDENTIALS);\n\tconst connectionString = credentials.connectionString as string;\n\tif (!mongoConfig.client || mongoConfig.connectionString !== connectionString) {\n\t\tif (mongoConfig.client) {\n\t\t\tawait mongoConfig.client.close();\n\t\t}\n\n\t\tmongoConfig.connectionString = connectionString;\n\t\tmongoConfig.client = new MongoClient(connectionString, {\n\t\t\tappName: 'devrel.integration.n8n_vector_integ',\n\t\t});\n\t\tawait mongoConfig.client.connect();\n\t}\n\treturn mongoConfig.client;\n}\n\n/**\n * Get the database object from the MongoClient by the configured name.\n * @param context - The context.\n * @returns the Db object.\n */\nexport async function getDatabase(context: IFunctionsContext, client: MongoClient) {\n\tconst credentials = await context.getCredentials(MONGODB_CREDENTIALS);\n\treturn client.db(credentials.database as string);\n}\n\n/**\n * Get all the collection in the database.\n * @param this The load options context.\n * @returns The list of collections.\n */\nexport async function getCollections(this: ILoadOptionsFunctions) {\n\ttry {\n\t\tconst client = await getMongoClient(this);\n\t\tconst db = await getDatabase(this, client);\n\t\tconst collections = await db.listCollections().toArray();\n\t\tconst results = collections.map((collection) => ({\n\t\t\tname: collection.name,\n\t\t\tvalue: collection.name,\n\t\t}));\n\n\t\treturn { results };\n\t} catch (error) {\n\t\tthrow new NodeOperationError(this.getNode(), `Error: ${error.message}`);\n\t}\n}\n\n/**\n * Get a parameter from the context.\n * @param key - The key of the parameter.\n * @param context - The context.\n * @param itemIndex - The index.\n * @returns The value.\n */\nexport function getParameter(key: string, context: IFunctionsContext, itemIndex: number): string {\n\tconst value = context.getNodeParameter(key, itemIndex, '', {\n\t\textractValue: true,\n\t}) as string;\n\tif (typeof value !== 'string') {\n\t\tthrow new NodeOperationError(context.getNode(), `Parameter ${key} must be a string`);\n\t}\n\treturn value;\n}\n\nexport const getCollectionName = getParameter.bind(null, MONGODB_COLLECTION_NAME);\nexport const getVectorIndexName = getParameter.bind(null, VECTOR_INDEX_NAME);\nexport const getEmbeddingFieldName = getParameter.bind(null, EMBEDDING_NAME);\nexport const getMetadataFieldName = getParameter.bind(null, METADATA_FIELD_NAME);\n\nexport class VectorStoreMongoDBAtlas extends createVectorStoreNode({\n\tmeta: {\n\t\tdisplayName: 'MongoDB Atlas Vector Store',\n\t\tname: 'vectorStoreMongoDBAtlas',\n\t\tdescription: 'Work with your data in MongoDB Atlas Vector Store',\n\t\ticon: { light: 'file:mongodb.svg', dark: 'file:mongodb.dark.svg' },\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoremongodbatlas/',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'mongoDb',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\toperationModes: ['load', 'insert', 'retrieve', 'update', 'retrieve-as-tool'],\n\t},\n\tmethods: { listSearch: { mongoCollectionSearch: getCollections } },\n\tretrieveFields,\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {\n\t\ttry {\n\t\t\tconst client = await getMongoClient(context);\n\t\t\tconst db = await getDatabase(context, client);\n\t\t\tconst collectionName = getCollectionName(context, itemIndex);\n\t\t\tconst mongoVectorIndexName = getVectorIndexName(context, itemIndex);\n\t\t\tconst embeddingFieldName = getEmbeddingFieldName(context, itemIndex);\n\t\t\tconst metadataFieldName = getMetadataFieldName(context, itemIndex);\n\n\t\t\tconst collection = db.collection(collectionName);\n\n\t\t\t// test index exists\n\t\t\tconst indexes = await collection.listSearchIndexes().toArray();\n\n\t\t\tconst indexExists = indexes.some((index) => index.name === mongoVectorIndexName);\n\n\t\t\tif (!indexExists) {\n\t\t\t\tthrow new NodeOperationError(context.getNode(), `Index ${mongoVectorIndexName} not found`, {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription: 'Please check that the index exists in your collection',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn new MongoDBAtlasVectorSearch(embeddings, {\n\t\t\t\tcollection,\n\t\t\t\tindexName: mongoVectorIndexName, // Default index name\n\t\t\t\ttextKey: metadataFieldName, // Field containing raw text\n\t\t\t\tembeddingKey: embeddingFieldName, // Field containing embeddings\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof NodeOperationError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t});\n\t\t}\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\ttry {\n\t\t\tconst client = await getMongoClient(context);\n\t\t\tconst db = await getDatabase(context, client);\n\t\t\tconst collectionName = getCollectionName(context, itemIndex);\n\t\t\tconst mongoVectorIndexName = getVectorIndexName(context, itemIndex);\n\t\t\tconst embeddingFieldName = getEmbeddingFieldName(context, itemIndex);\n\t\t\tconst metadataFieldName = getMetadataFieldName(context, itemIndex);\n\n\t\t\t// Check if collection exists\n\t\t\tconst collections = await db.listCollections({ name: collectionName }).toArray();\n\t\t\tif (collections.length === 0) {\n\t\t\t\tawait db.createCollection(collectionName);\n\t\t\t}\n\t\t\tconst collection = db.collection(collectionName);\n\t\t\tawait MongoDBAtlasVectorSearch.fromDocuments(documents, embeddings, {\n\t\t\t\tcollection,\n\t\t\t\tindexName: mongoVectorIndexName, // Default index name\n\t\t\t\ttextKey: metadataFieldName, // Field containing raw text\n\t\t\t\tembeddingKey: embeddingFieldName, // Field containing embeddings\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t});\n\t\t}\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyC;AACzC,IAAAA,kBAA4B;AAC5B,0BAMO;AACP,0BAAoC;AAEpC,mCAAsC;AAEtC,MAAM,qBAAsC;AAAA,EAC3C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS,EAAE,MAAM,QAAQ,OAAO,GAAG;AAAA,EACnC,UAAU;AAAA,EACV,OAAO;AAAA,IACN;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,QACZ,kBAAkB;AAAA;AAAA,MACnB;AAAA,IACD;AAAA,IACA;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACd;AAAA,EACD;AACD;AAEA,MAAM,kBAAmC;AAAA,EACxC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AACX;AAEA,MAAM,iBAAkC;AAAA,EACvC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AACX;AAEA,MAAM,gBAAiC;AAAA,EACtC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AACX;AAEA,MAAM,eAAkC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;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BAAmB,SAAS,SAAS;AAClE,YAAM,qBAAqB,sBAAsB,SAAS,SAAS;AACnE,YAAM,oBAAoB,qBAAqB,SAAS,SAAS;AAGjE,YAAM,cAAc,MAAM,GAAG,gBAAgB,EAAE,MAAM,eAAe,CAAC,EAAE,QAAQ;AAC/E,UAAI,YAAY,WAAW,GAAG;AAC7B,cAAM,GAAG,iBAAiB,cAAc;AAAA,MACzC;AACA,YAAM,aAAa,GAAG,WAAW,cAAc;AAC/C,YAAM,wCAAyB,cAAc,WAAW,YAAY;AAAA,QACnE;AAAA,QACA,WAAW;AAAA;AAAA,QACX,SAAS;AAAA;AAAA,QACT,cAAc;AAAA;AAAA,MACf,CAAC;AAAA,IACF,SAAS,OAAO;AACf,YAAM,IAAI,uCAAmB,QAAQ,QAAQ,GAAG,UAAU,MAAM,OAAO,IAAI;AAAA,QAC1E;AAAA,QACA,aAAa;AAAA,MACd,CAAC;AAAA,IACF;AAAA,EACD;AACD,CAAC,EAAE;AAAC;","names":["import_mongodb"]}
1
+ {"version":3,"sources":["../../../../nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts"],"sourcesContent":["import type { EmbeddingsInterface } from '@langchain/core/embeddings';\nimport { MongoDBAtlasVectorSearch, type MongoDBAtlasVectorSearchLibArgs } from '@langchain/mongodb';\nimport { MongoClient } from 'mongodb';\nimport {\n\ttype IDataObject,\n\ttype ILoadOptionsFunctions,\n\tNodeOperationError,\n\ttype INodeProperties,\n\ttype IExecuteFunctions,\n\ttype ISupplyDataFunctions,\n} from 'n8n-workflow';\nimport { metadataFilterField } from '@utils/sharedFields';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\n\n/**\n * Constants for the name of the credentials and Node parameters.\n */\nexport const MONGODB_CREDENTIALS = 'mongoDb';\nexport const MONGODB_COLLECTION_NAME = 'mongoCollection';\nexport const VECTOR_INDEX_NAME = 'vectorIndexName';\nexport const EMBEDDING_NAME = 'embedding';\nexport const METADATA_FIELD_NAME = 'metadata_field';\nexport const PRE_FILTER_NAME = 'preFilter';\nexport const POST_FILTER_NAME = 'postFilterPipeline';\n\nconst mongoCollectionRLC: INodeProperties = {\n\tdisplayName: 'MongoDB Collection',\n\tname: MONGODB_COLLECTION_NAME,\n\ttype: 'resourceLocator',\n\tdefault: { mode: 'list', value: '' },\n\trequired: true,\n\tmodes: [\n\t\t{\n\t\t\tdisplayName: 'From List',\n\t\t\tname: 'list',\n\t\t\ttype: 'list',\n\t\t\ttypeOptions: {\n\t\t\t\tsearchListMethod: 'mongoCollectionSearch', // Method to fetch collections\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Name',\n\t\t\tname: 'name',\n\t\t\ttype: 'string',\n\t\t\tplaceholder: 'e.g. my_collection',\n\t\t},\n\t],\n};\n\nconst vectorIndexName: INodeProperties = {\n\tdisplayName: 'Vector Index Name',\n\tname: VECTOR_INDEX_NAME,\n\ttype: 'string',\n\tdefault: '',\n\tdescription: 'The name of the vector index',\n\trequired: true,\n};\n\nconst embeddingField: INodeProperties = {\n\tdisplayName: 'Embedding',\n\tname: EMBEDDING_NAME,\n\ttype: 'string',\n\tdefault: 'embedding',\n\tdescription: 'The field with the embedding array',\n\trequired: true,\n};\n\nconst metadataField: INodeProperties = {\n\tdisplayName: 'Metadata Field',\n\tname: METADATA_FIELD_NAME,\n\ttype: 'string',\n\tdefault: 'text',\n\tdescription: 'The text field of the raw data',\n\trequired: true,\n};\n\nconst sharedFields: INodeProperties[] = [\n\tmongoCollectionRLC,\n\tembeddingField,\n\tmetadataField,\n\tvectorIndexName,\n];\n\nconst mongoNamespaceField: INodeProperties = {\n\tdisplayName: 'Namespace',\n\tname: 'namespace',\n\ttype: 'string',\n\tdescription: 'Logical partition for documents. Uses metadata.namespace field for filtering.',\n\tdefault: '',\n};\n\nconst preFilterField: INodeProperties = {\n\tdisplayName: 'Pre Filter',\n\tname: PRE_FILTER_NAME,\n\ttype: 'json',\n\ttypeOptions: {\n\t\talwaysOpenEditWindow: true,\n\t},\n\tdefault: '',\n\tplaceholder: '{ \"key\": \"value\" }',\n\thint: 'This is a filter applied in the $vectorSearch stage <a href=\"https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#atlas-vector-search-pre-filter\">here</a>',\n\trequired: true,\n\tdescription: 'MongoDB Atlas Vector Search pre-filter',\n};\n\nconst postFilterField: INodeProperties = {\n\tdisplayName: 'Post Filter Pipeline',\n\tname: POST_FILTER_NAME,\n\ttype: 'json',\n\ttypeOptions: {\n\t\talwaysOpenEditWindow: true,\n\t},\n\tdefault: '',\n\tplaceholder: '[{ \"$match\": { \"$gt\": \"1950-01-01\" }, ... }]',\n\thint: 'Learn more about aggregation pipeline <a href=\"https://docs.mongodb.com/manual/core/aggregation-pipeline/\">here</a>',\n\trequired: true,\n\tdescription: 'MongoDB aggregation pipeline in JSON format',\n};\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [mongoNamespaceField, metadataFilterField, preFilterField, postFilterField],\n\t},\n];\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Clear Namespace',\n\t\t\t\tname: 'clearNamespace',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to clear documents in the namespace before inserting new data',\n\t\t\t},\n\t\t\tmongoNamespaceField,\n\t\t],\n\t},\n];\n\nexport const mongoConfig = {\n\tclient: null as MongoClient | null,\n\tconnectionString: '',\n\tnodeVersion: 0,\n};\n\n/**\n * Type used for cleaner, more intentional typing.\n */\ntype IFunctionsContext = IExecuteFunctions | ISupplyDataFunctions | ILoadOptionsFunctions;\n\n/**\n * Get the mongo client.\n * @param context - The context.\n * @returns the MongoClient for the node.\n */\nexport async function getMongoClient(context: any, version: number) {\n\tconst credentials = await context.getCredentials(MONGODB_CREDENTIALS);\n\tconst connectionString = credentials.connectionString as string;\n\tif (\n\t\t!mongoConfig.client ||\n\t\tmongoConfig.connectionString !== connectionString ||\n\t\tmongoConfig.nodeVersion !== version\n\t) {\n\t\tif (mongoConfig.client) {\n\t\t\tawait mongoConfig.client.close();\n\t\t}\n\n\t\tmongoConfig.connectionString = connectionString;\n\t\tmongoConfig.nodeVersion = version;\n\t\tmongoConfig.client = new MongoClient(connectionString, {\n\t\t\tappName: 'devrel.integration.n8n_vector_integ',\n\t\t\tdriverInfo: {\n\t\t\t\tname: 'n8n_vector',\n\t\t\t\tversion: version.toString(),\n\t\t\t},\n\t\t});\n\t\tawait mongoConfig.client.connect();\n\t}\n\treturn mongoConfig.client;\n}\n\n/**\n * Get the database object from the MongoClient by the configured name.\n * @param context - The context.\n * @returns the Db object.\n */\nexport async function getDatabase(context: IFunctionsContext, client: MongoClient) {\n\tconst credentials = await context.getCredentials(MONGODB_CREDENTIALS);\n\treturn client.db(credentials.database as string);\n}\n\n/**\n * Get all the collection in the database.\n * @param this The load options context.\n * @returns The list of collections.\n */\nexport async function getCollections(this: ILoadOptionsFunctions) {\n\ttry {\n\t\tconst client = await getMongoClient(this, this.getNode().typeVersion);\n\t\tconst db = await getDatabase(this, client);\n\t\tconst collections = await db.listCollections().toArray();\n\t\tconst results = collections.map((collection) => ({\n\t\t\tname: collection.name,\n\t\t\tvalue: collection.name,\n\t\t}));\n\n\t\treturn { results };\n\t} catch (error) {\n\t\tthrow new NodeOperationError(this.getNode(), `Error: ${error.message}`);\n\t}\n}\n\n/**\n * Get a parameter from the context.\n * @param key - The key of the parameter.\n * @param context - The context.\n * @param itemIndex - The index.\n * @returns The value.\n */\nexport function getParameter(key: string, context: IFunctionsContext, itemIndex: number): string {\n\tconst value = context.getNodeParameter(key, itemIndex, '', {\n\t\textractValue: true,\n\t}) as string;\n\tif (typeof value !== 'string') {\n\t\tthrow new NodeOperationError(context.getNode(), `Parameter ${key} must be a string`);\n\t}\n\treturn value;\n}\n\nexport const getCollectionName = getParameter.bind(null, MONGODB_COLLECTION_NAME);\nexport const getVectorIndexName = getParameter.bind(null, VECTOR_INDEX_NAME);\nexport const getEmbeddingFieldName = getParameter.bind(null, EMBEDDING_NAME);\nexport const getMetadataFieldName = getParameter.bind(null, METADATA_FIELD_NAME);\n\nexport function getFilterValue<T>(\n\tname: string,\n\tcontext: IExecuteFunctions | ISupplyDataFunctions,\n\titemIndex: number,\n): T | undefined {\n\tconst options: IDataObject = context.getNodeParameter('options', itemIndex, {});\n\n\tif (options[name]) {\n\t\tif (typeof options[name] === 'string') {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(options[name]);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription: `Could not parse JSON for ${name}`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthrow new NodeOperationError(context.getNode(), 'Error: No JSON string provided.', {\n\t\t\titemIndex,\n\t\t\tdescription: `Could not parse JSON for ${name}`,\n\t\t});\n\t}\n\n\treturn undefined;\n}\n\nclass ExtendedMongoDBAtlasVectorSearch extends MongoDBAtlasVectorSearch {\n\tpreFilter: IDataObject;\n\tpostFilterPipeline?: IDataObject[];\n\n\tconstructor(\n\t\tembeddings: EmbeddingsInterface,\n\t\toptions: MongoDBAtlasVectorSearchLibArgs,\n\t\tpreFilter: IDataObject,\n\t\tpostFilterPipeline?: IDataObject[],\n\t) {\n\t\tsuper(embeddings, options);\n\t\tthis.preFilter = preFilter;\n\t\tthis.postFilterPipeline = postFilterPipeline;\n\t}\n\n\tasync similaritySearchVectorWithScore(query: number[], k: number) {\n\t\tconst mergedFilter: MongoDBAtlasVectorSearch['FilterType'] = {\n\t\t\tpreFilter: this.preFilter,\n\t\t\tpostFilterPipeline: this.postFilterPipeline,\n\t\t};\n\t\treturn await super.similaritySearchVectorWithScore(query, k, mergedFilter);\n\t}\n}\n\nexport class VectorStoreMongoDBAtlas extends createVectorStoreNode({\n\tmeta: {\n\t\tdisplayName: 'MongoDB Atlas Vector Store',\n\t\tname: 'vectorStoreMongoDBAtlas',\n\t\tdescription: 'Work with your data in MongoDB Atlas Vector Store',\n\t\ticon: { light: 'file:mongodb.svg', dark: 'file:mongodb.dark.svg' },\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoremongodbatlas/',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'mongoDb',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\toperationModes: ['load', 'insert', 'retrieve', 'update', 'retrieve-as-tool'],\n\t},\n\tmethods: { listSearch: { mongoCollectionSearch: getCollections } },\n\tretrieveFields,\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {\n\t\ttry {\n\t\t\tconst client = await getMongoClient(context, context.getNode().typeVersion);\n\t\t\tconst db = await getDatabase(context, client);\n\t\t\tconst collectionName = getCollectionName(context, itemIndex);\n\t\t\tconst mongoVectorIndexName = getVectorIndexName(context, itemIndex);\n\t\t\tconst embeddingFieldName = getEmbeddingFieldName(context, itemIndex);\n\t\t\tconst metadataFieldName = getMetadataFieldName(context, itemIndex);\n\n\t\t\tconst collection = db.collection(collectionName);\n\n\t\t\t// test index exists\n\t\t\tconst indexes = await collection.listSearchIndexes().toArray();\n\n\t\t\tconst indexExists = indexes.some((index) => index.name === mongoVectorIndexName);\n\n\t\t\tif (!indexExists) {\n\t\t\t\tthrow new NodeOperationError(context.getNode(), `Index ${mongoVectorIndexName} not found`, {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription: 'Please check that the index exists in your collection',\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst preFilter = getFilterValue<IDataObject>(PRE_FILTER_NAME, context, itemIndex);\n\t\t\tconst postFilterPipeline = getFilterValue<IDataObject[]>(\n\t\t\t\tPOST_FILTER_NAME,\n\t\t\t\tcontext,\n\t\t\t\titemIndex,\n\t\t\t);\n\n\t\t\treturn new ExtendedMongoDBAtlasVectorSearch(\n\t\t\t\tembeddings,\n\t\t\t\t{\n\t\t\t\t\tcollection,\n\t\t\t\t\tindexName: mongoVectorIndexName, // Default index name\n\t\t\t\t\ttextKey: metadataFieldName, // Field containing raw text\n\t\t\t\t\tembeddingKey: embeddingFieldName, // Field containing embeddings\n\t\t\t\t},\n\t\t\t\tpreFilter ?? {},\n\t\t\t\tpostFilterPipeline,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (error instanceof NodeOperationError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t});\n\t\t}\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\ttry {\n\t\t\tconst client = await getMongoClient(context, context.getNode().typeVersion);\n\t\t\tconst db = await getDatabase(context, client);\n\t\t\tconst collectionName = getCollectionName(context, itemIndex);\n\t\t\tconst mongoVectorIndexName = getVectorIndexName(context, itemIndex);\n\t\t\tconst embeddingFieldName = getEmbeddingFieldName(context, itemIndex);\n\t\t\tconst metadataFieldName = getMetadataFieldName(context, itemIndex);\n\n\t\t\t// Check if collection exists\n\t\t\tconst collections = await db.listCollections({ name: collectionName }).toArray();\n\t\t\tif (collections.length === 0) {\n\t\t\t\tawait db.createCollection(collectionName);\n\t\t\t}\n\t\t\tconst collection = db.collection(collectionName);\n\t\t\tawait ExtendedMongoDBAtlasVectorSearch.fromDocuments(documents, embeddings, {\n\t\t\t\tcollection,\n\t\t\t\tindexName: mongoVectorIndexName, // Default index name\n\t\t\t\ttextKey: metadataFieldName, // Field containing raw text\n\t\t\t\tembeddingKey: embeddingFieldName, // Field containing embeddings\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t});\n\t\t}\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA+E;AAC/E,IAAAA,kBAA4B;AAC5B,0BAOO;AACP,0BAAoC;AAEpC,mCAAsC;AAK/B,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAEhC,MAAM,qBAAsC;AAAA,EAC3C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS,EAAE,MAAM,QAAQ,OAAO,GAAG;AAAA,EACnC,UAAU;AAAA,EACV,OAAO;AAAA,IACN;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,QACZ,kBAAkB;AAAA;AAAA,MACnB;AAAA,IACD;AAAA,IACA;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACd;AAAA,EACD;AACD;AAEA,MAAM,kBAAmC;AAAA,EACxC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AACX;AAEA,MAAM,iBAAkC;AAAA,EACvC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AA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pers");
42
42
  var import_tracing = require("../../../../../utils/tracing");
43
43
  var import_utils = require("../../helpers/utils");
44
44
  var import_descriptions2 = require("../descriptions");
45
+ var import_httpProxyAgent = require("../../../../../utils/httpProxyAgent");
45
46
  const properties = [
46
47
  import_descriptions2.assistantRLC,
47
48
  {
@@ -190,7 +191,10 @@ async function execute(i) {
190
191
  apiKey: credentials.apiKey,
191
192
  maxRetries: options.maxRetries ?? 2,
192
193
  timeout: options.timeout ?? 1e4,
193
- baseURL
194
+ baseURL,
195
+ fetchOptions: {
196
+ dispatcher: (0, import_httpProxyAgent.getProxyAgent)(baseURL)
197
+ }
194
198
  });
195
199
  const agent = new import_openai_assistant.OpenAIAssistantRunnable({ assistantId, client, asAgent: true });
196
200
  const tools = await (0, import_helpers.getConnectedTools)(this, nodeVersion > 1, false);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/assistant/message.operation.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport { AgentExecutor } from 'langchain/agents';\nimport type { OpenAIToolType } from 'langchain/dist/experimental/openai_assistant/schema';\nimport { OpenAIAssistantRunnable } from 'langchain/experimental/openai_assistant';\nimport type { BufferWindowMemory } from 'langchain/memory';\nimport omit from 'lodash/omit';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeProperties,\n} from 'n8n-workflow';\nimport {\n\tApplicationError,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\tupdateDisplayOptions,\n} from 'n8n-workflow';\nimport { OpenAI as OpenAIClient } from 'openai';\n\nimport { promptTypeOptions } from '@utils/descriptions';\nimport { getConnectedTools } from '@utils/helpers';\nimport { getTracingConfig } from '@utils/tracing';\n\nimport { formatToOpenAIAssistantTool, getChatMessages } from '../../helpers/utils';\nimport { assistantRLC } from '../descriptions';\n\nconst properties: INodeProperties[] = [\n\tassistantRLC,\n\t{\n\t\t...promptTypeOptions,\n\t\tname: 'prompt',\n\t},\n\t{\n\t\tdisplayName: 'Prompt (User Message)',\n\t\tname: 'text',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: 'e.g. Hello, how can you help me?',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tprompt: ['define'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Memory',\n\t\tname: 'memory',\n\t\ttype: 'options',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Use memory connector',\n\t\t\t\tvalue: 'connector',\n\t\t\t\tdescription: 'Connect one of the supported memory nodes',\n\t\t\t},\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\tname: 'Use thread ID',\n\t\t\t\tvalue: 'threadId',\n\t\t\t\tdescription: 'Specify the ID of the thread to continue',\n\t\t\t},\n\t\t],\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t},\n\t\t},\n\t\tdefault: 'connector',\n\t},\n\t{\n\t\tdisplayName: 'Thread ID',\n\t\tname: 'threadId',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: '',\n\t\tdescription: 'The ID of the thread to continue, a new thread will be created if not specified',\n\t\thint: 'If the thread ID is empty or undefined a new thread will be created and included in the response',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t\tmemory: ['threadId'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Connect your own custom n8n tools to this node on the canvas',\n\t\tname: 'noticeTools',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\tdescription: 'Additional options to add',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\tname: 'baseURL',\n\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.8 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Max Retries',\n\t\t\t\tname: 'maxRetries',\n\t\t\t\tdefault: 2,\n\t\t\t\tdescription: 'Maximum number of retries to attempt',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\tname: 'timeout',\n\t\t\t\tdefault: 10000,\n\t\t\t\tdescription: 'Maximum amount of time a request is allowed to take in milliseconds',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Preserve Original Tools',\n\t\t\t\tname: 'preserveOriginalTools',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to preserve the original tools of the assistant after the execution of this node, otherwise the tools will be replaced with the connected tools, if any, default is true',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\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: ['message'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\nconst mapChatMessageToThreadMessage = (\n\tmessage: BaseMessage,\n): OpenAIClient.Beta.Threads.ThreadCreateParams.Message => ({\n\trole: message._getType() === 'ai' ? 'assistant' : 'user',\n\tcontent: message.content.toString(),\n});\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst credentials = await this.getCredentials('openAiApi');\n\tconst nodeVersion = this.getNode().typeVersion;\n\n\tconst prompt = this.getNodeParameter('prompt', i) as string;\n\n\tlet input;\n\tif (prompt === 'auto') {\n\t\tinput = this.evaluateExpression('{{ $json[\"chatInput\"] }}', i) as string;\n\t} else {\n\t\tinput = this.getNodeParameter('text', i) as string;\n\t}\n\n\tif (input === undefined) {\n\t\tthrow new NodeOperationError(this.getNode(), 'No prompt specified', {\n\t\t\tdescription:\n\t\t\t\t\"Expected to find the prompt in an input field called 'chatInput' (this is what the chat trigger node outputs). To use something else, change the 'Prompt' parameter\",\n\t\t});\n\t}\n\n\tconst assistantId = this.getNodeParameter('assistantId', i, '', { extractValue: true }) as string;\n\n\tconst options = this.getNodeParameter('options', i, {}) as {\n\t\tbaseURL?: string;\n\t\tmaxRetries: number;\n\t\ttimeout: number;\n\t\tpreserveOriginalTools?: boolean;\n\t};\n\n\tconst baseURL = (options.baseURL ?? credentials.url) as string;\n\n\tconst client = new OpenAIClient({\n\t\tapiKey: credentials.apiKey as string,\n\t\tmaxRetries: options.maxRetries ?? 2,\n\t\ttimeout: options.timeout ?? 10000,\n\t\tbaseURL,\n\t});\n\n\tconst agent = new OpenAIAssistantRunnable({ assistantId, client, asAgent: true });\n\n\tconst tools = await getConnectedTools(this, nodeVersion > 1, false);\n\tlet assistantTools;\n\n\tif (tools.length) {\n\t\tconst transformedConnectedTools = tools?.map(formatToOpenAIAssistantTool) ?? [];\n\t\tconst nativeToolsParsed: OpenAIToolType = [];\n\n\t\tassistantTools = (await client.beta.assistants.retrieve(assistantId)).tools;\n\n\t\tconst useCodeInterpreter = assistantTools.some((tool) => tool.type === 'code_interpreter');\n\t\tif (useCodeInterpreter) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'code_interpreter',\n\t\t\t});\n\t\t}\n\n\t\tconst useRetrieval = assistantTools.some((tool) => tool.type === 'file_search');\n\t\tif (useRetrieval) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'file_search',\n\t\t\t});\n\t\t}\n\n\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\ttools: [...nativeToolsParsed, ...transformedConnectedTools],\n\t\t});\n\t}\n\n\tconst agentExecutor = AgentExecutor.fromAgentAndTools({\n\t\tagent,\n\t\ttools: tools ?? [],\n\t});\n\n\tconst useMemoryConnector =\n\t\tnodeVersion >= 1.6 && this.getNodeParameter('memory', i) === 'connector';\n\tconst memory =\n\t\tuseMemoryConnector || nodeVersion < 1.6\n\t\t\t? ((await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t\t| BufferWindowMemory\n\t\t\t\t\t| undefined)\n\t\t\t: undefined;\n\n\tconst threadId =\n\t\tnodeVersion >= 1.6 && !useMemoryConnector\n\t\t\t? (this.getNodeParameter('threadId', i) as string)\n\t\t\t: undefined;\n\n\tconst chainValues: IDataObject = {\n\t\tcontent: input,\n\t\tsignal: this.getExecutionCancelSignal(),\n\t\ttimeout: options.timeout ?? 10000,\n\t};\n\tlet thread: OpenAIClient.Beta.Threads.Thread;\n\tif (memory) {\n\t\tconst chatMessages = await getChatMessages(memory);\n\n\t\t// Construct a new thread from the chat history to map the memory\n\t\tif (chatMessages.length) {\n\t\t\tconst first32Messages = chatMessages.slice(0, 32);\n\t\t\t// There is a undocumented limit of 32 messages per thread when creating a thread with messages\n\t\t\tconst mappedMessages: OpenAIClient.Beta.Threads.ThreadCreateParams.Message[] =\n\t\t\t\tfirst32Messages.map(mapChatMessageToThreadMessage);\n\n\t\t\tthread = await client.beta.threads.create({ messages: mappedMessages });\n\t\t\tconst overLimitMessages = chatMessages.slice(32).map(mapChatMessageToThreadMessage);\n\n\t\t\t// Send the remaining messages that exceed the limit of 32 sequentially\n\t\t\tfor (const message of overLimitMessages) {\n\t\t\t\tawait client.beta.threads.messages.create(thread.id, message);\n\t\t\t}\n\n\t\t\tchainValues.threadId = thread.id;\n\t\t}\n\t} else if (threadId) {\n\t\tchainValues.threadId = threadId;\n\t}\n\n\tlet filteredResponse: IDataObject = {};\n\ttry {\n\t\tconst response = await agentExecutor.withConfig(getTracingConfig(this)).invoke(chainValues);\n\t\tif (memory) {\n\t\t\tawait memory.saveContext({ input }, { output: response.output });\n\n\t\t\tif (response.threadId && response.runId) {\n\t\t\t\tconst threadRun = await client.beta.threads.runs.retrieve(response.runId, {\n\t\t\t\t\tthread_id: response.threadId,\n\t\t\t\t});\n\t\t\t\tresponse.usage = threadRun.usage;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\toptions.preserveOriginalTools !== false &&\n\t\t\tnodeVersion >= 1.3 &&\n\t\t\t(assistantTools ?? [])?.length\n\t\t) {\n\t\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\t\ttools: assistantTools,\n\t\t\t});\n\t\t}\n\t\t// Remove configuration properties and runId added by Langchain that are not relevant to the user\n\t\tfilteredResponse = omit(response, ['signal', 'timeout', 'content', 'runId']) as IDataObject;\n\t} catch (error) {\n\t\tif (!(error instanceof ApplicationError)) {\n\t\t\tthrow new NodeOperationError(this.getNode(), error.message, { itemIndex: i });\n\t\t}\n\t}\n\n\treturn [{ json: filteredResponse, pairedItem: { item: i } }];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAE9B,8BAAwC;AAExC,kBAAiB;AAOjB,0BAKO;AACP,oBAAuC;AAEvC,0BAAkC;AAClC,qBAAkC;AAClC,qBAAiC;AAEjC,mBAA6D;AAC7D,IAAAA,uBAA6B;AAE7B,MAAM,aAAgC;AAAA,EACrC;AAAA,EACA;AAAA,IACC,GAAG;AAAA,IACH,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,M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ACR,CAAC;AAAA,IACF;AAEA,2BAAmB,YAAAC,SAAK,UAAU,CAAC,UAAU,WAAW,WAAW,OAAO,CAAC;AAAA,EAC5E,SAAS,OAAO;AACf,QAAI,EAAE,iBAAiB,uCAAmB;AACzC,YAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,MAAM,SAAS,EAAE,WAAW,EAAE,CAAC;AAAA,IAC7E;AAAA,EACD;AAEA,SAAO,CAAC,EAAE,MAAM,kBAAkB,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;AAC5D;","names":["import_descriptions","OpenAIClient","omit"]}
1
+ {"version":3,"sources":["../../../../../../nodes/vendors/OpenAi/actions/assistant/message.operation.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport { AgentExecutor } from 'langchain/agents';\nimport type { OpenAIToolType } from 'langchain/dist/experimental/openai_assistant/schema';\nimport { OpenAIAssistantRunnable } from 'langchain/experimental/openai_assistant';\nimport type { BufferWindowMemory } from 'langchain/memory';\nimport omit from 'lodash/omit';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeProperties,\n} from 'n8n-workflow';\nimport {\n\tApplicationError,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\tupdateDisplayOptions,\n} from 'n8n-workflow';\nimport { OpenAI as OpenAIClient } from 'openai';\n\nimport { promptTypeOptions } from '@utils/descriptions';\nimport { getConnectedTools } from '@utils/helpers';\nimport { getTracingConfig } from '@utils/tracing';\n\nimport { formatToOpenAIAssistantTool, getChatMessages } from '../../helpers/utils';\nimport { assistantRLC } from '../descriptions';\nimport { getProxyAgent } from '@utils/httpProxyAgent';\n\nconst properties: INodeProperties[] = [\n\tassistantRLC,\n\t{\n\t\t...promptTypeOptions,\n\t\tname: 'prompt',\n\t},\n\t{\n\t\tdisplayName: 'Prompt (User Message)',\n\t\tname: 'text',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: 'e.g. Hello, how can you help me?',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tprompt: ['define'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Memory',\n\t\tname: 'memory',\n\t\ttype: 'options',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Use memory connector',\n\t\t\t\tvalue: 'connector',\n\t\t\t\tdescription: 'Connect one of the supported memory nodes',\n\t\t\t},\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\tname: 'Use thread ID',\n\t\t\t\tvalue: 'threadId',\n\t\t\t\tdescription: 'Specify the ID of the thread to continue',\n\t\t\t},\n\t\t],\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t},\n\t\t},\n\t\tdefault: 'connector',\n\t},\n\t{\n\t\tdisplayName: 'Thread ID',\n\t\tname: 'threadId',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: '',\n\t\tdescription: 'The ID of the thread to continue, a new thread will be created if not specified',\n\t\thint: 'If the thread ID is empty or undefined a new thread will be created and included in the response',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t\tmemory: ['threadId'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Connect your own custom n8n tools to this node on the canvas',\n\t\tname: 'noticeTools',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\tdescription: 'Additional options to add',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\tname: 'baseURL',\n\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.8 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Max Retries',\n\t\t\t\tname: 'maxRetries',\n\t\t\t\tdefault: 2,\n\t\t\t\tdescription: 'Maximum number of retries to attempt',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\tname: 'timeout',\n\t\t\t\tdefault: 10000,\n\t\t\t\tdescription: 'Maximum amount of time a request is allowed to take in milliseconds',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Preserve Original Tools',\n\t\t\t\tname: 'preserveOriginalTools',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to preserve the original tools of the assistant after the execution of this node, otherwise the tools will be replaced with the connected tools, if any, default is true',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\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: ['message'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\nconst mapChatMessageToThreadMessage = (\n\tmessage: BaseMessage,\n): OpenAIClient.Beta.Threads.ThreadCreateParams.Message => ({\n\trole: message._getType() === 'ai' ? 'assistant' : 'user',\n\tcontent: message.content.toString(),\n});\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst credentials = await this.getCredentials('openAiApi');\n\tconst nodeVersion = this.getNode().typeVersion;\n\n\tconst prompt = this.getNodeParameter('prompt', i) as string;\n\n\tlet input;\n\tif (prompt === 'auto') {\n\t\tinput = this.evaluateExpression('{{ $json[\"chatInput\"] }}', i) as string;\n\t} else {\n\t\tinput = this.getNodeParameter('text', i) as string;\n\t}\n\n\tif (input === undefined) {\n\t\tthrow new NodeOperationError(this.getNode(), 'No prompt specified', {\n\t\t\tdescription:\n\t\t\t\t\"Expected to find the prompt in an input field called 'chatInput' (this is what the chat trigger node outputs). To use something else, change the 'Prompt' parameter\",\n\t\t});\n\t}\n\n\tconst assistantId = this.getNodeParameter('assistantId', i, '', { extractValue: true }) as string;\n\n\tconst options = this.getNodeParameter('options', i, {}) as {\n\t\tbaseURL?: string;\n\t\tmaxRetries: number;\n\t\ttimeout: number;\n\t\tpreserveOriginalTools?: boolean;\n\t};\n\n\tconst baseURL = (options.baseURL ?? credentials.url) as string;\n\n\tconst client = new OpenAIClient({\n\t\tapiKey: credentials.apiKey as string,\n\t\tmaxRetries: options.maxRetries ?? 2,\n\t\ttimeout: options.timeout ?? 10000,\n\t\tbaseURL,\n\t\tfetchOptions: {\n\t\t\tdispatcher: getProxyAgent(baseURL),\n\t\t},\n\t});\n\n\tconst agent = new OpenAIAssistantRunnable({ assistantId, client, asAgent: true });\n\n\tconst tools = await getConnectedTools(this, nodeVersion > 1, false);\n\tlet assistantTools;\n\n\tif (tools.length) {\n\t\tconst transformedConnectedTools = tools?.map(formatToOpenAIAssistantTool) ?? [];\n\t\tconst nativeToolsParsed: OpenAIToolType = [];\n\n\t\tassistantTools = (await client.beta.assistants.retrieve(assistantId)).tools;\n\n\t\tconst useCodeInterpreter = assistantTools.some((tool) => tool.type === 'code_interpreter');\n\t\tif (useCodeInterpreter) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'code_interpreter',\n\t\t\t});\n\t\t}\n\n\t\tconst useRetrieval = assistantTools.some((tool) => tool.type === 'file_search');\n\t\tif (useRetrieval) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'file_search',\n\t\t\t});\n\t\t}\n\n\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\ttools: [...nativeToolsParsed, ...transformedConnectedTools],\n\t\t});\n\t}\n\n\tconst agentExecutor = AgentExecutor.fromAgentAndTools({\n\t\tagent,\n\t\ttools: tools ?? [],\n\t});\n\n\tconst useMemoryConnector =\n\t\tnodeVersion >= 1.6 && this.getNodeParameter('memory', i) === 'connector';\n\tconst memory =\n\t\tuseMemoryConnector || nodeVersion < 1.6\n\t\t\t? ((await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t\t| BufferWindowMemory\n\t\t\t\t\t| undefined)\n\t\t\t: undefined;\n\n\tconst threadId =\n\t\tnodeVersion >= 1.6 && !useMemoryConnector\n\t\t\t? (this.getNodeParameter('threadId', i) as string)\n\t\t\t: undefined;\n\n\tconst chainValues: IDataObject = {\n\t\tcontent: input,\n\t\tsignal: this.getExecutionCancelSignal(),\n\t\ttimeout: options.timeout ?? 10000,\n\t};\n\tlet thread: OpenAIClient.Beta.Threads.Thread;\n\tif (memory) {\n\t\tconst chatMessages = await getChatMessages(memory);\n\n\t\t// Construct a new thread from the chat history to map the memory\n\t\tif (chatMessages.length) {\n\t\t\tconst first32Messages = chatMessages.slice(0, 32);\n\t\t\t// There is a undocumented limit of 32 messages per thread when creating a thread with messages\n\t\t\tconst mappedMessages: OpenAIClient.Beta.Threads.ThreadCreateParams.Message[] =\n\t\t\t\tfirst32Messages.map(mapChatMessageToThreadMessage);\n\n\t\t\tthread = await client.beta.threads.create({ messages: mappedMessages });\n\t\t\tconst overLimitMessages = chatMessages.slice(32).map(mapChatMessageToThreadMessage);\n\n\t\t\t// Send the remaining messages that exceed the limit of 32 sequentially\n\t\t\tfor (const message of overLimitMessages) {\n\t\t\t\tawait client.beta.threads.messages.create(thread.id, message);\n\t\t\t}\n\n\t\t\tchainValues.threadId = thread.id;\n\t\t}\n\t} else if (threadId) {\n\t\tchainValues.threadId = threadId;\n\t}\n\n\tlet filteredResponse: IDataObject = {};\n\ttry {\n\t\tconst response = await agentExecutor.withConfig(getTracingConfig(this)).invoke(chainValues);\n\t\tif (memory) {\n\t\t\tawait memory.saveContext({ input }, { output: response.output });\n\n\t\t\tif (response.threadId && response.runId) {\n\t\t\t\tconst threadRun = await client.beta.threads.runs.retrieve(response.runId, {\n\t\t\t\t\tthread_id: response.threadId,\n\t\t\t\t});\n\t\t\t\tresponse.usage = threadRun.usage;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\toptions.preserveOriginalTools !== false &&\n\t\t\tnodeVersion >= 1.3 &&\n\t\t\t(assistantTools ?? [])?.length\n\t\t) {\n\t\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\t\ttools: assistantTools,\n\t\t\t});\n\t\t}\n\t\t// Remove configuration properties and runId added by Langchain that are not relevant to the user\n\t\tfilteredResponse = omit(response, ['signal', 'timeout', 'content', 'runId']) as IDataObject;\n\t} catch (error) {\n\t\tif (!(error instanceof ApplicationError)) {\n\t\t\tthrow new NodeOperationError(this.getNode(), error.message, { itemIndex: i });\n\t\t}\n\t}\n\n\treturn [{ json: filteredResponse, pairedItem: { item: i } }];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAE9B,8BAAwC;AAExC,kBAAiB;AAOjB,0BAKO;AACP,oBAAuC;AAEvC,0BAAkC;AAClC,qBAAkC;AAClC,qBAAiC;AAEjC,mBAA6D;AAC7D,IAAAA,uBAA6B;AAC7B,4BAA8B;AAE9B,MAAM,aAAgC;AAAA,EACrC;AAAA,EACA;AAAA,IACC,GAAG;AAAA,IACH,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,QAAQ,CAAC,QAAQ;AAAA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,OAAO;AAAA,MACR,CAAC;AAAA,IACF;AAEA,2BAAmB,YAAAC,SAAK,UAAU,CAAC,UAAU,WAAW,WAAW,OAAO,CAAC;AAAA,EAC5E,SAAS,OAAO;AACf,QAAI,EAAE,iBAAiB,uCAAmB;AACzC,YAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,MAAM,SAAS,EAAE,WAAW,EAAE,CAAC;AAAA,IAC7E;AAAA,EACD;AAEA,SAAO,CAAC,EAAE,MAAM,kBAAkB,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;AAC5D;","names":["import_descriptions","OpenAIClient","omit"]}
@@ -85,7 +85,7 @@
85
85
  {"displayName":"In Memory Vector Store Insert","name":"vectorStoreInMemoryInsert","icon":"fa:database","group":["transform"],"version":1,"hidden":true,"description":"Insert data into an in-memory vector store","defaults":{"name":"In Memory Vector Store Insert"},"codex":{"categories":["AI"],"subcategories":{"AI":["Vector Stores"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/"}]}},"inputs":["main",{"displayName":"Document","maxConnections":1,"type":"ai_document","required":true},{"displayName":"Embedding","maxConnections":1,"type":"ai_embedding","required":true}],"outputs":["main"],"properties":[{"displayName":"The embbded data are stored in the server memory, so they will be lost when the server is restarted. Additionally, if the amount of data is too large, it may cause the server to crash due to insufficient memory.","name":"notice","type":"notice","default":""},{"displayName":"Clear Store","name":"clearStore","type":"boolean","default":false,"description":"Whether to clear the store before inserting new data"},{"displayName":"Memory Key","name":"memoryKey","type":"string","default":"vector_store_key","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."}]},
86
86
  {"displayName":"In Memory Vector Store Load","name":"vectorStoreInMemoryLoad","icon":"fa:database","group":["transform"],"version":1,"hidden":true,"description":"Load embedded data from an in-memory vector store","defaults":{"name":"In Memory Vector Store Load"},"codex":{"categories":["AI"],"subcategories":{"AI":["Vector Stores"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/"}]}},"inputs":[{"displayName":"Embedding","maxConnections":1,"type":"ai_embedding","required":true}],"outputs":["ai_vectorStore"],"outputNames":["Vector Store"],"properties":[{"displayName":"Memory Key","name":"memoryKey","type":"string","default":"vector_store_key","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."}]},
87
87
  {"displayName":"Milvus Vector Store","name":"vectorStoreMilvus","description":"Work with your data in Milvus Vector Store","group":["transform"],"version":[1,1.1,1.2,1.3],"defaults":{"name":"Milvus Vector Store"},"codex":{"categories":["AI"],"subcategories":{"AI":["Vector Stores","Tools","Root Nodes"],"Vector Stores":["Other Vector Stores"],"Tools":["Other Tools"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoremilvus/"}]}},"credentials":[{"name":"milvusApi","required":true}],"inputs":"={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst useReranker = parameters?.useReranker;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"ai_embedding\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (['load', 'retrieve', 'retrieve-as-tool'].includes(mode) && useReranker) {\n\t\t\t\t\tinputs.push({ displayName: \"Reranker\", type: \"ai_reranker\", required: true, maxConnections: 1})\n\t\t\t\t}\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: \"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: \"ai_document\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}","outputs":"={{\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: \"ai_tool\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"ai_vectorStore\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"main\"}]\n\t\t\t})($parameter)\n\t\t}}","properties":[{"displayName":"Tip: Get a feel for vector stores in n8n with our","name":"ragStarterCallout","type":"callout","typeOptions":{"calloutAction":{"label":"RAG starter template","type":"openSampleWorkflowTemplate","templateId":"rag-starter-template"}},"default":""},{"displayName":"Operation Mode","name":"mode","type":"options","noDataExpression":true,"default":"retrieve","options":[{"name":"Get Many","value":"load","description":"Get many ranked documents from vector store for query","action":"Get ranked documents from vector store"},{"name":"Insert Documents","value":"insert","description":"Insert documents into vector store","action":"Add documents to vector store"},{"name":"Retrieve Documents (As Vector Store for Chain/Tool)","value":"retrieve","description":"Retrieve documents from vector store to be used as vector store with AI nodes","action":"Retrieve documents for Chain/Tool as Vector Store","outputConnectionType":"ai_vectorStore"},{"name":"Retrieve Documents (As Tool for AI Agent)","value":"retrieve-as-tool","description":"Retrieve documents from vector store to be used as tool with AI nodes","action":"Retrieve documents for AI Agent as Tool","outputConnectionType":"ai_tool"}]},{"displayName":"This node must be connected to a vector store retriever. <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='ai_retriever'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"},"displayOptions":{"show":{"mode":["retrieve"]}}},{"displayName":"Name","name":"toolName","type":"string","default":"","required":true,"description":"Name of the vector store","placeholder":"e.g. company_knowledge_base","validateType":"string-alphanumeric","displayOptions":{"show":{"@version":[{"_cnd":{"lte":1.2}}],"mode":["retrieve-as-tool"]}}},{"displayName":"Description","name":"toolDescription","type":"string","default":"","required":true,"typeOptions":{"rows":2},"description":"Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often","placeholder":"e.g. Work with your data in Milvus Vector Store","displayOptions":{"show":{"mode":["retrieve-as-tool"]}}},{"displayName":"Milvus Collection","name":"milvusCollection","type":"resourceLocator","default":{"mode":"list","value":""},"required":true,"modes":[{"displayName":"From List","name":"list","type":"list","typeOptions":{"searchListMethod":"milvusCollectionsSearch"}},{"displayName":"ID","name":"id","type":"string"}]},{"displayName":"Embedding Batch Size","name":"embeddingBatchSize","type":"number","default":200,"description":"Number of documents to embed in a single batch","displayOptions":{"show":{"mode":["insert"],"@version":[{"_cnd":{"gte":1.1}}]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Clear Collection","name":"clearCollection","type":"boolean","default":false,"description":"Whether to clear the collection before inserting new data"}],"displayOptions":{"show":{"mode":["insert"]}}},{"displayName":"Prompt","name":"prompt","type":"string","default":"","required":true,"description":"Search prompt to retrieve matching documents from the vector store using similarity-based ranking","displayOptions":{"show":{"mode":["load"]}}},{"displayName":"Limit","name":"topK","type":"number","default":4,"description":"Number of top results to fetch from vector store","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Include Metadata","name":"includeDocumentMetadata","type":"boolean","default":true,"description":"Whether or not to include document metadata","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Rerank Results","name":"useReranker","type":"boolean","default":false,"description":"Whether or not to rerank results","displayOptions":{"show":{"mode":["load","retrieve","retrieve-as-tool"]}}},{"displayName":"ID","name":"id","type":"string","default":"","required":true,"description":"ID of an embedding entry","displayOptions":{"show":{"mode":["update"]}}}],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMilvus/milvus-icon-black.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMilvus/milvus-icon-white.svg"}},
88
- {"displayName":"MongoDB Atlas Vector Store","name":"vectorStoreMongoDBAtlas","description":"Work with your data in MongoDB Atlas Vector Store","group":["transform"],"version":[1,1.1,1.2,1.3],"defaults":{"name":"MongoDB Atlas Vector Store"},"codex":{"categories":["AI"],"subcategories":{"AI":["Vector Stores","Tools","Root Nodes"],"Vector Stores":["Other Vector Stores"],"Tools":["Other Tools"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoremongodbatlas/"}]}},"credentials":[{"name":"mongoDb","required":true}],"inputs":"={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst useReranker = parameters?.useReranker;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"ai_embedding\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (['load', 'retrieve', 'retrieve-as-tool'].includes(mode) && useReranker) {\n\t\t\t\t\tinputs.push({ displayName: \"Reranker\", type: \"ai_reranker\", required: true, maxConnections: 1})\n\t\t\t\t}\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: \"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: \"ai_document\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}","outputs":"={{\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: \"ai_tool\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"ai_vectorStore\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"main\"}]\n\t\t\t})($parameter)\n\t\t}}","properties":[{"displayName":"Tip: Get a feel for vector stores in n8n with our","name":"ragStarterCallout","type":"callout","typeOptions":{"calloutAction":{"label":"RAG starter template","type":"openSampleWorkflowTemplate","templateId":"rag-starter-template"}},"default":""},{"displayName":"Operation Mode","name":"mode","type":"options","noDataExpression":true,"default":"retrieve","options":[{"name":"Get Many","value":"load","description":"Get many ranked documents from vector store for query","action":"Get ranked documents from vector store"},{"name":"Insert Documents","value":"insert","description":"Insert documents into vector store","action":"Add documents to vector store"},{"name":"Retrieve Documents (As Vector Store for Chain/Tool)","value":"retrieve","description":"Retrieve documents from vector store to be used as vector store with AI nodes","action":"Retrieve documents for Chain/Tool as Vector Store","outputConnectionType":"ai_vectorStore"},{"name":"Retrieve Documents (As Tool for AI Agent)","value":"retrieve-as-tool","description":"Retrieve documents from vector store to be used as tool with AI nodes","action":"Retrieve documents for AI Agent as Tool","outputConnectionType":"ai_tool"},{"name":"Update Documents","value":"update","description":"Update documents in vector store by ID","action":"Update vector store documents"}]},{"displayName":"This node must be connected to a vector store retriever. <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='ai_retriever'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"},"displayOptions":{"show":{"mode":["retrieve"]}}},{"displayName":"Name","name":"toolName","type":"string","default":"","required":true,"description":"Name of the vector store","placeholder":"e.g. company_knowledge_base","validateType":"string-alphanumeric","displayOptions":{"show":{"@version":[{"_cnd":{"lte":1.2}}],"mode":["retrieve-as-tool"]}}},{"displayName":"Description","name":"toolDescription","type":"string","default":"","required":true,"typeOptions":{"rows":2},"description":"Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often","placeholder":"e.g. Work with your data in MongoDB Atlas Vector Store","displayOptions":{"show":{"mode":["retrieve-as-tool"]}}},{"displayName":"MongoDB Collection","name":"mongoCollection","type":"resourceLocator","default":{"mode":"list","value":""},"required":true,"modes":[{"displayName":"From List","name":"list","type":"list","typeOptions":{"searchListMethod":"mongoCollectionSearch"}},{"displayName":"Name","name":"name","type":"string","placeholder":"e.g. my_collection"}]},{"displayName":"Embedding","name":"embedding","type":"string","default":"embedding","description":"The field with the embedding array","required":true},{"displayName":"Metadata Field","name":"metadata_field","type":"string","default":"text","description":"The text field of the raw data","required":true},{"displayName":"Vector Index Name","name":"vectorIndexName","type":"string","default":"","description":"The name of the vector index","required":true},{"displayName":"Embedding Batch Size","name":"embeddingBatchSize","type":"number","default":200,"description":"Number of documents to embed in a single batch","displayOptions":{"show":{"mode":["insert"],"@version":[{"_cnd":{"gte":1.1}}]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Clear Namespace","name":"clearNamespace","type":"boolean","default":false,"description":"Whether to clear documents in the namespace before inserting new data"},{"displayName":"Namespace","name":"namespace","type":"string","description":"Logical partition for documents. Uses metadata.namespace field for filtering.","default":""}],"displayOptions":{"show":{"mode":["insert"]}}},{"displayName":"Prompt","name":"prompt","type":"string","default":"","required":true,"description":"Search prompt to retrieve matching documents from the vector store using similarity-based ranking","displayOptions":{"show":{"mode":["load"]}}},{"displayName":"Limit","name":"topK","type":"number","default":4,"description":"Number of top results to fetch from vector store","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Include Metadata","name":"includeDocumentMetadata","type":"boolean","default":true,"description":"Whether or not to include document metadata","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Rerank Results","name":"useReranker","type":"boolean","default":false,"description":"Whether or not to rerank results","displayOptions":{"show":{"mode":["load","retrieve","retrieve-as-tool"]}}},{"displayName":"ID","name":"id","type":"string","default":"","required":true,"description":"ID of an embedding entry","displayOptions":{"show":{"mode":["update"]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Namespace","name":"namespace","type":"string","description":"Logical partition for documents. Uses metadata.namespace field for filtering.","default":""},{"displayName":"Metadata Filter","name":"metadata","type":"fixedCollection","description":"Metadata to filter the document by","typeOptions":{"multipleValues":true},"default":{},"placeholder":"Add filter field","options":[{"name":"metadataValues","displayName":"Fields to Set","values":[{"displayName":"Name","name":"name","type":"string","default":"","required":true},{"displayName":"Value","name":"value","type":"string","default":""}]}]}],"displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Namespace","name":"namespace","type":"string","description":"Logical partition for documents. Uses metadata.namespace field for filtering.","default":""},{"displayName":"Metadata Filter","name":"metadata","type":"fixedCollection","description":"Metadata to filter the document by","typeOptions":{"multipleValues":true},"default":{},"placeholder":"Add filter field","options":[{"name":"metadataValues","displayName":"Fields to Set","values":[{"displayName":"Name","name":"name","type":"string","default":"","required":true},{"displayName":"Value","name":"value","type":"string","default":""}]}]}],"displayOptions":{"show":{"mode":["retrieve"]}}}],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.dark.svg"}},
88
+ {"displayName":"MongoDB Atlas Vector Store","name":"vectorStoreMongoDBAtlas","description":"Work with your data in MongoDB Atlas Vector Store","group":["transform"],"version":[1,1.1,1.2,1.3],"defaults":{"name":"MongoDB Atlas Vector Store"},"codex":{"categories":["AI"],"subcategories":{"AI":["Vector Stores","Tools","Root Nodes"],"Vector Stores":["Other Vector Stores"],"Tools":["Other Tools"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoremongodbatlas/"}]}},"credentials":[{"name":"mongoDb","required":true}],"inputs":"={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst useReranker = parameters?.useReranker;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"ai_embedding\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (['load', 'retrieve', 'retrieve-as-tool'].includes(mode) && useReranker) {\n\t\t\t\t\tinputs.push({ displayName: \"Reranker\", type: \"ai_reranker\", required: true, maxConnections: 1})\n\t\t\t\t}\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: \"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: \"ai_document\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}","outputs":"={{\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: \"ai_tool\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"ai_vectorStore\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"main\"}]\n\t\t\t})($parameter)\n\t\t}}","properties":[{"displayName":"Tip: Get a feel for vector stores in n8n with our","name":"ragStarterCallout","type":"callout","typeOptions":{"calloutAction":{"label":"RAG starter template","type":"openSampleWorkflowTemplate","templateId":"rag-starter-template"}},"default":""},{"displayName":"Operation Mode","name":"mode","type":"options","noDataExpression":true,"default":"retrieve","options":[{"name":"Get Many","value":"load","description":"Get many ranked documents from vector store for query","action":"Get ranked documents from vector store"},{"name":"Insert Documents","value":"insert","description":"Insert documents into vector store","action":"Add documents to vector store"},{"name":"Retrieve Documents (As Vector Store for Chain/Tool)","value":"retrieve","description":"Retrieve documents from vector store to be used as vector store with AI nodes","action":"Retrieve documents for Chain/Tool as Vector Store","outputConnectionType":"ai_vectorStore"},{"name":"Retrieve Documents (As Tool for AI Agent)","value":"retrieve-as-tool","description":"Retrieve documents from vector store to be used as tool with AI nodes","action":"Retrieve documents for AI Agent as Tool","outputConnectionType":"ai_tool"},{"name":"Update Documents","value":"update","description":"Update documents in vector store by ID","action":"Update vector store documents"}]},{"displayName":"This node must be connected to a vector store retriever. <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='ai_retriever'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"},"displayOptions":{"show":{"mode":["retrieve"]}}},{"displayName":"Name","name":"toolName","type":"string","default":"","required":true,"description":"Name of the vector store","placeholder":"e.g. company_knowledge_base","validateType":"string-alphanumeric","displayOptions":{"show":{"@version":[{"_cnd":{"lte":1.2}}],"mode":["retrieve-as-tool"]}}},{"displayName":"Description","name":"toolDescription","type":"string","default":"","required":true,"typeOptions":{"rows":2},"description":"Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often","placeholder":"e.g. Work with your data in MongoDB Atlas Vector Store","displayOptions":{"show":{"mode":["retrieve-as-tool"]}}},{"displayName":"MongoDB Collection","name":"mongoCollection","type":"resourceLocator","default":{"mode":"list","value":""},"required":true,"modes":[{"displayName":"From List","name":"list","type":"list","typeOptions":{"searchListMethod":"mongoCollectionSearch"}},{"displayName":"Name","name":"name","type":"string","placeholder":"e.g. my_collection"}]},{"displayName":"Embedding","name":"embedding","type":"string","default":"embedding","description":"The field with the embedding array","required":true},{"displayName":"Metadata Field","name":"metadata_field","type":"string","default":"text","description":"The text field of the raw data","required":true},{"displayName":"Vector Index Name","name":"vectorIndexName","type":"string","default":"","description":"The name of the vector index","required":true},{"displayName":"Embedding Batch Size","name":"embeddingBatchSize","type":"number","default":200,"description":"Number of documents to embed in a single batch","displayOptions":{"show":{"mode":["insert"],"@version":[{"_cnd":{"gte":1.1}}]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Clear Namespace","name":"clearNamespace","type":"boolean","default":false,"description":"Whether to clear documents in the namespace before inserting new data"},{"displayName":"Namespace","name":"namespace","type":"string","description":"Logical partition for documents. Uses metadata.namespace field for filtering.","default":""}],"displayOptions":{"show":{"mode":["insert"]}}},{"displayName":"Prompt","name":"prompt","type":"string","default":"","required":true,"description":"Search prompt to retrieve matching documents from the vector store using similarity-based ranking","displayOptions":{"show":{"mode":["load"]}}},{"displayName":"Limit","name":"topK","type":"number","default":4,"description":"Number of top results to fetch from vector store","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Include Metadata","name":"includeDocumentMetadata","type":"boolean","default":true,"description":"Whether or not to include document metadata","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Rerank Results","name":"useReranker","type":"boolean","default":false,"description":"Whether or not to rerank results","displayOptions":{"show":{"mode":["load","retrieve","retrieve-as-tool"]}}},{"displayName":"ID","name":"id","type":"string","default":"","required":true,"description":"ID of an embedding entry","displayOptions":{"show":{"mode":["update"]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Namespace","name":"namespace","type":"string","description":"Logical partition for documents. Uses metadata.namespace field for filtering.","default":""},{"displayName":"Metadata Filter","name":"metadata","type":"fixedCollection","description":"Metadata to filter the document by","typeOptions":{"multipleValues":true},"default":{},"placeholder":"Add filter field","options":[{"name":"metadataValues","displayName":"Fields to Set","values":[{"displayName":"Name","name":"name","type":"string","default":"","required":true},{"displayName":"Value","name":"value","type":"string","default":""}]}]},{"displayName":"Pre Filter","name":"preFilter","type":"json","typeOptions":{"alwaysOpenEditWindow":true},"default":"","placeholder":"{ \"key\": \"value\" }","hint":"This is a filter applied in the $vectorSearch stage <a href=\"https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#atlas-vector-search-pre-filter\">here</a>","required":true,"description":"MongoDB Atlas Vector Search pre-filter"},{"displayName":"Post Filter Pipeline","name":"postFilterPipeline","type":"json","typeOptions":{"alwaysOpenEditWindow":true},"default":"","placeholder":"[{ \"$match\": { \"$gt\": \"1950-01-01\" }, ... }]","hint":"Learn more about aggregation pipeline <a href=\"https://docs.mongodb.com/manual/core/aggregation-pipeline/\">here</a>","required":true,"description":"MongoDB aggregation pipeline in JSON format"}],"displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Namespace","name":"namespace","type":"string","description":"Logical partition for documents. Uses metadata.namespace field for filtering.","default":""},{"displayName":"Metadata Filter","name":"metadata","type":"fixedCollection","description":"Metadata to filter the document by","typeOptions":{"multipleValues":true},"default":{},"placeholder":"Add filter field","options":[{"name":"metadataValues","displayName":"Fields to Set","values":[{"displayName":"Name","name":"name","type":"string","default":"","required":true},{"displayName":"Value","name":"value","type":"string","default":""}]}]},{"displayName":"Pre Filter","name":"preFilter","type":"json","typeOptions":{"alwaysOpenEditWindow":true},"default":"","placeholder":"{ \"key\": \"value\" }","hint":"This is a filter applied in the $vectorSearch stage <a href=\"https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#atlas-vector-search-pre-filter\">here</a>","required":true,"description":"MongoDB Atlas Vector Search pre-filter"},{"displayName":"Post Filter Pipeline","name":"postFilterPipeline","type":"json","typeOptions":{"alwaysOpenEditWindow":true},"default":"","placeholder":"[{ \"$match\": { \"$gt\": \"1950-01-01\" }, ... }]","hint":"Learn more about aggregation pipeline <a href=\"https://docs.mongodb.com/manual/core/aggregation-pipeline/\">here</a>","required":true,"description":"MongoDB aggregation pipeline in JSON format"}],"displayOptions":{"show":{"mode":["retrieve"]}}}],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.dark.svg"}},
89
89
  {"displayName":"Postgres PGVector Store","name":"vectorStorePGVector","description":"Work with your data in Postgresql with the PGVector extension","group":["transform"],"version":[1,1.1,1.2,1.3],"defaults":{"name":"Postgres PGVector Store"},"codex":{"categories":["AI"],"subcategories":{"AI":["Vector Stores","Tools","Root Nodes"],"Vector Stores":["Other Vector Stores"],"Tools":["Other Tools"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstorepgvector/"}]}},"credentials":[{"name":"postgres","required":true,"testedBy":"postgresConnectionTest"}],"inputs":"={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst useReranker = parameters?.useReranker;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"ai_embedding\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (['load', 'retrieve', 'retrieve-as-tool'].includes(mode) && useReranker) {\n\t\t\t\t\tinputs.push({ displayName: \"Reranker\", type: \"ai_reranker\", required: true, maxConnections: 1})\n\t\t\t\t}\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: \"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: \"ai_document\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}","outputs":"={{\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: \"ai_tool\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"ai_vectorStore\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"main\"}]\n\t\t\t})($parameter)\n\t\t}}","properties":[{"displayName":"Tip: Get a feel for vector stores in n8n with our","name":"ragStarterCallout","type":"callout","typeOptions":{"calloutAction":{"label":"RAG starter template","type":"openSampleWorkflowTemplate","templateId":"rag-starter-template"}},"default":""},{"displayName":"Operation Mode","name":"mode","type":"options","noDataExpression":true,"default":"retrieve","options":[{"name":"Get Many","value":"load","description":"Get many ranked documents from vector store for query","action":"Get ranked documents from vector store"},{"name":"Insert Documents","value":"insert","description":"Insert documents into vector store","action":"Add documents to vector store"},{"name":"Retrieve Documents (As Vector Store for Chain/Tool)","value":"retrieve","description":"Retrieve documents from vector store to be used as vector store with AI nodes","action":"Retrieve documents for Chain/Tool as Vector Store","outputConnectionType":"ai_vectorStore"},{"name":"Retrieve Documents (As Tool for AI Agent)","value":"retrieve-as-tool","description":"Retrieve documents from vector store to be used as tool with AI nodes","action":"Retrieve documents for AI Agent as Tool","outputConnectionType":"ai_tool"}]},{"displayName":"This node must be connected to a vector store retriever. <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='ai_retriever'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"},"displayOptions":{"show":{"mode":["retrieve"]}}},{"displayName":"Name","name":"toolName","type":"string","default":"","required":true,"description":"Name of the vector store","placeholder":"e.g. company_knowledge_base","validateType":"string-alphanumeric","displayOptions":{"show":{"@version":[{"_cnd":{"lte":1.2}}],"mode":["retrieve-as-tool"]}}},{"displayName":"Description","name":"toolDescription","type":"string","default":"","required":true,"typeOptions":{"rows":2},"description":"Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often","placeholder":"e.g. Work with your data in Postgresql with the PGVector extension","displayOptions":{"show":{"mode":["retrieve-as-tool"]}}},{"displayName":"Table Name","name":"tableName","type":"string","default":"n8n_vectors","description":"The table name to store the vectors in. If table does not exist, it will be created."},{"displayName":"Embedding Batch Size","name":"embeddingBatchSize","type":"number","default":200,"description":"Number of documents to embed in a single batch","displayOptions":{"show":{"mode":["insert"],"@version":[{"_cnd":{"gte":1.1}}]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Collection","name":"collection","type":"fixedCollection","description":"Collection of vectors","default":{"values":{"useCollection":false,"collectionName":"n8n","collectionTable":"n8n_vector_collections"}},"typeOptions":{},"placeholder":"Add Collection Settings","options":[{"name":"values","displayName":"Collection Settings","values":[{"displayName":"Use Collection","name":"useCollection","type":"boolean","default":false},{"displayName":"Collection Name","name":"collectionName","type":"string","default":"n8n","required":true,"displayOptions":{"show":{"useCollection":[true]}}},{"displayName":"Collection Table Name","name":"collectionTableName","type":"string","default":"n8n_vector_collections","required":true,"displayOptions":{"show":{"useCollection":[true]}}}]}]},{"displayName":"Column Names","name":"columnNames","type":"fixedCollection","description":"The names of the columns in the PGVector table","default":{"values":{"idColumnName":"id","vectorColumnName":"embedding","contentColumnName":"text","metadataColumnName":"metadata"}},"typeOptions":{},"placeholder":"Set Column Names","options":[{"name":"values","displayName":"Column Name Settings","values":[{"displayName":"ID Column Name","name":"idColumnName","type":"string","default":"id","required":true},{"displayName":"Vector Column Name","name":"vectorColumnName","type":"string","default":"embedding","required":true},{"displayName":"Content Column Name","name":"contentColumnName","type":"string","default":"text","required":true},{"displayName":"Metadata Column Name","name":"metadataColumnName","type":"string","default":"metadata","required":true}]}]}],"displayOptions":{"show":{"mode":["insert"]}}},{"displayName":"Prompt","name":"prompt","type":"string","default":"","required":true,"description":"Search prompt to retrieve matching documents from the vector store using similarity-based ranking","displayOptions":{"show":{"mode":["load"]}}},{"displayName":"Limit","name":"topK","type":"number","default":4,"description":"Number of top results to fetch from vector store","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Include Metadata","name":"includeDocumentMetadata","type":"boolean","default":true,"description":"Whether or not to include document metadata","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Rerank Results","name":"useReranker","type":"boolean","default":false,"description":"Whether or not to rerank results","displayOptions":{"show":{"mode":["load","retrieve","retrieve-as-tool"]}}},{"displayName":"ID","name":"id","type":"string","default":"","required":true,"description":"ID of an embedding entry","displayOptions":{"show":{"mode":["update"]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Distance Strategy","name":"distanceStrategy","type":"options","default":"cosine","description":"The method to calculate the distance between two vectors","options":[{"name":"Cosine","value":"cosine"},{"name":"Inner Product","value":"innerProduct"},{"name":"Euclidean","value":"euclidean"}]},{"displayName":"Collection","name":"collection","type":"fixedCollection","description":"Collection of vectors","default":{"values":{"useCollection":false,"collectionName":"n8n","collectionTable":"n8n_vector_collections"}},"typeOptions":{},"placeholder":"Add Collection Settings","options":[{"name":"values","displayName":"Collection Settings","values":[{"displayName":"Use Collection","name":"useCollection","type":"boolean","default":false},{"displayName":"Collection Name","name":"collectionName","type":"string","default":"n8n","required":true,"displayOptions":{"show":{"useCollection":[true]}}},{"displayName":"Collection Table Name","name":"collectionTableName","type":"string","default":"n8n_vector_collections","required":true,"displayOptions":{"show":{"useCollection":[true]}}}]}]},{"displayName":"Column Names","name":"columnNames","type":"fixedCollection","description":"The names of the columns in the PGVector table","default":{"values":{"idColumnName":"id","vectorColumnName":"embedding","contentColumnName":"text","metadataColumnName":"metadata"}},"typeOptions":{},"placeholder":"Set Column Names","options":[{"name":"values","displayName":"Column Name Settings","values":[{"displayName":"ID Column Name","name":"idColumnName","type":"string","default":"id","required":true},{"displayName":"Vector Column Name","name":"vectorColumnName","type":"string","default":"embedding","required":true},{"displayName":"Content Column Name","name":"contentColumnName","type":"string","default":"text","required":true},{"displayName":"Metadata Column Name","name":"metadataColumnName","type":"string","default":"metadata","required":true}]}]},{"displayName":"Metadata Filter","name":"metadata","type":"fixedCollection","description":"Metadata to filter the document by","typeOptions":{"multipleValues":true},"default":{},"placeholder":"Add filter field","options":[{"name":"metadataValues","displayName":"Fields to Set","values":[{"displayName":"Name","name":"name","type":"string","default":"","required":true},{"displayName":"Value","name":"value","type":"string","default":""}]}]}],"displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Distance Strategy","name":"distanceStrategy","type":"options","default":"cosine","description":"The method to calculate the distance between two vectors","options":[{"name":"Cosine","value":"cosine"},{"name":"Inner Product","value":"innerProduct"},{"name":"Euclidean","value":"euclidean"}]},{"displayName":"Collection","name":"collection","type":"fixedCollection","description":"Collection of vectors","default":{"values":{"useCollection":false,"collectionName":"n8n","collectionTable":"n8n_vector_collections"}},"typeOptions":{},"placeholder":"Add Collection Settings","options":[{"name":"values","displayName":"Collection Settings","values":[{"displayName":"Use Collection","name":"useCollection","type":"boolean","default":false},{"displayName":"Collection Name","name":"collectionName","type":"string","default":"n8n","required":true,"displayOptions":{"show":{"useCollection":[true]}}},{"displayName":"Collection Table Name","name":"collectionTableName","type":"string","default":"n8n_vector_collections","required":true,"displayOptions":{"show":{"useCollection":[true]}}}]}]},{"displayName":"Column Names","name":"columnNames","type":"fixedCollection","description":"The names of the columns in the PGVector table","default":{"values":{"idColumnName":"id","vectorColumnName":"embedding","contentColumnName":"text","metadataColumnName":"metadata"}},"typeOptions":{},"placeholder":"Set Column Names","options":[{"name":"values","displayName":"Column Name Settings","values":[{"displayName":"ID Column Name","name":"idColumnName","type":"string","default":"id","required":true},{"displayName":"Vector Column Name","name":"vectorColumnName","type":"string","default":"embedding","required":true},{"displayName":"Content Column Name","name":"contentColumnName","type":"string","default":"text","required":true},{"displayName":"Metadata Column Name","name":"metadataColumnName","type":"string","default":"metadata","required":true}]}]},{"displayName":"Metadata Filter","name":"metadata","type":"fixedCollection","description":"Metadata to filter the document by","typeOptions":{"multipleValues":true},"default":{},"placeholder":"Add filter field","options":[{"name":"metadataValues","displayName":"Fields to Set","values":[{"displayName":"Name","name":"name","type":"string","default":"","required":true},{"displayName":"Value","name":"value","type":"string","default":""}]}]}],"displayOptions":{"show":{"mode":["retrieve"]}}}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStorePGVector/postgres.svg"},
90
90
  {"displayName":"Pinecone Vector Store","name":"vectorStorePinecone","description":"Work with your data in Pinecone Vector Store","group":["transform"],"version":[1,1.1,1.2,1.3],"defaults":{"name":"Pinecone Vector Store"},"codex":{"categories":["AI"],"subcategories":{"AI":["Vector Stores","Tools","Root Nodes"],"Vector Stores":["Other Vector Stores"],"Tools":["Other Tools"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstorepinecone/"}]}},"credentials":[{"name":"pineconeApi","required":true}],"inputs":"={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst useReranker = parameters?.useReranker;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"ai_embedding\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (['load', 'retrieve', 'retrieve-as-tool'].includes(mode) && useReranker) {\n\t\t\t\t\tinputs.push({ displayName: \"Reranker\", type: \"ai_reranker\", required: true, maxConnections: 1})\n\t\t\t\t}\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: \"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: \"ai_document\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}","outputs":"={{\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: \"ai_tool\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"ai_vectorStore\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"main\"}]\n\t\t\t})($parameter)\n\t\t}}","properties":[{"displayName":"Tip: Get a feel for vector stores in n8n with our","name":"ragStarterCallout","type":"callout","typeOptions":{"calloutAction":{"label":"RAG starter template","type":"openSampleWorkflowTemplate","templateId":"rag-starter-template"}},"default":""},{"displayName":"Operation Mode","name":"mode","type":"options","noDataExpression":true,"default":"retrieve","options":[{"name":"Get Many","value":"load","description":"Get many ranked documents from vector store for query","action":"Get ranked documents from vector store"},{"name":"Insert Documents","value":"insert","description":"Insert documents into vector store","action":"Add documents to vector store"},{"name":"Retrieve Documents (As Vector Store for Chain/Tool)","value":"retrieve","description":"Retrieve documents from vector store to be used as vector store with AI nodes","action":"Retrieve documents for Chain/Tool as Vector Store","outputConnectionType":"ai_vectorStore"},{"name":"Retrieve Documents (As Tool for AI Agent)","value":"retrieve-as-tool","description":"Retrieve documents from vector store to be used as tool with AI nodes","action":"Retrieve documents for AI Agent as Tool","outputConnectionType":"ai_tool"},{"name":"Update Documents","value":"update","description":"Update documents in vector store by ID","action":"Update vector store documents"}]},{"displayName":"This node must be connected to a vector store retriever. <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='ai_retriever'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"},"displayOptions":{"show":{"mode":["retrieve"]}}},{"displayName":"Name","name":"toolName","type":"string","default":"","required":true,"description":"Name of the vector store","placeholder":"e.g. company_knowledge_base","validateType":"string-alphanumeric","displayOptions":{"show":{"@version":[{"_cnd":{"lte":1.2}}],"mode":["retrieve-as-tool"]}}},{"displayName":"Description","name":"toolDescription","type":"string","default":"","required":true,"typeOptions":{"rows":2},"description":"Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often","placeholder":"e.g. Work with your data in Pinecone Vector Store","displayOptions":{"show":{"mode":["retrieve-as-tool"]}}},{"displayName":"Pinecone Index","name":"pineconeIndex","type":"resourceLocator","default":{"mode":"list","value":""},"required":true,"modes":[{"displayName":"From List","name":"list","type":"list","typeOptions":{"searchListMethod":"pineconeIndexSearch"}},{"displayName":"ID","name":"id","type":"string"}]},{"displayName":"Embedding Batch Size","name":"embeddingBatchSize","type":"number","default":200,"description":"Number of documents to embed in a single batch","displayOptions":{"show":{"mode":["insert"],"@version":[{"_cnd":{"gte":1.1}}]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Clear Namespace","name":"clearNamespace","type":"boolean","default":false,"description":"Whether to clear the namespace before inserting new data"},{"displayName":"Pinecone Namespace","name":"pineconeNamespace","type":"string","description":"Partition the records in an index into namespaces. Queries and other operations are then limited to one namespace, so different requests can search different subsets of your index.","default":""}],"displayOptions":{"show":{"mode":["insert"]}}},{"displayName":"Prompt","name":"prompt","type":"string","default":"","required":true,"description":"Search prompt to retrieve matching documents from the vector store using similarity-based ranking","displayOptions":{"show":{"mode":["load"]}}},{"displayName":"Limit","name":"topK","type":"number","default":4,"description":"Number of top results to fetch from vector store","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Include Metadata","name":"includeDocumentMetadata","type":"boolean","default":true,"description":"Whether or not to include document metadata","displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Rerank Results","name":"useReranker","type":"boolean","default":false,"description":"Whether or not to rerank results","displayOptions":{"show":{"mode":["load","retrieve","retrieve-as-tool"]}}},{"displayName":"ID","name":"id","type":"string","default":"","required":true,"description":"ID of an embedding entry","displayOptions":{"show":{"mode":["update"]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Pinecone Namespace","name":"pineconeNamespace","type":"string","description":"Partition the records in an index into namespaces. Queries and other operations are then limited to one namespace, so different requests can search different subsets of your index.","default":""},{"displayName":"Metadata Filter","name":"metadata","type":"fixedCollection","description":"Metadata to filter the document by","typeOptions":{"multipleValues":true},"default":{},"placeholder":"Add filter field","options":[{"name":"metadataValues","displayName":"Fields to Set","values":[{"displayName":"Name","name":"name","type":"string","default":"","required":true},{"displayName":"Value","name":"value","type":"string","default":""}]}]}],"displayOptions":{"show":{"mode":["load","retrieve-as-tool"]}}},{"displayName":"Options","name":"options","type":"collection","placeholder":"Add Option","default":{},"options":[{"displayName":"Pinecone Namespace","name":"pineconeNamespace","type":"string","description":"Partition the records in an index into namespaces. Queries and other operations are then limited to one namespace, so different requests can search different subsets of your index.","default":""},{"displayName":"Metadata Filter","name":"metadata","type":"fixedCollection","description":"Metadata to filter the document by","typeOptions":{"multipleValues":true},"default":{},"placeholder":"Add filter field","options":[{"name":"metadataValues","displayName":"Fields to Set","values":[{"displayName":"Name","name":"name","type":"string","default":"","required":true},{"displayName":"Value","name":"value","type":"string","default":""}]}]}],"displayOptions":{"show":{"mode":["retrieve"]}}}],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStorePinecone/pinecone.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStorePinecone/pinecone.dark.svg"}},
91
91
  {"displayName":"Pinecone: Insert","hidden":true,"name":"vectorStorePineconeInsert","group":["transform"],"version":1,"description":"Insert data into Pinecone Vector Store index","defaults":{"name":"Pinecone: Insert","color":"#1321A7"},"codex":{"categories":["AI"],"subcategories":{"AI":["Vector Stores"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstorepinecone/"}]}},"credentials":[{"name":"pineconeApi","required":true}],"inputs":["main",{"displayName":"Document","maxConnections":1,"type":"ai_document","required":true},{"displayName":"Embedding","maxConnections":1,"type":"ai_embedding","required":true}],"outputs":["main"],"properties":[{"displayName":"Pinecone Index","name":"pineconeIndex","type":"resourceLocator","default":{"mode":"list","value":""},"required":true,"modes":[{"displayName":"From List","name":"list","type":"list","typeOptions":{"searchListMethod":"pineconeIndexSearch"}},{"displayName":"ID","name":"id","type":"string"}]},{"displayName":"Pinecone Namespace","name":"pineconeNamespace","type":"string","default":""},{"displayName":"Specify the document to load in the document loader sub-node","name":"notice","type":"notice","default":""},{"displayName":"Clear Namespace","name":"clearNamespace","type":"boolean","default":false,"description":"Whether to clear the namespace before inserting new data"}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStorePineconeInsert/pinecone.svg"},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8n/n8n-nodes-langchain",
3
- "version": "1.109.1",
3
+ "version": "1.110.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -148,7 +148,7 @@
148
148
  "fast-glob": "3.2.12",
149
149
  "jest-mock-extended": "^3.0.4",
150
150
  "tsup": "^8.5.0",
151
- "n8n-core": "1.109.0"
151
+ "n8n-core": "1.110.0"
152
152
  },
153
153
  "dependencies": {
154
154
  "@aws-sdk/client-sso-oidc": "3.808.0",
@@ -217,10 +217,10 @@
217
217
  "zod-to-json-schema": "3.23.3",
218
218
  "@n8n/client-oauth2": "0.29.0",
219
219
  "@n8n/errors": "^0.5.0",
220
- "@n8n/typescript-config": "1.3.0",
221
220
  "@n8n/json-schema-to-zod": "1.5.0",
222
- "n8n-workflow": "1.107.0",
223
- "n8n-nodes-base": "1.108.0"
221
+ "n8n-workflow": "1.108.0",
222
+ "n8n-nodes-base": "1.109.0",
223
+ "@n8n/typescript-config": "1.3.0"
224
224
  },
225
225
  "license": "SEE LICENSE IN LICENSE.md",
226
226
  "homepage": "https://n8n.io",