@n8n/n8n-nodes-langchain 1.83.1 → 1.84.1
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/build.tsbuildinfo +1 -1
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/agents/Agent/Agent.node.js +5 -1
- package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js +9 -19
- package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/OpenAiFunctionsAgent/execute.js +3 -7
- package/dist/nodes/agents/Agent/agents/OpenAiFunctionsAgent/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/PlanAndExecuteAgent/execute.js +3 -7
- package/dist/nodes/agents/Agent/agents/PlanAndExecuteAgent/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js +3 -7
- package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js +5 -6
- package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/ChainLlm.node.js +17 -389
- package/dist/nodes/chains/ChainLLM/ChainLlm.node.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/methods/chainExecutor.d.ts +15 -0
- package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js +69 -0
- package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js.map +1 -0
- package/dist/nodes/chains/ChainLLM/methods/config.d.ts +14 -0
- package/dist/nodes/chains/ChainLLM/methods/config.js +253 -0
- package/dist/nodes/chains/ChainLLM/methods/config.js.map +1 -0
- package/dist/nodes/chains/ChainLLM/methods/imageUtils.d.ts +12 -0
- package/dist/nodes/chains/ChainLLM/methods/imageUtils.js +66 -0
- package/dist/nodes/chains/ChainLLM/methods/imageUtils.js.map +1 -0
- package/dist/nodes/chains/ChainLLM/methods/index.d.ts +4 -0
- package/dist/nodes/chains/ChainLLM/methods/index.js +11 -0
- package/dist/nodes/chains/ChainLLM/methods/index.js.map +1 -0
- package/dist/nodes/chains/ChainLLM/methods/promptUtils.d.ts +3 -0
- package/dist/nodes/chains/ChainLLM/methods/promptUtils.js +69 -0
- package/dist/nodes/chains/ChainLLM/methods/promptUtils.js.map +1 -0
- package/dist/nodes/chains/ChainLLM/methods/responseFormatter.d.ts +2 -0
- package/dist/nodes/chains/ChainLLM/methods/responseFormatter.js +29 -0
- package/dist/nodes/chains/ChainLLM/methods/responseFormatter.js.map +1 -0
- package/dist/nodes/chains/ChainLLM/methods/types.d.ts +28 -0
- package/dist/nodes/chains/ChainLLM/methods/types.js +3 -0
- package/dist/nodes/chains/ChainLLM/methods/types.js.map +1 -0
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +68 -33
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +1 -0
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +1 -1
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js +1 -1
- package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.d.ts +16 -0
- package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.js +244 -0
- package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.js.map +1 -0
- package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.dark.svg +3 -0
- package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.svg +3 -0
- package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js +1 -1
- package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStorePinecone/VectorStorePinecone.node.js +2 -2
- package/dist/nodes/vector_store/VectorStorePinecone/VectorStorePinecone.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.d.ts +1 -1
- package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.js +1 -1
- package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.d.ts +1 -1
- package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.js +1 -1
- package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js +2 -2
- package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreSupabase/VectorStoreSupabase.node.js +2 -2
- package/dist/nodes/vector_store/VectorStoreSupabase/VectorStoreSupabase.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.d.ts +1 -1
- package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.js +1 -1
- package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.d.ts +1 -1
- package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.js +1 -1
- package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreZep/VectorStoreZep.node.js +1 -1
- package/dist/nodes/vector_store/VectorStoreZep/VectorStoreZep.node.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.d.ts +4 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.js +44 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.d.ts +15 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +226 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js +22 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.js +34 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js +33 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js +42 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js +16 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js +39 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/{createVectorStoreNode.d.ts → createVectorStoreNode/types.d.ts} +3 -16
- package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js +3 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.d.ts +6 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.js +20 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.js.map +1 -0
- package/dist/types/nodes.json +10 -9
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/helpers.js +12 -0
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/output_parsers/N8nOutputFixingParser.js +6 -1
- package/dist/utils/output_parsers/N8nOutputFixingParser.js.map +1 -1
- package/dist/utils/output_parsers/N8nOutputParser.d.ts +1 -1
- package/dist/utils/output_parsers/N8nOutputParser.js +5 -5
- package/dist/utils/output_parsers/N8nOutputParser.js.map +1 -1
- package/dist/utils/output_parsers/N8nStructuredOutputParser.js +2 -1
- package/dist/utils/output_parsers/N8nStructuredOutputParser.js.map +1 -1
- package/package.json +9 -6
- package/dist/nodes/chains/ChainLLM/utils.d.ts +0 -5
- package/dist/nodes/chains/ChainLLM/utils.js +0 -14
- package/dist/nodes/chains/ChainLLM/utils.js.map +0 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode.js +0 -369
- package/dist/nodes/vector_store/shared/createVectorStoreNode.js.map +0 -1
- package/dist/nodes/vector_store/shared/methods/listSearch.js.map +0 -1
- /package/dist/nodes/vector_store/shared/{methods → createVectorStoreNode/methods}/listSearch.d.ts +0 -0
- /package/dist/nodes/vector_store/shared/{methods → createVectorStoreNode/methods}/listSearch.js +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleLoadOperation = handleLoadOperation;
|
|
4
|
+
const helpers_1 = require("../../../../../utils/helpers");
|
|
5
|
+
async function handleLoadOperation(context, args, embeddings, itemIndex) {
|
|
6
|
+
const filter = (0, helpers_1.getMetadataFiltersValues)(context, itemIndex);
|
|
7
|
+
const vectorStore = await args.getVectorStoreClient(context, undefined, embeddings, itemIndex);
|
|
8
|
+
try {
|
|
9
|
+
const prompt = context.getNodeParameter('prompt', itemIndex);
|
|
10
|
+
const topK = context.getNodeParameter('topK', itemIndex, 4);
|
|
11
|
+
const includeDocumentMetadata = context.getNodeParameter('includeDocumentMetadata', itemIndex, true);
|
|
12
|
+
const embeddedPrompt = await embeddings.embedQuery(prompt);
|
|
13
|
+
const docs = await vectorStore.similaritySearchVectorWithScore(embeddedPrompt, topK, filter);
|
|
14
|
+
const serializedDocs = docs.map(([doc, score]) => {
|
|
15
|
+
const document = {
|
|
16
|
+
pageContent: doc.pageContent,
|
|
17
|
+
...(includeDocumentMetadata ? { metadata: doc.metadata } : {}),
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
json: { document, score },
|
|
21
|
+
pairedItem: {
|
|
22
|
+
item: itemIndex,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
(0, helpers_1.logAiEvent)(context, 'ai-vector-store-searched', { query: prompt });
|
|
27
|
+
return serializedDocs;
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=loadOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadOperation.js","sourceRoot":"","sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.ts"],"names":[],"mappings":";;AAYA,kDAsDC;AA9DD,4CAAsE;AAQ/D,KAAK,UAAU,mBAAmB,CACxC,OAA0B,EAC1B,IAAuC,EACvC,UAAsB,EACtB,SAAiB;IAEjB,MAAM,MAAM,GAAG,IAAA,kCAAwB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAClD,OAAO,EAEP,SAAS,EACT,UAAU,EACV,SAAS,CACT,CAAC;IAEF,IAAI,CAAC;QAEJ,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAW,CAAC;QACvE,MAAM,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAW,CAAC;QACtE,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CACvD,yBAAyB,EACzB,SAAS,EACT,IAAI,CACO,CAAC;QAGb,MAAM,cAAc,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAG3D,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,+BAA+B,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAG7F,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAChD,MAAM,QAAQ,GAAG;gBAChB,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9D,CAAC;YAEF,OAAO;gBACN,IAAI,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;gBACzB,UAAU,EAAE;oBACX,IAAI,EAAE,SAAS;iBACf;aACD,CAAC;QACH,CAAC,CAAC,CAAC;QAGH,IAAA,oBAAU,EAAC,OAAO,EAAE,0BAA0B,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QAEnE,OAAO,cAAc,CAAC;IACvB,CAAC;YAAS,CAAC;QAEV,IAAI,CAAC,wBAAwB,EAAE,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC;AACF,CAAC"}
|
package/dist/nodes/vector_store/shared/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/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleRetrieveAsToolOperation = handleRetrieveAsToolOperation;
|
|
4
|
+
const tools_1 = require("langchain/tools");
|
|
5
|
+
const helpers_1 = require("../../../../../utils/helpers");
|
|
6
|
+
const logWrapper_1 = require("../../../../../utils/logWrapper");
|
|
7
|
+
async function handleRetrieveAsToolOperation(context, args, embeddings, itemIndex) {
|
|
8
|
+
const toolDescription = context.getNodeParameter('toolDescription', itemIndex);
|
|
9
|
+
const toolName = context.getNodeParameter('toolName', itemIndex);
|
|
10
|
+
const topK = context.getNodeParameter('topK', itemIndex, 4);
|
|
11
|
+
const includeDocumentMetadata = context.getNodeParameter('includeDocumentMetadata', itemIndex, true);
|
|
12
|
+
const filter = (0, helpers_1.getMetadataFiltersValues)(context, itemIndex);
|
|
13
|
+
const vectorStoreTool = new tools_1.DynamicTool({
|
|
14
|
+
name: toolName,
|
|
15
|
+
description: toolDescription,
|
|
16
|
+
func: async (input) => {
|
|
17
|
+
const vectorStore = await args.getVectorStoreClient(context, undefined, embeddings, itemIndex);
|
|
18
|
+
try {
|
|
19
|
+
const embeddedPrompt = await embeddings.embedQuery(input);
|
|
20
|
+
const documents = await vectorStore.similaritySearchVectorWithScore(embeddedPrompt, topK, filter);
|
|
21
|
+
return documents
|
|
22
|
+
.map((document) => {
|
|
23
|
+
if (includeDocumentMetadata) {
|
|
24
|
+
return { type: 'text', text: JSON.stringify(document[0]) };
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
type: 'text',
|
|
28
|
+
text: JSON.stringify({ pageContent: document[0].pageContent }),
|
|
29
|
+
};
|
|
30
|
+
})
|
|
31
|
+
.filter((document) => !!document);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
response: (0, logWrapper_1.logWrapper)(vectorStoreTool, context),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=retrieveAsToolOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieveAsToolOperation.js","sourceRoot":"","sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.ts"],"names":[],"mappings":";;AAcA,sEAoEC;AAhFD,2CAA8C;AAG9C,4CAA0D;AAC1D,kDAA+C;AAQxC,KAAK,UAAU,6BAA6B,CAClD,OAA6B,EAC7B,IAAuC,EACvC,UAAsB,EACtB,SAAiB;IAGjB,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,SAAS,CAAW,CAAC;IACzF,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAW,CAAC;IAC3E,MAAM,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAW,CAAC;IACtE,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CACvD,yBAAyB,EACzB,SAAS,EACT,IAAI,CACO,CAAC;IAGb,MAAM,MAAM,GAAG,IAAA,kCAAwB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAG5D,MAAM,eAAe,GAAG,IAAI,mBAAW,CAAC;QACvC,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YAIrB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAClD,OAAO,EACP,SAAS,EACT,UAAU,EACV,SAAS,CACT,CAAC;YAEF,IAAI,CAAC;gBAEJ,MAAM,cAAc,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBAG1D,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,+BAA+B,CAClE,cAAc,EACd,IAAI,EACJ,MAAM,CACN,CAAC;gBAGF,OAAO,SAAS;qBACd,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;oBACjB,IAAI,uBAAuB,EAAE,CAAC;wBAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC5D,CAAC;oBACD,OAAO;wBACN,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;qBAC9D,CAAC;gBACH,CAAC,CAAC;qBACD,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;oBAAS,CAAC;gBAEV,IAAI,CAAC,wBAAwB,EAAE,CAAC,WAAW,CAAC,CAAC;YAC9C,CAAC;QACF,CAAC;KACD,CAAC,CAAC;IAGH,OAAO;QACN,QAAQ,EAAE,IAAA,uBAAU,EAAC,eAAe,EAAE,OAAO,CAAC;KAC9C,CAAC;AACH,CAAC"}
|
package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.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 handleRetrieveOperation<T extends VectorStore = VectorStore>(context: ISupplyDataFunctions, args: VectorStoreNodeConstructorArgs<T>, embeddings: Embeddings, itemIndex: number): Promise<SupplyData>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleRetrieveOperation = handleRetrieveOperation;
|
|
4
|
+
const helpers_1 = require("../../../../../utils/helpers");
|
|
5
|
+
const logWrapper_1 = require("../../../../../utils/logWrapper");
|
|
6
|
+
async function handleRetrieveOperation(context, args, embeddings, itemIndex) {
|
|
7
|
+
const filter = (0, helpers_1.getMetadataFiltersValues)(context, itemIndex);
|
|
8
|
+
const vectorStore = await args.getVectorStoreClient(context, filter, embeddings, itemIndex);
|
|
9
|
+
return {
|
|
10
|
+
response: (0, logWrapper_1.logWrapper)(vectorStore, context),
|
|
11
|
+
closeFunction: async () => {
|
|
12
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=retrieveOperation.js.map
|
package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieveOperation.js","sourceRoot":"","sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.ts"],"names":[],"mappings":";;AAaA,0DAoBC;AA7BD,4CAA0D;AAC1D,kDAA+C;AAQxC,KAAK,UAAU,uBAAuB,CAC5C,OAA6B,EAC7B,IAAuC,EACvC,UAAsB,EACtB,SAAiB;IAGjB,MAAM,MAAM,GAAG,IAAA,kCAAwB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAG5D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IAG5F,OAAO;QACN,QAAQ,EAAE,IAAA,uBAAU,EAAC,WAAW,EAAE,OAAO,CAAC;QAC1C,aAAa,EAAE,KAAK,IAAI,EAAE;YAEzB,IAAI,CAAC,wBAAwB,EAAE,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC;KACD,CAAC;AACH,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,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleUpdateOperation = handleUpdateOperation;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const helpers_1 = require("../../../../../utils/helpers");
|
|
6
|
+
const N8nJsonLoader_1 = require("../../../../../utils/N8nJsonLoader");
|
|
7
|
+
const processDocuments_1 = require("../../processDocuments");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
async function handleUpdateOperation(context, args, embeddings) {
|
|
10
|
+
if (!(0, utils_1.isUpdateSupported)(args)) {
|
|
11
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Update operation is not implemented for this Vector Store');
|
|
12
|
+
}
|
|
13
|
+
const items = context.getInputData();
|
|
14
|
+
const loader = new N8nJsonLoader_1.N8nJsonLoader(context);
|
|
15
|
+
const resultData = [];
|
|
16
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
17
|
+
const itemData = items[itemIndex];
|
|
18
|
+
const documentId = context.getNodeParameter('id', itemIndex, '', {
|
|
19
|
+
extractValue: true,
|
|
20
|
+
});
|
|
21
|
+
const vectorStore = await args.getVectorStoreClient(context, undefined, embeddings, itemIndex);
|
|
22
|
+
try {
|
|
23
|
+
const { processedDocuments, serializedDocuments } = await (0, processDocuments_1.processDocument)(loader, itemData, itemIndex);
|
|
24
|
+
if (processedDocuments?.length !== 1) {
|
|
25
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Single document per item expected');
|
|
26
|
+
}
|
|
27
|
+
resultData.push(...serializedDocuments);
|
|
28
|
+
await vectorStore.addDocuments(processedDocuments, {
|
|
29
|
+
ids: [documentId],
|
|
30
|
+
});
|
|
31
|
+
(0, helpers_1.logAiEvent)(context, 'ai-vector-store-updated');
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
args.releaseVectorStoreClient?.(vectorStore);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return resultData;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=updateOperation.js.map
|
package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateOperation.js","sourceRoot":"","sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.ts"],"names":[],"mappings":";;AAgBA,sDA8DC;AA3ED,+CAAkD;AAElD,4CAA4C;AAC5C,wDAAqD;AAErD,6DAAyD;AAEzD,oCAA6C;AAMtC,KAAK,UAAU,qBAAqB,CAC1C,OAA0B,EAC1B,IAAuC,EACvC,UAAsB;IAGtB,IAAI,CAAC,IAAA,yBAAiB,EAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,iCAAkB,CAC3B,OAAO,CAAC,OAAO,EAAE,EACjB,2DAA2D,CAC3D,CAAC;IACH,CAAC;IAGD,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAErC,MAAM,MAAM,GAAG,IAAI,6BAAa,CAAC,OAAO,CAAC,CAAC;IAE1C,MAAM,UAAU,GAAyB,EAAE,CAAC;IAG5C,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC;QAC/D,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;QAGlC,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;YAChE,YAAY,EAAE,IAAI;SAClB,CAAW,CAAC;QAGb,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAE/F,IAAI,CAAC;YAEJ,MAAM,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,GAAG,MAAM,IAAA,kCAAe,EACxE,MAAM,EACN,QAAQ,EACR,SAAS,CACT,CAAC;YAGF,IAAI,kBAAkB,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtC,MAAM,IAAI,iCAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,mCAAmC,CAAC,CAAC;YACtF,CAAC;YAGD,UAAU,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC;YAGxC,MAAM,WAAW,CAAC,YAAY,CAAC,kBAAkB,EAAE;gBAClD,GAAG,EAAE,CAAC,UAAU,CAAC;aACjB,CAAC,CAAC;YAGH,IAAA,oBAAU,EAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;QAChD,CAAC;gBAAS,CAAC;YAEV,IAAI,CAAC,wBAAwB,EAAE,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Document } from '@langchain/core/documents';
|
|
2
2
|
import type { Embeddings } from '@langchain/core/embeddings';
|
|
3
3
|
import type { VectorStore } from '@langchain/core/vectorstores';
|
|
4
|
-
import type { IExecuteFunctions, INodeCredentialDescription, INodeProperties,
|
|
5
|
-
type NodeOperationMode = 'insert' | 'load' | 'retrieve' | 'update' | 'retrieve-as-tool';
|
|
6
|
-
interface NodeMeta {
|
|
4
|
+
import type { IExecuteFunctions, INodeCredentialDescription, INodeProperties, ILoadOptionsFunctions, INodeListSearchResult, Icon, ISupplyDataFunctions, ThemeIconColor } from 'n8n-workflow';
|
|
5
|
+
export type NodeOperationMode = 'insert' | 'load' | 'retrieve' | 'update' | 'retrieve-as-tool';
|
|
6
|
+
export interface NodeMeta {
|
|
7
7
|
displayName: string;
|
|
8
8
|
name: string;
|
|
9
9
|
description: string;
|
|
@@ -29,16 +29,3 @@ export interface VectorStoreNodeConstructorArgs<T extends VectorStore = VectorSt
|
|
|
29
29
|
getVectorStoreClient: (context: IExecuteFunctions | ISupplyDataFunctions, filter: Record<string, never> | undefined, embeddings: Embeddings, itemIndex: number) => Promise<T>;
|
|
30
30
|
releaseVectorStoreClient?: (vectorStore: T) => void;
|
|
31
31
|
}
|
|
32
|
-
export declare const createVectorStoreNode: <T extends VectorStore = VectorStore>(args: VectorStoreNodeConstructorArgs<T>) => {
|
|
33
|
-
new (): {
|
|
34
|
-
description: INodeTypeDescription;
|
|
35
|
-
methods: {
|
|
36
|
-
listSearch?: {
|
|
37
|
-
[key: string]: (this: ILoadOptionsFunctions, filter?: string, paginationToken?: string) => Promise<INodeListSearchResult>;
|
|
38
|
-
};
|
|
39
|
-
} | undefined;
|
|
40
|
-
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
41
|
-
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../nodes/vector_store/shared/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,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformDescriptionForOperationMode = transformDescriptionForOperationMode;
|
|
4
|
+
exports.isUpdateSupported = isUpdateSupported;
|
|
5
|
+
exports.getOperationModeOptions = getOperationModeOptions;
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
function transformDescriptionForOperationMode(fields, mode) {
|
|
8
|
+
return fields.map((field) => ({
|
|
9
|
+
...field,
|
|
10
|
+
displayOptions: { show: { mode: Array.isArray(mode) ? mode : [mode] } },
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
function isUpdateSupported(args) {
|
|
14
|
+
return args.meta.operationModes?.includes('update') ?? false;
|
|
15
|
+
}
|
|
16
|
+
function getOperationModeOptions(args) {
|
|
17
|
+
const enabledOperationModes = args.meta.operationModes ?? constants_1.DEFAULT_OPERATION_MODES;
|
|
18
|
+
return constants_1.OPERATION_MODE_DESCRIPTIONS.filter(({ value }) => enabledOperationModes.includes(value));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../nodes/vector_store/shared/createVectorStoreNode/utils.ts"],"names":[],"mappings":";;AAUA,oFAQC;AAMD,8CAIC;AAMD,0DAQC;AAvCD,2CAAmF;AAOnF,SAAgB,oCAAoC,CACnD,MAAyB,EACzB,IAA6C;IAE7C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7B,GAAG,KAAK;QACR,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;KACvE,CAAC,CAAC,CAAC;AACL,CAAC;AAMD,SAAgB,iBAAiB,CAChC,IAAuC;IAEvC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;AAC9D,CAAC;AAMD,SAAgB,uBAAuB,CACtC,IAAuC;IAEvC,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,mCAAuB,CAAC;IAElF,OAAO,uCAA2B,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACvD,qBAAqB,CAAC,QAAQ,CAAC,KAA0B,CAAC,CAC1D,CAAC;AACH,CAAC"}
|