@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.
Files changed (123) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/known/nodes.json +4 -0
  3. package/dist/nodes/agents/Agent/Agent.node.js +5 -1
  4. package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
  5. package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js +9 -19
  6. package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js.map +1 -1
  7. package/dist/nodes/agents/Agent/agents/OpenAiFunctionsAgent/execute.js +3 -7
  8. package/dist/nodes/agents/Agent/agents/OpenAiFunctionsAgent/execute.js.map +1 -1
  9. package/dist/nodes/agents/Agent/agents/PlanAndExecuteAgent/execute.js +3 -7
  10. package/dist/nodes/agents/Agent/agents/PlanAndExecuteAgent/execute.js.map +1 -1
  11. package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js +3 -7
  12. package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js.map +1 -1
  13. package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js +5 -6
  14. package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js.map +1 -1
  15. package/dist/nodes/chains/ChainLLM/ChainLlm.node.js +17 -389
  16. package/dist/nodes/chains/ChainLLM/ChainLlm.node.js.map +1 -1
  17. package/dist/nodes/chains/ChainLLM/methods/chainExecutor.d.ts +15 -0
  18. package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js +69 -0
  19. package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js.map +1 -0
  20. package/dist/nodes/chains/ChainLLM/methods/config.d.ts +14 -0
  21. package/dist/nodes/chains/ChainLLM/methods/config.js +253 -0
  22. package/dist/nodes/chains/ChainLLM/methods/config.js.map +1 -0
  23. package/dist/nodes/chains/ChainLLM/methods/imageUtils.d.ts +12 -0
  24. package/dist/nodes/chains/ChainLLM/methods/imageUtils.js +66 -0
  25. package/dist/nodes/chains/ChainLLM/methods/imageUtils.js.map +1 -0
  26. package/dist/nodes/chains/ChainLLM/methods/index.d.ts +4 -0
  27. package/dist/nodes/chains/ChainLLM/methods/index.js +11 -0
  28. package/dist/nodes/chains/ChainLLM/methods/index.js.map +1 -0
  29. package/dist/nodes/chains/ChainLLM/methods/promptUtils.d.ts +3 -0
  30. package/dist/nodes/chains/ChainLLM/methods/promptUtils.js +69 -0
  31. package/dist/nodes/chains/ChainLLM/methods/promptUtils.js.map +1 -0
  32. package/dist/nodes/chains/ChainLLM/methods/responseFormatter.d.ts +2 -0
  33. package/dist/nodes/chains/ChainLLM/methods/responseFormatter.js +29 -0
  34. package/dist/nodes/chains/ChainLLM/methods/responseFormatter.js.map +1 -0
  35. package/dist/nodes/chains/ChainLLM/methods/types.d.ts +28 -0
  36. package/dist/nodes/chains/ChainLLM/methods/types.js +3 -0
  37. package/dist/nodes/chains/ChainLLM/methods/types.js.map +1 -0
  38. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +68 -33
  39. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
  40. package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +1 -0
  41. package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
  42. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +1 -1
  43. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
  44. package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js +1 -1
  45. package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js.map +1 -1
  46. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.d.ts +16 -0
  47. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.js +244 -0
  48. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.js.map +1 -0
  49. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.dark.svg +3 -0
  50. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.svg +3 -0
  51. package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js +1 -1
  52. package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js.map +1 -1
  53. package/dist/nodes/vector_store/VectorStorePinecone/VectorStorePinecone.node.js +2 -2
  54. package/dist/nodes/vector_store/VectorStorePinecone/VectorStorePinecone.node.js.map +1 -1
  55. package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.d.ts +1 -1
  56. package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.js +1 -1
  57. package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.js.map +1 -1
  58. package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.d.ts +1 -1
  59. package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.js +1 -1
  60. package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.js.map +1 -1
  61. package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js +2 -2
  62. package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js.map +1 -1
  63. package/dist/nodes/vector_store/VectorStoreSupabase/VectorStoreSupabase.node.js +2 -2
  64. package/dist/nodes/vector_store/VectorStoreSupabase/VectorStoreSupabase.node.js.map +1 -1
  65. package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.d.ts +1 -1
  66. package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.js +1 -1
  67. package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.js.map +1 -1
  68. package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.d.ts +1 -1
  69. package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.js +1 -1
  70. package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.js.map +1 -1
  71. package/dist/nodes/vector_store/VectorStoreZep/VectorStoreZep.node.js +1 -1
  72. package/dist/nodes/vector_store/VectorStoreZep/VectorStoreZep.node.js.map +1 -1
  73. package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.d.ts +4 -0
  74. package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.js +44 -0
  75. package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.js.map +1 -0
  76. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.d.ts +15 -0
  77. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +226 -0
  78. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -0
  79. package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js.map +1 -0
  80. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.d.ts +5 -0
  81. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js +22 -0
  82. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js.map +1 -0
  83. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.d.ts +5 -0
  84. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.js +34 -0
  85. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.js.map +1 -0
  86. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.d.ts +5 -0
  87. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js +33 -0
  88. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js.map +1 -0
  89. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.d.ts +5 -0
  90. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js +42 -0
  91. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js.map +1 -0
  92. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.d.ts +5 -0
  93. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js +16 -0
  94. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js.map +1 -0
  95. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.d.ts +5 -0
  96. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js +39 -0
  97. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js.map +1 -0
  98. package/dist/nodes/vector_store/shared/{createVectorStoreNode.d.ts → createVectorStoreNode/types.d.ts} +3 -16
  99. package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js +3 -0
  100. package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js.map +1 -0
  101. package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.d.ts +6 -0
  102. package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.js +20 -0
  103. package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.js.map +1 -0
  104. package/dist/types/nodes.json +10 -9
  105. package/dist/utils/helpers.d.ts +1 -0
  106. package/dist/utils/helpers.js +12 -0
  107. package/dist/utils/helpers.js.map +1 -1
  108. package/dist/utils/output_parsers/N8nOutputFixingParser.js +6 -1
  109. package/dist/utils/output_parsers/N8nOutputFixingParser.js.map +1 -1
  110. package/dist/utils/output_parsers/N8nOutputParser.d.ts +1 -1
  111. package/dist/utils/output_parsers/N8nOutputParser.js +5 -5
  112. package/dist/utils/output_parsers/N8nOutputParser.js.map +1 -1
  113. package/dist/utils/output_parsers/N8nStructuredOutputParser.js +2 -1
  114. package/dist/utils/output_parsers/N8nStructuredOutputParser.js.map +1 -1
  115. package/package.json +9 -6
  116. package/dist/nodes/chains/ChainLLM/utils.d.ts +0 -5
  117. package/dist/nodes/chains/ChainLLM/utils.js +0 -14
  118. package/dist/nodes/chains/ChainLLM/utils.js.map +0 -1
  119. package/dist/nodes/vector_store/shared/createVectorStoreNode.js +0 -369
  120. package/dist/nodes/vector_store/shared/createVectorStoreNode.js.map +0 -1
  121. package/dist/nodes/vector_store/shared/methods/listSearch.js.map +0 -1
  122. /package/dist/nodes/vector_store/shared/{methods → createVectorStoreNode/methods}/listSearch.d.ts +0 -0
  123. /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"}
@@ -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>;
@@ -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"}
@@ -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
@@ -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
@@ -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, INodeExecutionData, INodeTypeDescription, SupplyData, ISupplyDataFunctions, ILoadOptionsFunctions, INodeListSearchResult, Icon, ThemeIconColor } from 'n8n-workflow';
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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -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"}