@n8n/ai-utilities 0.4.1 → 0.5.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.
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +18 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/typecheck.tsbuildinfo +1 -1
- package/dist/cjs/utils/fromai-tool-factory.d.ts +14 -0
- package/dist/cjs/utils/fromai-tool-factory.js +45 -0
- package/dist/cjs/utils/fromai-tool-factory.js.map +1 -0
- package/dist/cjs/utils/shared-fields.d.ts +8 -0
- package/dist/cjs/utils/shared-fields.js +159 -0
- package/dist/cjs/utils/shared-fields.js.map +1 -0
- package/dist/cjs/utils/vector-store/MemoryManager/MemoryCalculator.d.ts +7 -0
- package/dist/cjs/utils/vector-store/MemoryManager/MemoryCalculator.js +60 -0
- package/dist/cjs/utils/vector-store/MemoryManager/MemoryCalculator.js.map +1 -0
- package/dist/cjs/utils/vector-store/MemoryManager/MemoryVectorStoreManager.d.ts +34 -0
- package/dist/cjs/utils/vector-store/MemoryManager/MemoryVectorStoreManager.js +186 -0
- package/dist/cjs/utils/vector-store/MemoryManager/MemoryVectorStoreManager.js.map +1 -0
- package/dist/cjs/utils/vector-store/MemoryManager/StoreCleanupService.d.ts +16 -0
- package/dist/cjs/utils/vector-store/MemoryManager/StoreCleanupService.js +105 -0
- package/dist/cjs/utils/vector-store/MemoryManager/StoreCleanupService.js.map +1 -0
- package/dist/cjs/utils/vector-store/MemoryManager/config.d.ts +4 -0
- package/dist/cjs/utils/vector-store/MemoryManager/config.js +48 -0
- package/dist/cjs/utils/vector-store/MemoryManager/config.js.map +1 -0
- package/dist/cjs/utils/vector-store/MemoryManager/types.d.ts +39 -0
- package/dist/cjs/utils/vector-store/MemoryManager/types.js +13 -0
- package/dist/cjs/utils/vector-store/MemoryManager/types.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/constants.d.ts +4 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/constants.js +55 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/constants.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/createVectorStoreNode.d.ts +18 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/createVectorStoreNode.js +294 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/createVectorStoreNode.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/index.d.ts +6 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/index.js +33 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/index.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/insertOperation.d.ts +5 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/insertOperation.js +48 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/insertOperation.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/loadOperation.d.ts +5 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/loadOperation.js +55 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/loadOperation.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.d.ts +5 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.js +74 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.d.ts +5 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.js +70 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveOperation.d.ts +5 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveOperation.js +39 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveOperation.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/updateOperation.d.ts +5 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/updateOperation.js +49 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/updateOperation.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/types.d.ts +39 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/types.js +13 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/types.js.map +1 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/utils.d.ts +6 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/utils.js +30 -0
- package/dist/cjs/utils/vector-store/createVectorStoreNode/utils.js.map +1 -0
- package/dist/cjs/utils/vector-store/processDocuments.d.ts +25 -0
- package/dist/cjs/utils/vector-store/processDocuments.js +52 -0
- package/dist/cjs/utils/vector-store/processDocuments.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +17 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/typecheck.tsbuildinfo +1 -1
- package/dist/esm/utils/fromai-tool-factory.d.ts +14 -0
- package/dist/esm/utils/fromai-tool-factory.js +35 -0
- package/dist/esm/utils/fromai-tool-factory.js.map +1 -0
- package/dist/esm/utils/shared-fields.d.ts +8 -0
- package/dist/esm/utils/shared-fields.js +149 -0
- package/dist/esm/utils/shared-fields.js.map +1 -0
- package/dist/esm/utils/vector-store/MemoryManager/MemoryCalculator.d.ts +7 -0
- package/dist/esm/utils/vector-store/MemoryManager/MemoryCalculator.js +50 -0
- package/dist/esm/utils/vector-store/MemoryManager/MemoryCalculator.js.map +1 -0
- package/dist/esm/utils/vector-store/MemoryManager/MemoryVectorStoreManager.d.ts +34 -0
- package/dist/esm/utils/vector-store/MemoryManager/MemoryVectorStoreManager.js +176 -0
- package/dist/esm/utils/vector-store/MemoryManager/MemoryVectorStoreManager.js.map +1 -0
- package/dist/esm/utils/vector-store/MemoryManager/StoreCleanupService.d.ts +16 -0
- package/dist/esm/utils/vector-store/MemoryManager/StoreCleanupService.js +95 -0
- package/dist/esm/utils/vector-store/MemoryManager/StoreCleanupService.js.map +1 -0
- package/dist/esm/utils/vector-store/MemoryManager/config.d.ts +4 -0
- package/dist/esm/utils/vector-store/MemoryManager/config.js +38 -0
- package/dist/esm/utils/vector-store/MemoryManager/config.js.map +1 -0
- package/dist/esm/utils/vector-store/MemoryManager/types.d.ts +39 -0
- package/dist/esm/utils/vector-store/MemoryManager/types.js +3 -0
- package/dist/esm/utils/vector-store/MemoryManager/types.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/constants.d.ts +4 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/constants.js +45 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/constants.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/createVectorStoreNode.d.ts +18 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/createVectorStoreNode.js +284 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/createVectorStoreNode.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/index.d.ts +6 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/index.js +23 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/index.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/insertOperation.d.ts +5 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/insertOperation.js +38 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/insertOperation.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/loadOperation.d.ts +5 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/loadOperation.js +45 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/loadOperation.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.d.ts +5 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.js +64 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.d.ts +5 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.js +60 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveOperation.d.ts +5 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveOperation.js +29 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/retrieveOperation.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/updateOperation.d.ts +5 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/updateOperation.js +39 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/operations/updateOperation.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/types.d.ts +39 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/types.js +3 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/types.js.map +1 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/utils.d.ts +6 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/utils.js +20 -0
- package/dist/esm/utils/vector-store/createVectorStoreNode/utils.js.map +1 -0
- package/dist/esm/utils/vector-store/processDocuments.d.ts +25 -0
- package/dist/esm/utils/vector-store/processDocuments.js +42 -0
- package/dist/esm/utils/vector-store/processDocuments.js.map +1 -0
- package/package.json +8 -5
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
(function (factory) {
|
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
+
var v = factory(require, exports);
|
|
18
|
+
if (v !== undefined) module.exports = v;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
|
21
|
+
define(["require", "exports", "./loadOperation", "./insertOperation", "./updateOperation", "./retrieveOperation", "./retrieveAsToolOperation", "./retrieveAsToolExecuteOperation"], factory);
|
|
22
|
+
}
|
|
23
|
+
})(function (require, exports) {
|
|
24
|
+
"use strict";
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
__exportStar(require("./loadOperation"), exports);
|
|
27
|
+
__exportStar(require("./insertOperation"), exports);
|
|
28
|
+
__exportStar(require("./updateOperation"), exports);
|
|
29
|
+
__exportStar(require("./retrieveOperation"), exports);
|
|
30
|
+
__exportStar(require("./retrieveAsToolOperation"), exports);
|
|
31
|
+
__exportStar(require("./retrieveAsToolExecuteOperation"), exports);
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/utils/vector-store/createVectorStoreNode/operations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IAAA,kDAAgC;IAChC,oDAAkC;IAClC,oDAAkC;IAClC,sDAAoC;IACpC,4DAA0C;IAC1C,mEAAiD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Embeddings } from '@langchain/core/embeddings';
|
|
2
|
+
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
3
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
4
|
+
import type { VectorStoreNodeConstructorArgs } from '../types';
|
|
5
|
+
export declare function handleInsertOperation<T extends VectorStore = VectorStore>(context: IExecuteFunctions, args: VectorStoreNodeConstructorArgs<T>, embeddings: Embeddings): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "n8n-workflow", "../../../log-ai-event", "../../processDocuments"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.handleInsertOperation = handleInsertOperation;
|
|
13
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
14
|
+
const log_ai_event_1 = require("../../../log-ai-event");
|
|
15
|
+
const processDocuments_1 = require("../../processDocuments");
|
|
16
|
+
async function handleInsertOperation(context, args, embeddings) {
|
|
17
|
+
const nodeVersion = context.getNode().typeVersion;
|
|
18
|
+
const items = context.getInputData();
|
|
19
|
+
const documentInput = (await context.getInputConnectionData(n8n_workflow_1.NodeConnectionTypes.AiDocument, 0));
|
|
20
|
+
const resultData = [];
|
|
21
|
+
const documentsForEmbedding = [];
|
|
22
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
23
|
+
if (context.getExecutionCancelSignal()?.aborted) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
const itemData = items[itemIndex];
|
|
27
|
+
const processedDocuments = await (0, processDocuments_1.processDocument)(documentInput, itemData, itemIndex);
|
|
28
|
+
resultData.push(...processedDocuments.serializedDocuments);
|
|
29
|
+
documentsForEmbedding.push(...processedDocuments.processedDocuments);
|
|
30
|
+
if (nodeVersion === 1) {
|
|
31
|
+
await args.populateVectorStore(context, embeddings, processedDocuments.processedDocuments, itemIndex);
|
|
32
|
+
}
|
|
33
|
+
(0, log_ai_event_1.logAiEvent)(context, 'ai-vector-store-populated');
|
|
34
|
+
}
|
|
35
|
+
if (nodeVersion >= 1.1) {
|
|
36
|
+
if (args.beforeInsert) {
|
|
37
|
+
await args.beforeInsert(context, embeddings, 0);
|
|
38
|
+
}
|
|
39
|
+
const embeddingBatchSize = context.getNodeParameter('embeddingBatchSize', 0, 200) ?? 200;
|
|
40
|
+
for (let i = 0; i < documentsForEmbedding.length; i += embeddingBatchSize) {
|
|
41
|
+
const nextBatch = documentsForEmbedding.slice(i, i + embeddingBatchSize);
|
|
42
|
+
await args.populateVectorStore(context, embeddings, nextBatch, 0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return resultData;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=insertOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertOperation.js","sourceRoot":"","sources":["../../../../../../src/utils/vector-store/createVectorStoreNode/operations/insertOperation.ts"],"names":[],"mappings":";;;;;;;;;;;IAgBA,sDAgEC;IA7ED,+CAAmD;IAGnD,wDAAmD;IAGnD,6DAAyD;IAOlD,KAAK,UAAU,qBAAqB,CAC1C,OAA0B,EAC1B,IAAuC,EACvC,UAAsB;QAEtB,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC;QAElD,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;QACrC,MA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CAAC,GAAG,qBAAqB,CAAC,MAAM,EAAE,CAAC,IAAI,kBAAkB,EAAE,CAAC;gBAC3E,MAAM,SAAS,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC;gBACzE,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YACnE,CAAC;QACF,CAAC;QAED,OAAO,UAAU,CAAC;IACnB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Embeddings } from '@langchain/core/embeddings';
|
|
2
|
+
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
3
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
4
|
+
import type { VectorStoreNodeConstructorArgs } from '../types';
|
|
5
|
+
export declare function handleLoadOperation<T extends VectorStore = VectorStore>(context: IExecuteFunctions, args: VectorStoreNodeConstructorArgs<T>, embeddings: Embeddings, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "n8n-workflow", "../../../helpers", "../../../log-ai-event"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.handleLoadOperation = handleLoadOperation;
|
|
13
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
14
|
+
const helpers_1 = require("../../../helpers");
|
|
15
|
+
const log_ai_event_1 = require("../../../log-ai-event");
|
|
16
|
+
async function handleLoadOperation(context, args, embeddings, itemIndex) {
|
|
17
|
+
const filter = (0, helpers_1.getMetadataFiltersValues)(context, itemIndex);
|
|
18
|
+
const vectorStore = await args.getVectorStoreClient(context, undefined, embeddings, itemIndex);
|
|
19
|
+
try {
|
|
20
|
+
const prompt = context.getNodeParameter('prompt', itemIndex);
|
|
21
|
+
const topK = context.getNodeParameter('topK', itemIndex, 4);
|
|
22
|
+
const useReranker = context.getNodeParameter('useReranker', itemIndex, false);
|
|
23
|
+
const includeDocumentMetadata = context.getNodeParameter('includeDocumentMetadata', itemIndex, true);
|
|
24
|
+
const embeddedPrompt = await embeddings.embedQuery(prompt);
|
|
25
|
+
let docs = await vectorStore.similaritySearchVectorWithScore(embeddedPrompt, topK, filter);
|
|
26
|
+
if (useReranker && docs.length > 0) {
|
|
27
|
+
const reranker = (await context.getInputConnectionData(n8n_workflow_1.NodeConnectionTypes.AiReranker, 0));
|
|
28
|
+
const documents = docs.map(([doc]) => doc);
|
|
29
|
+
const rerankedDocuments = await reranker.compressDocuments(documents, prompt);
|
|
30
|
+
docs = rerankedDocuments.map((doc) => {
|
|
31
|
+
const { relevanceScore, ...metadata } = doc.metadata || {};
|
|
32
|
+
return [{ ...doc, metadata }, relevanceScore];
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const serializedDocs = docs.map(([doc, score]) => {
|
|
36
|
+
const document = {
|
|
37
|
+
pageContent: doc.pageContent,
|
|
38
|
+
...(includeDocumentMetadata ? { metadata: doc.metadata } : {}),
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
json: { document, score },
|
|
42
|
+
pairedItem: {
|
|
43
|
+
item: itemIndex,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
(0, log_ai_event_1.logAiEvent)(context, 'ai-vector-store-searched', { query: prompt });
|
|
48
|
+
return serializedDocs;
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=loadOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadOperation.js","sourceRoot":"","sources":["../../../../../../src/utils/vector-store/createVectorStoreNode/operations/loadOperation.ts"],"names":[],"mappings":";;;;;;;;;;;IAcA,kDAuEC;IAlFD,+CAAmD;IAGnD,8CAA4D;IAC5D,wDAAmD;IAO5C,KAAK,UAAU,mBAAmB,CACxC,OAA0B,EAC1B,IAAuC,EACvC,UAAsB,EACtB,SAAiB;QAEjB,MAAM,MAAM,GAAG,IAAA,kCAAwB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAClD,OAAO,EAEP,SAAS,EACT,UAAU,EACV,SAAS,CACT,CAAC;QAEF,IAAI,CAAC;YAEJ,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAW,CAAC;YACvE,MAAM,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAW,CAAC;YACtE,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,CAAY,CAAC;YAEzF,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CACvD,yBAAyB,EACzB,SAAS,EACT,IAAI,CACO,CAAC;YAGb,MAAM,cAAc,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAG3D,IAAI,IAAI,GAAG,MAAM,WAAW,CAAC,+BAA+B,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAG3F,IAAI,WAAW,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,MAAM,QAAQ,GAAG,CAAC,MAAM,OAAO,CAAC,sBAAsB,CACrD,kCAAmB,CAAC,UAAU,EAC9B,CAAC,CACD,C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eddings';
|
|
2
|
+
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
3
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
4
|
+
import type { VectorStoreNodeConstructorArgs } from '../types';
|
|
5
|
+
export declare function handleRetrieveAsToolExecuteOperation<T extends VectorStore = VectorStore>(context: IExecuteFunctions, args: VectorStoreNodeConstructorArgs<T>, embeddings: Embeddings, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "n8n-workflow", "../../../helpers", "../../../log-ai-event"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.handleRetrieveAsToolExecuteOperation = handleRetrieveAsToolExecuteOperation;
|
|
13
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
14
|
+
const helpers_1 = require("../../../helpers");
|
|
15
|
+
const log_ai_event_1 = require("../../../log-ai-event");
|
|
16
|
+
async function handleRetrieveAsToolExecuteOperation(context, args, embeddings, itemIndex) {
|
|
17
|
+
const filter = (0, helpers_1.getMetadataFiltersValues)(context, itemIndex);
|
|
18
|
+
const vectorStore = await args.getVectorStoreClient(context, undefined, embeddings, itemIndex);
|
|
19
|
+
try {
|
|
20
|
+
const inputData = context.getInputData();
|
|
21
|
+
const item = inputData[itemIndex];
|
|
22
|
+
const query = typeof item.json.input === 'string' ? item.json.input : undefined;
|
|
23
|
+
if (!query || typeof query !== 'string') {
|
|
24
|
+
throw new Error('Input data must contain a "input" field with the search query');
|
|
25
|
+
}
|
|
26
|
+
const topK = context.getNodeParameter('topK', itemIndex, 4);
|
|
27
|
+
(0, n8n_workflow_1.assertParamIsNumber)('topK', topK, context.getNode());
|
|
28
|
+
const useReranker = context.getNodeParameter('useReranker', itemIndex, false);
|
|
29
|
+
(0, n8n_workflow_1.assertParamIsBoolean)('useReranker', useReranker, context.getNode());
|
|
30
|
+
const includeDocumentMetadata = context.getNodeParameter('includeDocumentMetadata', itemIndex, true);
|
|
31
|
+
(0, n8n_workflow_1.assertParamIsBoolean)('includeDocumentMetadata', includeDocumentMetadata, context.getNode());
|
|
32
|
+
const embeddedQuery = await embeddings.embedQuery(query);
|
|
33
|
+
let docs = await vectorStore.similaritySearchVectorWithScore(embeddedQuery, topK, filter);
|
|
34
|
+
if (useReranker && docs.length > 0) {
|
|
35
|
+
const reranker = (await context.getInputConnectionData(n8n_workflow_1.NodeConnectionTypes.AiReranker, 0));
|
|
36
|
+
const documents = docs.map(([doc]) => doc);
|
|
37
|
+
const rerankedDocuments = await reranker.compressDocuments(documents, query);
|
|
38
|
+
docs = rerankedDocuments.map((doc) => {
|
|
39
|
+
const { relevanceScore, ...metadata } = doc.metadata || {};
|
|
40
|
+
return [{ ...doc, metadata }, relevanceScore ?? 0];
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const serializedDocs = docs.map(([doc]) => {
|
|
44
|
+
if (includeDocumentMetadata) {
|
|
45
|
+
return {
|
|
46
|
+
type: 'text',
|
|
47
|
+
text: JSON.stringify({ ...doc }),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return {
|
|
52
|
+
type: 'text',
|
|
53
|
+
pageContent: JSON.stringify({ pageContent: doc.pageContent }),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
(0, log_ai_event_1.logAiEvent)(context, 'ai-vector-store-searched', { input: query });
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
json: {
|
|
61
|
+
response: serializedDocs,
|
|
62
|
+
},
|
|
63
|
+
pairedItem: {
|
|
64
|
+
item: itemIndex,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=retrieveAsToolExecuteOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieveAsToolExecuteOperation.js","sourceRoot":"","sources":["../../../../../../src/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.ts"],"names":[],"mappings":";;;;;;;;;;;IAeA,oFA0FC;IAtGD,+CAA8F;IAG9F,8CAA4D;IAC5D,wDAAmD;IAQ5C,KAAK,UAAU,oCAAoC,CACzD,OAA0B,EAC1B,IAAuC,EACvC,UAAsB,EACtB,SAAiB;QAEjB,MAAM,MAAM,GAAG,IAAA,kCAAwB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAClD,OAAO,EAEP,SAAS,EACT,UAAU,EACV,SAAS,CACT,CAAC;QAEF,IAAI,CAAC;YAEJ,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACzC,MAAM,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YAEhF,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;YAClF,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;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,EAAE,EAAE,cAAc,IAAI,CAAC,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAC;YACJ,CAAC;YAGD,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE;gBACzC,IAAI,uBAAuB,EAAE,CAAC;oBAC7B,OAAO;wBACN,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC;qBAChC,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACP,OAAO;wBACN,IAAI,EAAE,MAAM;wBACZ,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;qBAC7D,CAAC;gBACH,CAAC;YACF,CAAC,CAAC,CAAC;YAGH,IAAA,yBAAU,EAAC,OAAO,EAAE,0BAA0B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YAElE,OAAO;gBACN;oBACC,IAAI,EAAE;wBACL,QAAQ,EAAE,cAAc;qBACxB;oBACD,UAAU,EAAE;wBACX,IAAI,EAAE,SAAS;qBACf;iBACD;aACD,CAAC;QACH,CAAC;gBAAS,CAAC;YAEV,IAAI,CAAC,wBAAwB,EAAE,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC"}
|
package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Embeddings } from '@langchain/core/embeddings';
|
|
2
|
+
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
3
|
+
import type { ISupplyDataFunctions, SupplyData } from 'n8n-workflow';
|
|
4
|
+
import type { VectorStoreNodeConstructorArgs } from '../types';
|
|
5
|
+
export declare function handleRetrieveAsToolOperation<T extends VectorStore = VectorStore>(context: ISupplyDataFunctions, args: VectorStoreNodeConstructorArgs<T>, embeddings: Embeddings, itemIndex: number): Promise<SupplyData>;
|
package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "n8n-workflow", "../../../fromai-tool-factory", "../../../helpers", "../../../log-wrapper"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.handleRetrieveAsToolOperation = handleRetrieveAsToolOperation;
|
|
13
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
14
|
+
const fromai_tool_factory_1 = require("../../../fromai-tool-factory");
|
|
15
|
+
const helpers_1 = require("../../../helpers");
|
|
16
|
+
const log_wrapper_1 = require("../../../log-wrapper");
|
|
17
|
+
async function handleRetrieveAsToolOperation(context, args, embeddings, itemIndex) {
|
|
18
|
+
const toolDescription = context.getNodeParameter('toolDescription', itemIndex);
|
|
19
|
+
const node = context.getNode();
|
|
20
|
+
const { typeVersion } = node;
|
|
21
|
+
const toolName = typeVersion < 1.3
|
|
22
|
+
? context.getNodeParameter('toolName', itemIndex)
|
|
23
|
+
: (0, n8n_workflow_1.nodeNameToToolName)(node);
|
|
24
|
+
const vectorStoreTool = (0, fromai_tool_factory_1.createToolFromNode)(node, {
|
|
25
|
+
name: toolName,
|
|
26
|
+
description: toolDescription,
|
|
27
|
+
extraArgs: [{ key: 'input', description: 'Query to search for. Required' }],
|
|
28
|
+
func: async (query) => {
|
|
29
|
+
const topK = context.getNodeParameter('topK', itemIndex, 4);
|
|
30
|
+
const useReranker = context.getNodeParameter('useReranker', itemIndex, false);
|
|
31
|
+
const includeDocumentMetadata = context.getNodeParameter('includeDocumentMetadata', itemIndex, true);
|
|
32
|
+
const filter = (0, helpers_1.getMetadataFiltersValues)(context, itemIndex);
|
|
33
|
+
const queryString = typeof query === 'string' ? query : query.input;
|
|
34
|
+
(0, n8n_workflow_1.assert)(typeof queryString === 'string', 'Query must be of type string');
|
|
35
|
+
const vectorStore = await args.getVectorStoreClient(context, undefined, embeddings, itemIndex);
|
|
36
|
+
try {
|
|
37
|
+
const embeddedPrompt = await embeddings.embedQuery(queryString);
|
|
38
|
+
let documents = await vectorStore.similaritySearchVectorWithScore(embeddedPrompt, topK, filter);
|
|
39
|
+
if (useReranker && documents.length > 0) {
|
|
40
|
+
const reranker = (await context.getInputConnectionData(n8n_workflow_1.NodeConnectionTypes.AiReranker, 0));
|
|
41
|
+
const docs = documents.map(([doc]) => doc);
|
|
42
|
+
const rerankedDocuments = await reranker.compressDocuments(docs, queryString);
|
|
43
|
+
documents = rerankedDocuments.map((doc) => {
|
|
44
|
+
const { relevanceScore, ...metadata } = doc.metadata;
|
|
45
|
+
return [{ ...doc, metadata }, relevanceScore];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return documents
|
|
49
|
+
.map((document) => {
|
|
50
|
+
if (includeDocumentMetadata) {
|
|
51
|
+
return { type: 'text', text: JSON.stringify(document[0]) };
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
type: 'text',
|
|
55
|
+
text: JSON.stringify({ pageContent: document[0].pageContent }),
|
|
56
|
+
};
|
|
57
|
+
})
|
|
58
|
+
.filter((document) => !!document);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
response: (0, log_wrapper_1.logWrapper)(vectorStoreTool, context),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=retrieveAsToolOperation.js.map
|
package/dist/cjs/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieveAsToolOperation.js","sourceRoot":"","sources":["../../../../../../src/utils/vector-store/createVectorStoreNode/operations/retrieveAsToolOperation.ts"],"names":[],"mappings":";;;;;;;;;;;IAeA,sEAgGC;IA5GD,+CAA+E;IAG/E,sEAAkE;IAClE,8CAA4D;IAC5D,sDAAkD;IAO3C,KAAK,UAAU,6BAA6B,CAClD,OAA6B,EAC7B,IAAuC,EACvC,UAAsB,EACtB,SAAiB;QAGjB,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,SAAS,CAAW,CAAC;QAEzF,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAC7B,MAAM,QAAQ,GACb,WAAW,GAAG,GAAG;YAChB,CAAC,CAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAY;YAC7D,CAAC,CAAC,IAAA,iCAAkB,EAAC,IAAI,CAAC,CAAC;QAG7B,MAAM,eAAe,GAAG,IAAA,wCAAkB,EAAC,IAAI,EAAE;YAChD,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,eAAe;YAC5B,SAAS,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;YAC3E,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;gBACrB,MAAM,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAW,CAAC;gBACtE,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,CAAY,CAAC;gBACzF,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CACvD,yBA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wBAC/C,CAAC,CAAC,CAAC;oBACJ,CAAC;oBAGD,OAAO,SAAS;yBACd,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;wBACjB,IAAI,uBAAuB,EAAE,CAAC;4BAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;wBAC5D,CAAC;wBACD,OAAO;4BACN,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;yBAC9D,CAAC;oBACH,CAAC,CAAC;yBACD,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;gBACpC,CAAC;wBAAS,CAAC;oBAEV,IAAI,CAAC,wBAAwB,EAAE,CAAC,WAAW,CAAC,CAAC;gBAC9C,CAAC;YACF,CAAC;SACD,CAAC,CAAC;QAGH,OAAO;YACN,QAAQ,EAAE,IAAA,wBAAU,EAAC,eAAe,EAAE,OAAO,CAAC;SAC9C,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Embeddings } from '@langchain/core/embeddings';
|
|
2
|
+
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
3
|
+
import type { ISupplyDataFunctions, SupplyData } from 'n8n-workflow';
|
|
4
|
+
import type { VectorStoreNodeConstructorArgs } from '../types';
|
|
5
|
+
export declare function handleRetrieveOperation<T extends VectorStore = VectorStore>(context: ISupplyDataFunctions, args: VectorStoreNodeConstructorArgs<T>, embeddings: Embeddings, itemIndex: number): Promise<SupplyData>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "n8n-workflow", "../../../helpers", "../../../log-wrapper"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.handleRetrieveOperation = handleRetrieveOperation;
|
|
13
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
14
|
+
const helpers_1 = require("../../../helpers");
|
|
15
|
+
const log_wrapper_1 = require("../../../log-wrapper");
|
|
16
|
+
async function handleRetrieveOperation(context, args, embeddings, itemIndex) {
|
|
17
|
+
const filter = (0, helpers_1.getMetadataFiltersValues)(context, itemIndex);
|
|
18
|
+
const useReranker = context.getNodeParameter('useReranker', itemIndex, false);
|
|
19
|
+
const vectorStore = await args.getVectorStoreClient(context, filter, embeddings, itemIndex);
|
|
20
|
+
let response = vectorStore;
|
|
21
|
+
if (useReranker) {
|
|
22
|
+
const reranker = (await context.getInputConnectionData(n8n_workflow_1.NodeConnectionTypes.AiReranker, 0));
|
|
23
|
+
response = {
|
|
24
|
+
reranker,
|
|
25
|
+
vectorStore: (0, log_wrapper_1.logWrapper)(vectorStore, context),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
response = (0, log_wrapper_1.logWrapper)(vectorStore, context);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
response,
|
|
33
|
+
closeFunction: async () => {
|
|
34
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=retrieveOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieveOperation.js","sourceRoot":"","sources":["../../../../../../src/utils/vector-store/createVectorStoreNode/operations/retrieveOperation.ts"],"names":[],"mappings":";;;;;;;;;;;IAcA,0DAsCC;IAjDD,+CAAmD;IAGnD,8CAA4D;IAC5D,sDAAkD;IAO3C,KAAK,UAAU,uBAAuB,CAC5C,OAA6B,EAC7B,IAAuC,EACvC,UAAsB,EACtB,SAAiB;QAGjB,MAAM,MAAM,GAAG,IAAA,kCAAwB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,CAAY,CAAC;QAGzF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAC5F,IAAI,QAAQ,GACX,WAAW,CAAC;QAEb,IAAI,WAAW,EAAE,CAAC;YACjB,MAAM,QAAQ,GAAG,CAAC,MAAM,OAAO,CAAC,sBAAsB,CACrD,kCAAmB,CAAC,UAAU,EAC9B,CAAC,CACD,CAA2B,CAAC;YAG7B,QAAQ,GAAG;gBACV,QAAQ;gBACR,WAAW,EAAE,IAAA,wBAAU,EAAC,WAAW,EAAE,OAAO,CAAC;aAC7C,CAAC;QACH,CAAC;aAAM,CAAC;YAEP,QAAQ,GAAG,IAAA,wBAAU,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO;YACN,QAAQ;YACR,aAAa,EAAE,KAAK,IAAI,EAAE;gBAEzB,IAAI,CAAC,wBAAwB,EAAE,CAAC,WAAW,CAAC,CAAC;YAC9C,CAAC;SACD,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Embeddings } from '@langchain/core/embeddings';
|
|
2
|
+
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
3
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
4
|
+
import type { VectorStoreNodeConstructorArgs } from '../types';
|
|
5
|
+
export declare function handleUpdateOperation<T extends VectorStore = VectorStore>(context: IExecuteFunctions, args: VectorStoreNodeConstructorArgs<T>, embeddings: Embeddings): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "n8n-workflow", "../../../log-ai-event", "../../../n8n-json-loader", "../../processDocuments", "../utils"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.handleUpdateOperation = handleUpdateOperation;
|
|
13
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
14
|
+
const log_ai_event_1 = require("../../../log-ai-event");
|
|
15
|
+
const n8n_json_loader_1 = require("../../../n8n-json-loader");
|
|
16
|
+
const processDocuments_1 = require("../../processDocuments");
|
|
17
|
+
const utils_1 = require("../utils");
|
|
18
|
+
async function handleUpdateOperation(context, args, embeddings) {
|
|
19
|
+
if (!(0, utils_1.isUpdateSupported)(args)) {
|
|
20
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Update operation is not implemented for this Vector Store');
|
|
21
|
+
}
|
|
22
|
+
const items = context.getInputData();
|
|
23
|
+
const loader = new n8n_json_loader_1.N8nJsonLoader(context);
|
|
24
|
+
const resultData = [];
|
|
25
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
26
|
+
const itemData = items[itemIndex];
|
|
27
|
+
const documentId = context.getNodeParameter('id', itemIndex, '', {
|
|
28
|
+
extractValue: true,
|
|
29
|
+
});
|
|
30
|
+
const vectorStore = await args.getVectorStoreClient(context, undefined, embeddings, itemIndex);
|
|
31
|
+
try {
|
|
32
|
+
const { processedDocuments, serializedDocuments } = await (0, processDocuments_1.processDocument)(loader, itemData, itemIndex);
|
|
33
|
+
if (processedDocuments?.length !== 1) {
|
|
34
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Single document per item expected');
|
|
35
|
+
}
|
|
36
|
+
resultData.push(...serializedDocuments);
|
|
37
|
+
await vectorStore.addDocuments(processedDocuments, {
|
|
38
|
+
ids: [documentId],
|
|
39
|
+
});
|
|
40
|
+
(0, log_ai_event_1.logAiEvent)(context, 'ai-vector-store-updated');
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return resultData;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=updateOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateOperation.js","sourceRoot":"","sources":["../../../../../../src/utils/vector-store/createVectorStoreNode/operations/updateOperation.ts"],"names":[],"mappings":";;;;;;;;;;;IAeA,sDA8DC;IA3ED,+CAAkD;IAGlD,wDAAmD;IACnD,8DAAyD;IACzD,6DAAyD;IAEzD,oCAA6C;IAMtC,KAAK,UAAU,qBAAqB,CAC1C,OAA0B,EAC1B,IAAuC,EACvC,UAAsB;QAGtB,IAAI,CAAC,IAAA,yBAAiB,EAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,iCAAkB,CAC3B,OAAO,CAAC,OAAO,EAAE,EACjB,2DAA2D,CAC3D,CAAC;QACH,CAAC;QAGD,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;QAErC,MAAM,MAAM,GAAG,IAAI,+BAAa,CAAC,OAAO,CAAC,CAAC;QAE1C,MAAM,UAAU,GAAyB,EAAE,CAAC;QAG5C,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC;YAC/D,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;YAGlC,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;gBAChE,YAAY,EAAE,IAAI;aAClB,CAAW,CAAC;YAGb,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;YAE/F,IAAI,CAAC;gBAEJ,MAAM,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,GAAG,MAAM,IAAA,kCAAe,EACxE,MAAM,EACN,QAAQ,EACR,SAAS,CACT,CAAC;gBAGF,IAAI,kBAAkB,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;oBACtC,MAAM,IAAI,iCAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,mCAAmC,CAAC,CAAC;gBACtF,CAAC;gBAGD,UAAU,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC;gBAGxC,MAAM,WAAW,CAAC,YAAY,CAAC,kBAAkB,EAAE;oBAClD,GAAG,EAAE,CAAC,UAAU,CAAC;iBACjB,CAAC,CAAC;gBAGH,IAAA,yBAAU,EAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;YAChD,CAAC;oBAAS,CAAC;gBAEV,IAAI,CAAC,wBAAwB,EAAE,CAAC,WAAW,CAAC,CAAC;YAC9C,CAAC;QACF,CAAC;QAED,OAAO,UAAU,CAAC;IACnB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Document } from '@langchain/core/documents';
|
|
2
|
+
import type { Embeddings } from '@langchain/core/embeddings';
|
|
3
|
+
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
4
|
+
import type { IExecuteFunctions, INodeCredentialDescription, INodeProperties, ILoadOptionsFunctions, INodeListSearchResult, Icon, ISupplyDataFunctions, ThemeIconColor, IDataObject, NodeParameterValueType, IBuilderHint } from 'n8n-workflow';
|
|
5
|
+
export type NodeOperationMode = 'insert' | 'load' | 'retrieve' | 'update' | 'retrieve-as-tool';
|
|
6
|
+
export interface NodeMeta {
|
|
7
|
+
displayName: string;
|
|
8
|
+
name: string;
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
description: string;
|
|
11
|
+
docsUrl: string;
|
|
12
|
+
icon: Icon;
|
|
13
|
+
iconColor?: ThemeIconColor;
|
|
14
|
+
credentials?: INodeCredentialDescription[];
|
|
15
|
+
operationModes?: NodeOperationMode[];
|
|
16
|
+
categories?: string[];
|
|
17
|
+
subcategories?: Record<string, string[]>;
|
|
18
|
+
builderHint?: IBuilderHint;
|
|
19
|
+
}
|
|
20
|
+
export interface VectorStoreNodeConstructorArgs<T extends VectorStore = VectorStore> {
|
|
21
|
+
meta: NodeMeta;
|
|
22
|
+
methods?: {
|
|
23
|
+
listSearch?: {
|
|
24
|
+
[key: string]: (this: ILoadOptionsFunctions, filter?: string, paginationToken?: string) => Promise<INodeListSearchResult>;
|
|
25
|
+
};
|
|
26
|
+
actionHandler?: {
|
|
27
|
+
[functionName: string]: (this: ILoadOptionsFunctions, payload: IDataObject | string | undefined) => Promise<NodeParameterValueType>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
sharedFields: INodeProperties[];
|
|
31
|
+
insertFields?: INodeProperties[];
|
|
32
|
+
loadFields?: INodeProperties[];
|
|
33
|
+
retrieveFields?: INodeProperties[];
|
|
34
|
+
updateFields?: INodeProperties[];
|
|
35
|
+
beforeInsert?: (context: IExecuteFunctions | ISupplyDataFunctions, embeddings: Embeddings, itemIndex: number) => Promise<void>;
|
|
36
|
+
populateVectorStore: (context: IExecuteFunctions | ISupplyDataFunctions, embeddings: Embeddings, documents: Array<Document<Record<string, unknown>>>, itemIndex: number) => Promise<void>;
|
|
37
|
+
getVectorStoreClient: (context: IExecuteFunctions | ISupplyDataFunctions, filter: Record<string, never> | undefined, embeddings: Embeddings, itemIndex: number) => Promise<T>;
|
|
38
|
+
releaseVectorStoreClient?: (vectorStore: T) => void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/utils/vector-store/createVectorStoreNode/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
2
|
+
import type { INodeProperties, INodePropertyOptions } from 'n8n-workflow';
|
|
3
|
+
import type { NodeOperationMode, VectorStoreNodeConstructorArgs } from './types';
|
|
4
|
+
export declare function transformDescriptionForOperationMode(fields: INodeProperties[], mode: NodeOperationMode | NodeOperationMode[]): INodeProperties[];
|
|
5
|
+
export declare function isUpdateSupported<T extends VectorStore>(args: VectorStoreNodeConstructorArgs<T>): boolean;
|
|
6
|
+
export declare function getOperationModeOptions<T extends VectorStore>(args: VectorStoreNodeConstructorArgs<T>): INodePropertyOptions[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./constants"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.transformDescriptionForOperationMode = transformDescriptionForOperationMode;
|
|
13
|
+
exports.isUpdateSupported = isUpdateSupported;
|
|
14
|
+
exports.getOperationModeOptions = getOperationModeOptions;
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
|
+
function transformDescriptionForOperationMode(fields, mode) {
|
|
17
|
+
return fields.map((field) => ({
|
|
18
|
+
...field,
|
|
19
|
+
displayOptions: { show: { mode: Array.isArray(mode) ? mode : [mode] } },
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
function isUpdateSupported(args) {
|
|
23
|
+
return args.meta.operationModes?.includes('update') ?? false;
|
|
24
|
+
}
|
|
25
|
+
function getOperationModeOptions(args) {
|
|
26
|
+
const enabledOperationModes = args.meta.operationModes ?? constants_1.DEFAULT_OPERATION_MODES;
|
|
27
|
+
return constants_1.OPERATION_MODE_DESCRIPTIONS.filter(({ value }) => enabledOperationModes.includes(value));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/utils/vector-store/createVectorStoreNode/utils.ts"],"names":[],"mappings":";;;;;;;;;;;IAUA,oFAQC;IAMD,8CAIC;IAMD,0DAQC;IAvCD,2CAAmF;IAOnF,SAAgB,oCAAoC,CACnD,MAAyB,EACzB,IAA6C;QAE7C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7B,GAAG,KAAK;YACR,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE;SACvE,CAAC,CAAC,CAAC;IACL,CAAC;IAMD,SAAgB,iBAAiB,CAChC,IAAuC;QAEvC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;IAC9D,CAAC;IAMD,SAAgB,uBAAuB,CACtC,IAAuC;QAEvC,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,mCAAuB,CAAC;QAElF,OAAO,uCAA2B,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACvD,qBAAqB,CAAC,QAAQ,CAAC,KAA0B,CAAC,CAC1D,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Document } from '@langchain/core/documents';
|
|
2
|
+
import type { INodeExecutionData } from 'n8n-workflow';
|
|
3
|
+
import { N8nBinaryLoader } from '../n8n-binary-loader';
|
|
4
|
+
import { N8nJsonLoader } from '../n8n-json-loader';
|
|
5
|
+
export declare function processDocuments(documentInput: N8nJsonLoader | N8nBinaryLoader | Array<Document<Record<string, unknown>>>, inputItems: INodeExecutionData[]): Promise<{
|
|
6
|
+
processedDocuments: Document<Record<string, any>>[];
|
|
7
|
+
serializedDocuments: {
|
|
8
|
+
json: {
|
|
9
|
+
metadata: Record<string, any>;
|
|
10
|
+
pageContent: string;
|
|
11
|
+
};
|
|
12
|
+
}[];
|
|
13
|
+
}>;
|
|
14
|
+
export declare function processDocument(documentInput: N8nJsonLoader | N8nBinaryLoader | Array<Document<Record<string, unknown>>>, inputItem: INodeExecutionData, itemIndex: number): Promise<{
|
|
15
|
+
processedDocuments: Document<Record<string, any>>[];
|
|
16
|
+
serializedDocuments: {
|
|
17
|
+
json: {
|
|
18
|
+
metadata: Record<string, any>;
|
|
19
|
+
pageContent: string;
|
|
20
|
+
};
|
|
21
|
+
pairedItem: {
|
|
22
|
+
item: number;
|
|
23
|
+
};
|
|
24
|
+
}[];
|
|
25
|
+
}>;
|