@n8n/n8n-nodes-langchain 1.96.1 → 1.97.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/known/credentials.json +2 -1
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/ToolExecutor/ToolExecutor.node.js.map +1 -1
- package/dist/nodes/ToolExecutor/utils/executeTool.js.map +1 -1
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js +2 -1
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V1/execute.js +12 -2
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V1/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js +12 -2
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js.map +1 -1
- package/dist/nodes/agents/OpenAiAssistant/utils.js.map +1 -1
- package/dist/nodes/chains/InformationExtractor/InformationExtractor.node.js +9 -13
- package/dist/nodes/chains/InformationExtractor/InformationExtractor.node.js.map +1 -1
- package/dist/nodes/document_loaders/DocumentDefaultDataLoader/DocumentDefaultDataLoader.node.js +54 -13
- package/dist/nodes/document_loaders/DocumentDefaultDataLoader/DocumentDefaultDataLoader.node.js.map +1 -1
- package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js +54 -12
- package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +2 -2
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js +1 -1
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js.map +1 -1
- package/dist/nodes/llms/N8nLlmTracing.js +12 -2
- package/dist/nodes/llms/N8nLlmTracing.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/utils.js +5 -2
- package/dist/nodes/mcp/McpClientTool/utils.js.map +1 -1
- package/dist/nodes/memory/MemoryManager/MemoryManager.node.js +20 -15
- package/dist/nodes/memory/MemoryManager/MemoryManager.node.js.map +1 -1
- package/dist/nodes/output_parser/OutputParserAutofixing/OutputParserAutofixing.node.js +1 -1
- package/dist/nodes/output_parser/OutputParserAutofixing/OutputParserAutofixing.node.js.map +1 -1
- package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js +94 -16
- package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js.map +1 -1
- package/dist/nodes/output_parser/OutputParserStructured/prompt.js +44 -0
- package/dist/nodes/output_parser/OutputParserStructured/prompt.js.map +1 -0
- package/dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js +107 -0
- package/dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js.map +1 -0
- package/dist/nodes/rerankers/RerankerCohere/cohere.dark.svg +5 -0
- package/dist/nodes/rerankers/RerankerCohere/cohere.svg +5 -0
- package/dist/nodes/retrievers/RetrieverVectorStore/RetrieverVectorStore.node.js +11 -1
- package/dist/nodes/retrievers/RetrieverVectorStore/RetrieverVectorStore.node.js.map +1 -1
- package/dist/nodes/tools/ToolCode/ToolCode.node.js +15 -4
- package/dist/nodes/tools/ToolCode/ToolCode.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v1/ToolWorkflowV1.node.js +1 -1
- package/dist/nodes/tools/ToolWorkflow/v1/ToolWorkflowV1.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js +4 -3
- package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +13 -3
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js +8 -2
- package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +23 -3
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js +15 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js +18 -2
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js +16 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/helpers/utils.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js +1 -1
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js.map +1 -1
- package/dist/types/credentials.json +1 -1
- package/dist/types/nodes.json +19 -18
- package/dist/utils/descriptions.js +17 -2
- package/dist/utils/descriptions.js.map +1 -1
- package/dist/utils/logWrapper.js +23 -0
- package/dist/utils/logWrapper.js.map +1 -1
- package/dist/utils/output_parsers/N8nStructuredOutputParser.js +5 -1
- package/dist/utils/output_parsers/N8nStructuredOutputParser.js.map +1 -1
- package/dist/utils/schemaParsing.js +29 -5
- package/dist/utils/schemaParsing.js.map +1 -1
- package/package.json +10 -9
|
@@ -20,6 +20,7 @@ var descriptions_exports = {};
|
|
|
20
20
|
__export(descriptions_exports, {
|
|
21
21
|
buildInputSchemaField: () => buildInputSchemaField,
|
|
22
22
|
buildJsonSchemaExampleField: () => buildJsonSchemaExampleField,
|
|
23
|
+
buildJsonSchemaExampleNotice: () => buildJsonSchemaExampleNotice,
|
|
23
24
|
inputSchemaField: () => inputSchemaField,
|
|
24
25
|
jsonSchemaExampleField: () => jsonSchemaExampleField,
|
|
25
26
|
promptTypeOptions: () => promptTypeOptions,
|
|
@@ -40,7 +41,7 @@ const schemaTypeField = {
|
|
|
40
41
|
description: "Generate a schema from an example JSON object"
|
|
41
42
|
},
|
|
42
43
|
{
|
|
43
|
-
name: "Define
|
|
44
|
+
name: "Define using JSON Schema",
|
|
44
45
|
value: "manual",
|
|
45
46
|
description: "Define the JSON schema manually"
|
|
46
47
|
}
|
|
@@ -67,6 +68,18 @@ const buildJsonSchemaExampleField = (props) => ({
|
|
|
67
68
|
},
|
|
68
69
|
description: "Example JSON object to use to generate the schema"
|
|
69
70
|
});
|
|
71
|
+
const buildJsonSchemaExampleNotice = (props) => ({
|
|
72
|
+
displayName: "All properties will be required. To make them optional, use the 'JSON Schema' schema type instead",
|
|
73
|
+
name: "notice",
|
|
74
|
+
type: "notice",
|
|
75
|
+
default: "",
|
|
76
|
+
displayOptions: {
|
|
77
|
+
show: {
|
|
78
|
+
...props?.showExtraProps,
|
|
79
|
+
schemaType: ["fromJson"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
70
83
|
const jsonSchemaExampleField = buildJsonSchemaExampleField();
|
|
71
84
|
const buildInputSchemaField = (props) => ({
|
|
72
85
|
displayName: "Input Schema",
|
|
@@ -91,7 +104,8 @@ const buildInputSchemaField = (props) => ({
|
|
|
91
104
|
schemaType: ["manual"]
|
|
92
105
|
}
|
|
93
106
|
},
|
|
94
|
-
description: "Schema to use for the function"
|
|
107
|
+
description: "Schema to use for the function",
|
|
108
|
+
hint: 'Use <a target="_blank" href="https://json-schema.org/">JSON Schema</a> format (<a target="_blank" href="https://json-schema.org/learn/miscellaneous-examples.html">examples</a>). $refs syntax is currently not supported.'
|
|
95
109
|
});
|
|
96
110
|
const inputSchemaField = buildInputSchemaField();
|
|
97
111
|
const promptTypeOptions = {
|
|
@@ -138,6 +152,7 @@ const textFromPreviousNode = {
|
|
|
138
152
|
0 && (module.exports = {
|
|
139
153
|
buildInputSchemaField,
|
|
140
154
|
buildJsonSchemaExampleField,
|
|
155
|
+
buildJsonSchemaExampleNotice,
|
|
141
156
|
inputSchemaField,
|
|
142
157
|
jsonSchemaExampleField,
|
|
143
158
|
promptTypeOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../utils/descriptions.ts"],"sourcesContent":["import type { DisplayCondition, INodeProperties, NodeParameterValue } from 'n8n-workflow';\n\nexport const schemaTypeField: INodeProperties = {\n\tdisplayName: 'Schema Type',\n\tname: 'schemaType',\n\ttype: 'options',\n\tnoDataExpression: true,\n\toptions: [\n\t\t{\n\t\t\tname: 'Generate From JSON Example',\n\t\t\tvalue: 'fromJson',\n\t\t\tdescription: 'Generate a schema from an example JSON object',\n\t\t},\n\t\t{\n\t\t\tname: 'Define
|
|
1
|
+
{"version":3,"sources":["../../utils/descriptions.ts"],"sourcesContent":["import type { DisplayCondition, INodeProperties, NodeParameterValue } from 'n8n-workflow';\n\nexport const schemaTypeField: INodeProperties = {\n\tdisplayName: 'Schema Type',\n\tname: 'schemaType',\n\ttype: 'options',\n\tnoDataExpression: true,\n\toptions: [\n\t\t{\n\t\t\tname: 'Generate From JSON Example',\n\t\t\tvalue: 'fromJson',\n\t\t\tdescription: 'Generate a schema from an example JSON object',\n\t\t},\n\t\t{\n\t\t\tname: 'Define using JSON Schema',\n\t\t\tvalue: 'manual',\n\t\t\tdescription: 'Define the JSON schema manually',\n\t\t},\n\t],\n\tdefault: 'fromJson',\n\tdescription: 'How to specify the schema for the function',\n};\n\n/**\n * Returns a field for inputting a JSON example that can be used to generate the schema.\n * @param props\n */\nexport const buildJsonSchemaExampleField = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName: 'JSON Example',\n\tname: 'jsonSchemaExample',\n\ttype: 'json',\n\tdefault: `{\n\t\"some_input\": \"some_value\"\n}`,\n\tnoDataExpression: true,\n\ttypeOptions: {\n\t\trows: 10,\n\t},\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['fromJson'],\n\t\t},\n\t},\n\tdescription: 'Example JSON object to use to generate the schema',\n});\n\n/**\n * Returns a notice field about the generated schema properties being required by default.\n * @param props\n */\nexport const buildJsonSchemaExampleNotice = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName:\n\t\t\"All properties will be required. To make them optional, use the 'JSON Schema' schema type instead\",\n\tname: 'notice',\n\ttype: 'notice',\n\tdefault: '',\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['fromJson'],\n\t\t},\n\t},\n});\n\nexport const jsonSchemaExampleField = buildJsonSchemaExampleField();\n\nexport const buildInputSchemaField = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName: 'Input Schema',\n\tname: 'inputSchema',\n\ttype: 'json',\n\tdefault: `{\n\"type\": \"object\",\n\"properties\": {\n\t\"some_input\": {\n\t\t\"type\": \"string\",\n\t\t\"description\": \"Some input to the function\"\n\t\t}\n\t}\n}`,\n\tnoDataExpression: true,\n\ttypeOptions: {\n\t\trows: 10,\n\t},\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['manual'],\n\t\t},\n\t},\n\tdescription: 'Schema to use for the function',\n\thint: 'Use <a target=\"_blank\" href=\"https://json-schema.org/\">JSON Schema</a> format (<a target=\"_blank\" href=\"https://json-schema.org/learn/miscellaneous-examples.html\">examples</a>). $refs syntax is currently not supported.',\n});\n\nexport const inputSchemaField = buildInputSchemaField();\n\nexport const promptTypeOptions: INodeProperties = {\n\tdisplayName: 'Source for Prompt (User Message)',\n\tname: 'promptType',\n\ttype: 'options',\n\toptions: [\n\t\t{\n\t\t\tname: 'Connected Chat Trigger Node',\n\t\t\tvalue: 'auto',\n\t\t\tdescription:\n\t\t\t\t\"Looks for an input field called 'chatInput' that is coming from a directly connected Chat Trigger\",\n\t\t},\n\t\t{\n\t\t\tname: 'Define below',\n\t\t\tvalue: 'define',\n\t\t\tdescription: 'Use an expression to reference data in previous nodes or enter static text',\n\t\t},\n\t],\n\tdefault: 'auto',\n};\n\nexport const textInput: INodeProperties = {\n\tdisplayName: 'Prompt (User Message)',\n\tname: 'text',\n\ttype: 'string',\n\trequired: true,\n\tdefault: '',\n\tplaceholder: 'e.g. Hello, how can you help me?',\n\ttypeOptions: {\n\t\trows: 2,\n\t},\n};\n\nexport const textFromPreviousNode: INodeProperties = {\n\tdisplayName: 'Prompt (User Message)',\n\tname: 'text',\n\ttype: 'string',\n\trequired: true,\n\tdefault: '={{ $json.chatInput }}',\n\ttypeOptions: {\n\t\trows: 2,\n\t},\n\tdisabledOptions: { show: { promptType: ['auto'] } },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,kBAAmC;AAAA,EAC/C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,kBAAkB;AAAA,EAClB,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IACd;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IACd;AAAA,EACD;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACd;AAMO,MAAM,8BAA8B,CAAC,WAEpB;AAAA,EACvB,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA;AAAA;AAAA,EAGT,kBAAkB;AAAA,EAClB,aAAa;AAAA,IACZ,MAAM;AAAA,EACP;AAAA,EACA,gBAAgB;AAAA,IACf,MAAM;AAAA,MACL,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AM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AAAA,IACZ,MAAM;AAAA,EACP;AAAA,EACA,iBAAiB,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE;AACnD;","names":[]}
|
package/dist/utils/logWrapper.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(logWrapper_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(logWrapper_exports);
|
|
26
26
|
var import_embeddings = require("@langchain/core/embeddings");
|
|
27
27
|
var import_retrievers = require("@langchain/core/retrievers");
|
|
28
|
+
var import_document_compressors = require("@langchain/core/retrievers/document_compressors");
|
|
28
29
|
var import_vectorstores = require("@langchain/core/vectorstores");
|
|
29
30
|
var import_textsplitters = require("@langchain/textsplitters");
|
|
30
31
|
var import_n8n_workflow = require("n8n-workflow");
|
|
@@ -230,6 +231,28 @@ function logWrapper(originalInstance, executeFunctions) {
|
|
|
230
231
|
};
|
|
231
232
|
}
|
|
232
233
|
}
|
|
234
|
+
if (originalInstance instanceof import_document_compressors.BaseDocumentCompressor) {
|
|
235
|
+
if (prop === "compressDocuments" && "compressDocuments" in target) {
|
|
236
|
+
return async (documents, query) => {
|
|
237
|
+
connectionType = import_n8n_workflow.NodeConnectionTypes.AiReranker;
|
|
238
|
+
const { index } = executeFunctions.addInputData(connectionType, [
|
|
239
|
+
[{ json: { query, documents } }]
|
|
240
|
+
]);
|
|
241
|
+
const response = await callMethodAsync.call(target, {
|
|
242
|
+
executeFunctions,
|
|
243
|
+
connectionType,
|
|
244
|
+
currentNodeRunIndex: index,
|
|
245
|
+
method: target[prop],
|
|
246
|
+
// compressDocuments mutates the original object
|
|
247
|
+
// messing up the input data logging
|
|
248
|
+
arguments: [(0, import_n8n_workflow.deepCopy)(documents), query]
|
|
249
|
+
});
|
|
250
|
+
(0, import_helpers.logAiEvent)(executeFunctions, "ai-document-reranked", { query });
|
|
251
|
+
executeFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);
|
|
252
|
+
return response;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
233
256
|
if (originalInstance instanceof import_N8nJsonLoader.N8nJsonLoader || originalInstance instanceof import_N8nBinaryLoader.N8nBinaryLoader) {
|
|
234
257
|
if (prop === "processAll" && "processAll" in target) {
|
|
235
258
|
return async (items) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../utils/logWrapper.ts"],"sourcesContent":["import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';\nimport type { BaseCallbackConfig, Callbacks } from '@langchain/core/callbacks/manager';\nimport type { BaseChatMessageHistory } from '@langchain/core/chat_history';\nimport type { Document } from '@langchain/core/documents';\nimport { Embeddings } from '@langchain/core/embeddings';\nimport type { InputValues, MemoryVariables, OutputValues } from '@langchain/core/memory';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport { BaseRetriever } from '@langchain/core/retrievers';\nimport type { StructuredTool, Tool } from '@langchain/core/tools';\nimport { VectorStore } from '@langchain/core/vectorstores';\nimport { TextSplitter } from '@langchain/textsplitters';\nimport type { BaseDocumentLoader } from 'langchain/dist/document_loaders/base';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tISupplyDataFunctions,\n\tITaskMetadata,\n\tNodeConnectionType,\n} from 'n8n-workflow';\nimport { NodeOperationError, NodeConnectionTypes, parseErrorMetadata } from 'n8n-workflow';\n\nimport { logAiEvent, isToolsInstance, isBaseChatMemory, isBaseChatMessageHistory } from './helpers';\nimport { N8nBinaryLoader } from './N8nBinaryLoader';\nimport { N8nJsonLoader } from './N8nJsonLoader';\n\nexport async function callMethodAsync<T>(\n\tthis: T,\n\tparameters: {\n\t\texecuteFunctions: IExecuteFunctions | ISupplyDataFunctions;\n\t\tconnectionType: NodeConnectionType;\n\t\tcurrentNodeRunIndex: number;\n\t\tmethod: (...args: any[]) => Promise<unknown>;\n\t\targuments: unknown[];\n\t},\n): Promise<unknown> {\n\ttry {\n\t\treturn await parameters.method.call(this, ...parameters.arguments);\n\t} catch (e) {\n\t\tconst connectedNode = parameters.executeFunctions.getNode();\n\n\t\tconst error = new NodeOperationError(connectedNode, e, {\n\t\t\tfunctionality: 'configuration-node',\n\t\t});\n\n\t\tconst metadata = parseErrorMetadata(error);\n\t\tparameters.executeFunctions.addOutputData(\n\t\t\tparameters.connectionType,\n\t\t\tparameters.currentNodeRunIndex,\n\t\t\terror,\n\t\t\tmetadata,\n\t\t);\n\n\t\tif (error.message) {\n\t\t\tif (!error.description) {\n\t\t\t\terror.description = error.message;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new NodeOperationError(\n\t\t\tconnectedNode,\n\t\t\t`Error on node \"${connectedNode.name}\" which is connected via input \"${parameters.connectionType}\"`,\n\t\t\t{ functionality: 'configuration-node' },\n\t\t);\n\t}\n}\n\nexport function callMethodSync<T>(\n\tthis: T,\n\tparameters: {\n\t\texecuteFunctions: IExecuteFunctions;\n\t\tconnectionType: NodeConnectionType;\n\t\tcurrentNodeRunIndex: number;\n\t\tmethod: (...args: any[]) => T;\n\t\targuments: unknown[];\n\t},\n): unknown {\n\ttry {\n\t\treturn parameters.method.call(this, ...parameters.arguments);\n\t} catch (e) {\n\t\tconst connectedNode = parameters.executeFunctions.getNode();\n\t\tconst error = new NodeOperationError(connectedNode, e);\n\t\tparameters.executeFunctions.addOutputData(\n\t\t\tparameters.connectionType,\n\t\t\tparameters.currentNodeRunIndex,\n\t\t\terror,\n\t\t);\n\n\t\tthrow new NodeOperationError(\n\t\t\tconnectedNode,\n\t\t\t`Error on node \"${connectedNode.name}\" which is connected via input \"${parameters.connectionType}\"`,\n\t\t\t{ functionality: 'configuration-node' },\n\t\t);\n\t}\n}\n\nexport function logWrapper<\n\tT extends\n\t\t| Tool\n\t\t| StructuredTool\n\t\t| BaseChatMemory\n\t\t| BaseChatMessageHistory\n\t\t| BaseRetriever\n\t\t| Embeddings\n\t\t| Document[]\n\t\t| Document\n\t\t| BaseDocumentLoader\n\t\t| TextSplitter\n\t\t| VectorStore\n\t\t| N8nBinaryLoader\n\t\t| N8nJsonLoader,\n>(originalInstance: T, executeFunctions: IExecuteFunctions | ISupplyDataFunctions): T {\n\treturn new Proxy(originalInstance, {\n\t\tget: (target, prop) => {\n\t\t\tlet connectionType: NodeConnectionType | undefined;\n\t\t\t// ========== BaseChatMemory ==========\n\t\t\tif (isBaseChatMemory(originalInstance)) {\n\t\t\t\tif (prop === 'loadMemoryVariables' && 'loadMemoryVariables' in target) {\n\t\t\t\t\treturn async (values: InputValues): Promise<MemoryVariables> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiMemory;\n\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { action: 'loadMemoryVariables', values } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [values],\n\t\t\t\t\t\t})) as MemoryVariables;\n\n\t\t\t\t\t\tconst chatHistory = (response?.chat_history as BaseMessage[]) ?? response;\n\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [\n\t\t\t\t\t\t\t[{ json: { action: 'loadMemoryVariables', chatHistory } }],\n\t\t\t\t\t\t]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t} else if (prop === 'saveContext' && 'saveContext' in target) {\n\t\t\t\t\treturn async (input: InputValues, output: OutputValues): Promise<MemoryVariables> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiMemory;\n\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { action: 'saveContext', input, output } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [input, output],\n\t\t\t\t\t\t})) as MemoryVariables;\n\n\t\t\t\t\t\tconst chatHistory = await target.chatHistory.getMessages();\n\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [\n\t\t\t\t\t\t\t[{ json: { action: 'saveContext', chatHistory } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== BaseChatMessageHistory ==========\n\t\t\tif (isBaseChatMessageHistory(originalInstance)) {\n\t\t\t\tif (prop === 'getMessages' && 'getMessages' in target) {\n\t\t\t\t\treturn async (): Promise<BaseMessage[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiMemory;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { action: 'getMessages' } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [],\n\t\t\t\t\t\t})) as BaseMessage[];\n\n\t\t\t\t\t\tconst payload = { action: 'getMessages', response };\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: payload }]]);\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-messages-retrieved-from-memory', { response });\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t} else if (prop === 'addMessage' && 'addMessage' in target) {\n\t\t\t\t\treturn async (message: BaseMessage): Promise<void> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiMemory;\n\t\t\t\t\t\tconst payload = { action: 'addMessage', message };\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [[{ json: payload }]]);\n\n\t\t\t\t\t\tawait callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [message],\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-message-added-to-memory', { message });\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: payload }]]);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== BaseRetriever ==========\n\t\t\tif (originalInstance instanceof BaseRetriever) {\n\t\t\t\tif (prop === 'getRelevantDocuments' && 'getRelevantDocuments' in target) {\n\t\t\t\t\treturn async (\n\t\t\t\t\t\tquery: string,\n\t\t\t\t\t\tconfig?: Callbacks | BaseCallbackConfig,\n\t\t\t\t\t): Promise<Document[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiRetriever;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { query, config } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [query, config],\n\t\t\t\t\t\t})) as Array<Document<Record<string, any>>>;\n\n\t\t\t\t\t\tconst executionId: string | undefined = response[0]?.metadata?.executionId as string;\n\t\t\t\t\t\tconst workflowId: string | undefined = response[0]?.metadata?.workflowId as string;\n\n\t\t\t\t\t\tconst metadata: ITaskMetadata = {};\n\t\t\t\t\t\tif (executionId && workflowId) {\n\t\t\t\t\t\t\tmetadata.subExecution = {\n\t\t\t\t\t\t\t\texecutionId,\n\t\t\t\t\t\t\t\tworkflowId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-documents-retrieved', { query });\n\t\t\t\t\t\texecuteFunctions.addOutputData(\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t[[{ json: { response } }]],\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== Embeddings ==========\n\t\t\tif (originalInstance instanceof Embeddings) {\n\t\t\t\t// Docs -> Embeddings\n\t\t\t\tif (prop === 'embedDocuments' && 'embedDocuments' in target) {\n\t\t\t\t\treturn async (documents: string[]): Promise<number[][]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiEmbedding;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { documents } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [documents],\n\t\t\t\t\t\t})) as number[][];\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-document-embedded');\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t// Query -> Embeddings\n\t\t\t\tif (prop === 'embedQuery' && 'embedQuery' in target) {\n\t\t\t\t\treturn async (query: string): Promise<number[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiEmbedding;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { query } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [query],\n\t\t\t\t\t\t})) as number[];\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-query-embedded');\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== N8n Loaders Process All ==========\n\t\t\tif (\n\t\t\t\toriginalInstance instanceof N8nJsonLoader ||\n\t\t\t\toriginalInstance instanceof N8nBinaryLoader\n\t\t\t) {\n\t\t\t\t// Process All\n\t\t\t\tif (prop === 'processAll' && 'processAll' in target) {\n\t\t\t\t\treturn async (items: INodeExecutionData[]): Promise<number[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiDocument;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [items]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [items],\n\t\t\t\t\t\t})) as number[];\n\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Process Each\n\t\t\t\tif (prop === 'processItem' && 'processItem' in target) {\n\t\t\t\t\treturn async (item: INodeExecutionData, itemIndex: number): Promise<number[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiDocument;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [[item]]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [item, itemIndex],\n\t\t\t\t\t\t})) as number[];\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-document-processed');\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [\n\t\t\t\t\t\t\t[{ json: { response }, pairedItem: { item: itemIndex } }],\n\t\t\t\t\t\t]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== TextSplitter ==========\n\t\t\tif (originalInstance instanceof TextSplitter) {\n\t\t\t\tif (prop === 'splitText' && 'splitText' in target) {\n\t\t\t\t\treturn async (text: string): Promise<string[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiTextSplitter;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { textSplitter: text } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [text],\n\t\t\t\t\t\t})) as string[];\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-text-split');\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== Tool ==========\n\t\t\tif (isToolsInstance(originalInstance)) {\n\t\t\t\tif (prop === '_call' && '_call' in target) {\n\t\t\t\t\treturn async (query: string): Promise<string> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiTool;\n\t\t\t\t\t\tconst inputData: IDataObject = { query };\n\n\t\t\t\t\t\tif (target.metadata?.isFromToolkit) {\n\t\t\t\t\t\t\tinputData.tool = {\n\t\t\t\t\t\t\t\tname: target.name,\n\t\t\t\t\t\t\t\tdescription: target.description,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: inputData }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [query],\n\t\t\t\t\t\t})) as string;\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-tool-called', { ...inputData, response });\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\n\t\t\t\t\t\tif (typeof response === 'string') return response;\n\t\t\t\t\t\treturn JSON.stringify(response);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== VectorStore ==========\n\t\t\tif (originalInstance instanceof VectorStore) {\n\t\t\t\tif (prop === 'similaritySearch' && 'similaritySearch' in target) {\n\t\t\t\t\treturn async (\n\t\t\t\t\t\tquery: string,\n\t\t\t\t\t\tk?: number,\n\t\t\t\t\t\tfilter?: BiquadFilterType | undefined,\n\t\t\t\t\t\t_callbacks?: Callbacks | undefined,\n\t\t\t\t\t): Promise<Document[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiVectorStore;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { query, k, filter } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [query, k, filter, _callbacks],\n\t\t\t\t\t\t})) as Array<Document<Record<string, any>>>;\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-vector-store-searched', { query });\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn (target as any)[prop];\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,wBAA2B;AAG3B,wBAA8B;AAE9B,0BAA4B;AAC5B,2BAA6B;AAU7B,0BAA4E;AAE5E,qBAAwF;AACxF,6BAAgC;AAChC,2BAA8B;AAE9B,eAAsB,gBAErB,YAOmB;AACnB,MAAI;AACH,WAAO,MAAM,WAAW,OAAO,KAAK,MAAM,GAAG,WAAW,SAAS;AAAA,EAClE,SAAS,GAAG;AACX,UAAM,gBAAgB,WAAW,iBAAiB,QAAQ;AAE1D,UAAM,QAAQ,IAAI,uCAAmB,eAAe,GAAG;AAAA,MACtD,eAAe;AAAA,IAChB,CAAC;AAED,UAAM,eAAW,wCAAmB,KAAK;AACzC,eAAW,iBAAiB;AAAA,MAC3B,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MACA;AAAA,IACD;AAEA,QA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,cACnB,WAAW,CAAC,KAAK;AAAA,YAClB,CAAC;AAED,2CAAW,kBAAkB,kBAAkB,EAAE,GAAG,WAAW,SAAS,CAAC;AACzE,6BAAiB,cAAc,gBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AAEhF,gBAAI,OAAO,aAAa,SAAU,QAAO;AACzC,mBAAO,KAAK,UAAU,QAAQ;AAAA,UAC/B;AAAA,QACD;AAAA,MACD;AAGA,UAAI,4BAA4B,iCAAa;AAC5C,YAAI,SAAS,sBAAsB,sBAAsB,QAAQ;AAChE,iBAAO,OACN,OACA,GACA,QACA,eACyB;AACzB,6BAAiB,wCAAoB;AACrC,kBAAM,EAAE,MAAM,IAAI,iBAAiB,aAAa,gBAAgB;AAAA,cAC/D,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;AAAA,YAChC,CAAC;AAED,kBAAM,WAAY,MAAM,gBAAgB,KAAK,QAAQ;AAAA,cACpD;AAAA,cACA;AAAA,cACA,qBAAqB;AAAA,cACrB,QAAQ,OAAO,IAAI;AAAA,cACnB,WAAW,CAAC,OAAO,GAAG,QAAQ,UAAU;AAAA,YACzC,CAAC;AAED,2CAAW,kBAAkB,4BAA4B,EAAE,MAAM,CAAC;AAClE,6BAAiB,cAAc,gBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AAEhF,mBAAO;AAAA,UACR;AAAA,QACD;AAAA,MACD;AAGA,aAAQ,OAAe,IAAI;AAAA,IAC5B;AAAA,EACD,CAAC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../utils/logWrapper.ts"],"sourcesContent":["import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';\nimport type { BaseCallbackConfig, Callbacks } from '@langchain/core/callbacks/manager';\nimport type { BaseChatMessageHistory } from '@langchain/core/chat_history';\nimport type { Document } from '@langchain/core/documents';\nimport { Embeddings } from '@langchain/core/embeddings';\nimport type { InputValues, MemoryVariables, OutputValues } from '@langchain/core/memory';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport { BaseRetriever } from '@langchain/core/retrievers';\nimport { BaseDocumentCompressor } from '@langchain/core/retrievers/document_compressors';\nimport type { StructuredTool, Tool } from '@langchain/core/tools';\nimport { VectorStore } from '@langchain/core/vectorstores';\nimport { TextSplitter } from '@langchain/textsplitters';\nimport type { BaseDocumentLoader } from 'langchain/dist/document_loaders/base';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tISupplyDataFunctions,\n\tITaskMetadata,\n\tNodeConnectionType,\n} from 'n8n-workflow';\nimport {\n\tNodeOperationError,\n\tNodeConnectionTypes,\n\tparseErrorMetadata,\n\tdeepCopy,\n} from 'n8n-workflow';\n\nimport { logAiEvent, isToolsInstance, isBaseChatMemory, isBaseChatMessageHistory } from './helpers';\nimport { N8nBinaryLoader } from './N8nBinaryLoader';\nimport { N8nJsonLoader } from './N8nJsonLoader';\n\nexport async function callMethodAsync<T>(\n\tthis: T,\n\tparameters: {\n\t\texecuteFunctions: IExecuteFunctions | ISupplyDataFunctions;\n\t\tconnectionType: NodeConnectionType;\n\t\tcurrentNodeRunIndex: number;\n\t\tmethod: (...args: any[]) => Promise<unknown>;\n\t\targuments: unknown[];\n\t},\n): Promise<unknown> {\n\ttry {\n\t\treturn await parameters.method.call(this, ...parameters.arguments);\n\t} catch (e) {\n\t\tconst connectedNode = parameters.executeFunctions.getNode();\n\n\t\tconst error = new NodeOperationError(connectedNode, e, {\n\t\t\tfunctionality: 'configuration-node',\n\t\t});\n\n\t\tconst metadata = parseErrorMetadata(error);\n\t\tparameters.executeFunctions.addOutputData(\n\t\t\tparameters.connectionType,\n\t\t\tparameters.currentNodeRunIndex,\n\t\t\terror,\n\t\t\tmetadata,\n\t\t);\n\n\t\tif (error.message) {\n\t\t\tif (!error.description) {\n\t\t\t\terror.description = error.message;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new NodeOperationError(\n\t\t\tconnectedNode,\n\t\t\t`Error on node \"${connectedNode.name}\" which is connected via input \"${parameters.connectionType}\"`,\n\t\t\t{ functionality: 'configuration-node' },\n\t\t);\n\t}\n}\n\nexport function callMethodSync<T>(\n\tthis: T,\n\tparameters: {\n\t\texecuteFunctions: IExecuteFunctions;\n\t\tconnectionType: NodeConnectionType;\n\t\tcurrentNodeRunIndex: number;\n\t\tmethod: (...args: any[]) => T;\n\t\targuments: unknown[];\n\t},\n): unknown {\n\ttry {\n\t\treturn parameters.method.call(this, ...parameters.arguments);\n\t} catch (e) {\n\t\tconst connectedNode = parameters.executeFunctions.getNode();\n\t\tconst error = new NodeOperationError(connectedNode, e);\n\t\tparameters.executeFunctions.addOutputData(\n\t\t\tparameters.connectionType,\n\t\t\tparameters.currentNodeRunIndex,\n\t\t\terror,\n\t\t);\n\n\t\tthrow new NodeOperationError(\n\t\t\tconnectedNode,\n\t\t\t`Error on node \"${connectedNode.name}\" which is connected via input \"${parameters.connectionType}\"`,\n\t\t\t{ functionality: 'configuration-node' },\n\t\t);\n\t}\n}\n\nexport function logWrapper<\n\tT extends\n\t\t| Tool\n\t\t| StructuredTool\n\t\t| BaseChatMemory\n\t\t| BaseChatMessageHistory\n\t\t| BaseRetriever\n\t\t| BaseDocumentCompressor\n\t\t| Embeddings\n\t\t| Document[]\n\t\t| Document\n\t\t| BaseDocumentLoader\n\t\t| TextSplitter\n\t\t| VectorStore\n\t\t| N8nBinaryLoader\n\t\t| N8nJsonLoader,\n>(originalInstance: T, executeFunctions: IExecuteFunctions | ISupplyDataFunctions): T {\n\treturn new Proxy(originalInstance, {\n\t\tget: (target, prop) => {\n\t\t\tlet connectionType: NodeConnectionType | undefined;\n\t\t\t// ========== BaseChatMemory ==========\n\t\t\tif (isBaseChatMemory(originalInstance)) {\n\t\t\t\tif (prop === 'loadMemoryVariables' && 'loadMemoryVariables' in target) {\n\t\t\t\t\treturn async (values: InputValues): Promise<MemoryVariables> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiMemory;\n\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { action: 'loadMemoryVariables', values } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [values],\n\t\t\t\t\t\t})) as MemoryVariables;\n\n\t\t\t\t\t\tconst chatHistory = (response?.chat_history as BaseMessage[]) ?? response;\n\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [\n\t\t\t\t\t\t\t[{ json: { action: 'loadMemoryVariables', chatHistory } }],\n\t\t\t\t\t\t]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t} else if (prop === 'saveContext' && 'saveContext' in target) {\n\t\t\t\t\treturn async (input: InputValues, output: OutputValues): Promise<MemoryVariables> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiMemory;\n\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { action: 'saveContext', input, output } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [input, output],\n\t\t\t\t\t\t})) as MemoryVariables;\n\n\t\t\t\t\t\tconst chatHistory = await target.chatHistory.getMessages();\n\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [\n\t\t\t\t\t\t\t[{ json: { action: 'saveContext', chatHistory } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== BaseChatMessageHistory ==========\n\t\t\tif (isBaseChatMessageHistory(originalInstance)) {\n\t\t\t\tif (prop === 'getMessages' && 'getMessages' in target) {\n\t\t\t\t\treturn async (): Promise<BaseMessage[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiMemory;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { action: 'getMessages' } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [],\n\t\t\t\t\t\t})) as BaseMessage[];\n\n\t\t\t\t\t\tconst payload = { action: 'getMessages', response };\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: payload }]]);\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-messages-retrieved-from-memory', { response });\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t} else if (prop === 'addMessage' && 'addMessage' in target) {\n\t\t\t\t\treturn async (message: BaseMessage): Promise<void> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiMemory;\n\t\t\t\t\t\tconst payload = { action: 'addMessage', message };\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [[{ json: payload }]]);\n\n\t\t\t\t\t\tawait callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [message],\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-message-added-to-memory', { message });\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: payload }]]);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== BaseRetriever ==========\n\t\t\tif (originalInstance instanceof BaseRetriever) {\n\t\t\t\tif (prop === 'getRelevantDocuments' && 'getRelevantDocuments' in target) {\n\t\t\t\t\treturn async (\n\t\t\t\t\t\tquery: string,\n\t\t\t\t\t\tconfig?: Callbacks | BaseCallbackConfig,\n\t\t\t\t\t): Promise<Document[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiRetriever;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { query, config } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [query, config],\n\t\t\t\t\t\t})) as Array<Document<Record<string, any>>>;\n\n\t\t\t\t\t\tconst executionId: string | undefined = response[0]?.metadata?.executionId as string;\n\t\t\t\t\t\tconst workflowId: string | undefined = response[0]?.metadata?.workflowId as string;\n\n\t\t\t\t\t\tconst metadata: ITaskMetadata = {};\n\t\t\t\t\t\tif (executionId && workflowId) {\n\t\t\t\t\t\t\tmetadata.subExecution = {\n\t\t\t\t\t\t\t\texecutionId,\n\t\t\t\t\t\t\t\tworkflowId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-documents-retrieved', { query });\n\t\t\t\t\t\texecuteFunctions.addOutputData(\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t[[{ json: { response } }]],\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== Embeddings ==========\n\t\t\tif (originalInstance instanceof Embeddings) {\n\t\t\t\t// Docs -> Embeddings\n\t\t\t\tif (prop === 'embedDocuments' && 'embedDocuments' in target) {\n\t\t\t\t\treturn async (documents: string[]): Promise<number[][]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiEmbedding;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { documents } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [documents],\n\t\t\t\t\t\t})) as number[][];\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-document-embedded');\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t// Query -> Embeddings\n\t\t\t\tif (prop === 'embedQuery' && 'embedQuery' in target) {\n\t\t\t\t\treturn async (query: string): Promise<number[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiEmbedding;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { query } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [query],\n\t\t\t\t\t\t})) as number[];\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-query-embedded');\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== Rerankers ==========\n\t\t\tif (originalInstance instanceof BaseDocumentCompressor) {\n\t\t\t\tif (prop === 'compressDocuments' && 'compressDocuments' in target) {\n\t\t\t\t\treturn async (documents: Document[], query: string): Promise<Document[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiReranker;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { query, documents } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\t// compressDocuments mutates the original object\n\t\t\t\t\t\t\t// messing up the input data logging\n\t\t\t\t\t\t\targuments: [deepCopy(documents), query],\n\t\t\t\t\t\t})) as Document[];\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-document-reranked', { query });\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== N8n Loaders Process All ==========\n\t\t\tif (\n\t\t\t\toriginalInstance instanceof N8nJsonLoader ||\n\t\t\t\toriginalInstance instanceof N8nBinaryLoader\n\t\t\t) {\n\t\t\t\t// Process All\n\t\t\t\tif (prop === 'processAll' && 'processAll' in target) {\n\t\t\t\t\treturn async (items: INodeExecutionData[]): Promise<number[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiDocument;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [items]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [items],\n\t\t\t\t\t\t})) as number[];\n\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Process Each\n\t\t\t\tif (prop === 'processItem' && 'processItem' in target) {\n\t\t\t\t\treturn async (item: INodeExecutionData, itemIndex: number): Promise<number[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiDocument;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [[item]]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [item, itemIndex],\n\t\t\t\t\t\t})) as number[];\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-document-processed');\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [\n\t\t\t\t\t\t\t[{ json: { response }, pairedItem: { item: itemIndex } }],\n\t\t\t\t\t\t]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== TextSplitter ==========\n\t\t\tif (originalInstance instanceof TextSplitter) {\n\t\t\t\tif (prop === 'splitText' && 'splitText' in target) {\n\t\t\t\t\treturn async (text: string): Promise<string[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiTextSplitter;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { textSplitter: text } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [text],\n\t\t\t\t\t\t})) as string[];\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-text-split');\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== Tool ==========\n\t\t\tif (isToolsInstance(originalInstance)) {\n\t\t\t\tif (prop === '_call' && '_call' in target) {\n\t\t\t\t\treturn async (query: string): Promise<string> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiTool;\n\t\t\t\t\t\tconst inputData: IDataObject = { query };\n\n\t\t\t\t\t\tif (target.metadata?.isFromToolkit) {\n\t\t\t\t\t\t\tinputData.tool = {\n\t\t\t\t\t\t\t\tname: target.name,\n\t\t\t\t\t\t\t\tdescription: target.description,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: inputData }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [query],\n\t\t\t\t\t\t})) as string;\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-tool-called', { ...inputData, response });\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\n\t\t\t\t\t\tif (typeof response === 'string') return response;\n\t\t\t\t\t\treturn JSON.stringify(response);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ========== VectorStore ==========\n\t\t\tif (originalInstance instanceof VectorStore) {\n\t\t\t\tif (prop === 'similaritySearch' && 'similaritySearch' in target) {\n\t\t\t\t\treturn async (\n\t\t\t\t\t\tquery: string,\n\t\t\t\t\t\tk?: number,\n\t\t\t\t\t\tfilter?: BiquadFilterType | undefined,\n\t\t\t\t\t\t_callbacks?: Callbacks | undefined,\n\t\t\t\t\t): Promise<Document[]> => {\n\t\t\t\t\t\tconnectionType = NodeConnectionTypes.AiVectorStore;\n\t\t\t\t\t\tconst { index } = executeFunctions.addInputData(connectionType, [\n\t\t\t\t\t\t\t[{ json: { query, k, filter } }],\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tconst response = (await callMethodAsync.call(target, {\n\t\t\t\t\t\t\texecuteFunctions,\n\t\t\t\t\t\t\tconnectionType,\n\t\t\t\t\t\t\tcurrentNodeRunIndex: index,\n\t\t\t\t\t\t\tmethod: target[prop],\n\t\t\t\t\t\t\targuments: [query, k, filter, _callbacks],\n\t\t\t\t\t\t})) as Array<Document<Record<string, any>>>;\n\n\t\t\t\t\t\tlogAiEvent(executeFunctions, 'ai-vector-store-searched', { query });\n\t\t\t\t\t\texecuteFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);\n\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn (target as any)[prop];\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,wBAA2B;AAG3B,wBAA8B;AAC9B,kCAAuC;AAEvC,0BAA4B;AAC5B,2BAA6B;AA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C,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AAEhF,gBAAI,OAAO,aAAa,SAAU,QAAO;AACzC,mBAAO,KAAK,UAAU,QAAQ;AAAA,UAC/B;AAAA,QACD;AAAA,MACD;AAGA,UAAI,4BAA4B,iCAAa;AAC5C,YAAI,SAAS,sBAAsB,sBAAsB,QAAQ;AAChE,iBAAO,OACN,OACA,GACA,QACA,eACyB;AACzB,6BAAiB,wCAAoB;AACrC,kBAAM,EAAE,MAAM,IAAI,iBAAiB,aAAa,gBAAgB;AAAA,cAC/D,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;AAAA,YAChC,CAAC;AAED,kBAAM,WAAY,MAAM,gBAAgB,KAAK,QAAQ;AAAA,cACpD;AAAA,cACA;AAAA,cACA,qBAAqB;AAAA,cACrB,QAAQ,OAAO,IAAI;AAAA,cACnB,WAAW,CAAC,OAAO,GAAG,QAAQ,UAAU;AAAA,YACzC,CAAC;AAED,2CAAW,kBAAkB,4BAA4B,EAAE,MAAM,CAAC;AAClE,6BAAiB,cAAc,gBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AAEhF,mBAAO;AAAA,UACR;AAAA,QACD;AAAA,MACD;AAGA,aAAQ,OAAe,IAAI;AAAA,IAC5B;AAAA,EACD,CAAC;AACF;","names":[]}
|
|
@@ -98,10 +98,14 @@ class N8nStructuredOutputParser extends import_output_parsers.StructuredOutputPa
|
|
|
98
98
|
}
|
|
99
99
|
)
|
|
100
100
|
});
|
|
101
|
-
} else {
|
|
101
|
+
} else if (nodeVersion < 1.3) {
|
|
102
102
|
returnSchema = import_zod.z.object({
|
|
103
103
|
output: zodSchema.optional()
|
|
104
104
|
});
|
|
105
|
+
} else {
|
|
106
|
+
returnSchema = import_zod.z.object({
|
|
107
|
+
output: zodSchema
|
|
108
|
+
});
|
|
105
109
|
}
|
|
106
110
|
return new N8nStructuredOutputParser(context, returnSchema);
|
|
107
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../utils/output_parsers/N8nStructuredOutputParser.ts"],"sourcesContent":["import type { Callbacks } from '@langchain/core/callbacks/manager';\nimport { StructuredOutputParser } from 'langchain/output_parsers';\nimport get from 'lodash/get';\nimport type { ISupplyDataFunctions } from 'n8n-workflow';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport { z } from 'zod';\n\nimport { logAiEvent, unwrapNestedOutput } from '../helpers';\n\nconst STRUCTURED_OUTPUT_KEY = '__structured__output';\nconst STRUCTURED_OUTPUT_OBJECT_KEY = '__structured__output__object';\nconst STRUCTURED_OUTPUT_ARRAY_KEY = '__structured__output__array';\n\nexport class N8nStructuredOutputParser extends StructuredOutputParser<\n\tz.ZodType<object, z.ZodTypeDef, object>\n> {\n\tconstructor(\n\t\tprivate context: ISupplyDataFunctions,\n\t\tzodSchema: z.ZodSchema<object>,\n\t) {\n\t\tsuper(zodSchema);\n\t}\n\n\tlc_namespace = ['langchain', 'output_parsers', 'structured'];\n\n\tasync parse(\n\t\ttext: string,\n\t\t_callbacks?: Callbacks,\n\t\terrorMapper?: (error: Error) => Error,\n\t): Promise<object> {\n\t\tconst { index } = this.context.addInputData(NodeConnectionTypes.AiOutputParser, [\n\t\t\t[{ json: { action: 'parse', text } }],\n\t\t]);\n\t\ttry {\n\t\t\tconst jsonString = text.includes('```') ? text.split(/```(?:json)?/)[1] : text;\n\t\t\tconst json = JSON.parse(jsonString.trim());\n\t\t\tconst parsed = await this.schema.parseAsync(json);\n\n\t\t\tlet result = (get(parsed, [STRUCTURED_OUTPUT_KEY, STRUCTURED_OUTPUT_OBJECT_KEY]) ??\n\t\t\t\tget(parsed, [STRUCTURED_OUTPUT_KEY, STRUCTURED_OUTPUT_ARRAY_KEY]) ??\n\t\t\t\tget(parsed, STRUCTURED_OUTPUT_KEY) ??\n\t\t\t\tparsed) as Record<string, unknown>;\n\n\t\t\t// Unwrap any doubly-nested output structures (e.g., {output: {output: {...}}})\n\t\t\tresult = unwrapNestedOutput(result);\n\n\t\t\tlogAiEvent(this.context, 'ai-output-parsed', { text, response: result });\n\n\t\t\tthis.context.addOutputData(NodeConnectionTypes.AiOutputParser, index, [\n\t\t\t\t[{ json: { action: 'parse', response: result } }],\n\t\t\t]);\n\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tconst nodeError = new NodeOperationError(\n\t\t\t\tthis.context.getNode(),\n\t\t\t\t\"Model output doesn't fit required format\",\n\t\t\t\t{\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"To continue the execution when this happens, change the 'On Error' parameter in the root node's settings\",\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tlogAiEvent(this.context, 'ai-output-parsed', {\n\t\t\t\ttext,\n\t\t\t\tresponse: e.message ?? e,\n\t\t\t});\n\n\t\t\tthis.context.addOutputData(NodeConnectionTypes.AiOutputParser, index, nodeError);\n\t\t\tif (errorMapper) {\n\t\t\t\tthrow errorMapper(e);\n\t\t\t}\n\n\t\t\tthrow nodeError;\n\t\t}\n\t}\n\n\tstatic async fromZodJsonSchema(\n\t\tzodSchema: z.ZodSchema<object>,\n\t\tnodeVersion: number,\n\t\tcontext: ISupplyDataFunctions,\n\t): Promise<N8nStructuredOutputParser> {\n\t\tlet returnSchema: z.ZodType<object, z.ZodTypeDef, object>;\n\t\tif (nodeVersion === 1) {\n\t\t\treturnSchema = z.object({\n\t\t\t\t[STRUCTURED_OUTPUT_KEY]: z\n\t\t\t\t\t.object({\n\t\t\t\t\t\t[STRUCTURED_OUTPUT_OBJECT_KEY]: zodSchema.optional(),\n\t\t\t\t\t\t[STRUCTURED_OUTPUT_ARRAY_KEY]: z.array(zodSchema).optional(),\n\t\t\t\t\t})\n\t\t\t\t\t.describe(\n\t\t\t\t\t\t`Wrapper around the output data. It can only contain ${STRUCTURED_OUTPUT_OBJECT_KEY} or ${STRUCTURED_OUTPUT_ARRAY_KEY} but never both.`,\n\t\t\t\t\t)\n\t\t\t\t\t.refine(\n\t\t\t\t\t\t(data) => {\n\t\t\t\t\t\t\t// Validate that one and only one of the properties exists\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\tBoolean(data[STRUCTURED_OUTPUT_OBJECT_KEY]) !==\n\t\t\t\t\t\t\t\tBoolean(data[STRUCTURED_OUTPUT_ARRAY_KEY])\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t'One and only one of __structured__output__object and __structured__output__array should be present.',\n\t\t\t\t\t\t\tpath: [STRUCTURED_OUTPUT_KEY],\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t});\n\t\t} else {\n\t\t\treturnSchema = z.object({\n\t\t\t\toutput: zodSchema.optional(),\n\t\t\t});\n\t\t}\n\n\t\treturn new N8nStructuredOutputParser(context, returnSchema);\n\t}\n\n\tgetSchema() {\n\t\treturn this.schema;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAuC;AACvC,iBAAgB;AAEhB,0BAAwD;AACxD,iBAAkB;AAElB,qBAA+C;AAE/C,MAAM,wBAAwB;AAC9B,MAAM,+BAA+B;AACrC,MAAM,8BAA8B;AAE7B,MAAM,kCAAkC,6CAE7C;AAAA,EACD,YACS,SACR,WACC;AACD,UAAM,SAAS;AAHP;AAMT,wBAAe,CAAC,aAAa,kBAAkB,YAAY;AAAA,EAF3D;AAAA,EAIA,MAAM,MACL,MACA,YACA,aACkB;AAClB,UAAM,EAAE,MAAM,IAAI,KAAK,QAAQ,aAAa,wCAAoB,gBAAgB;AAAA,MAC/E,CAAC,EAAE,MAAM,EAAE,QAAQ,SAAS,KAAK,EAAE,CAAC;AAAA,IACrC,CAAC;AACD,QAAI;AACH,YAAM,aAAa,KAAK,SAAS,KAAK,IAAI,KAAK,MAAM,cAAc,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EACC;AAAA,UACA,CAAC,SAAS;AAET,mBACC,QAAQ,KAAK,4BAA4B,CAAC,MAC1C,QAAQ,KAAK,2BAA2B,CAAC;AAAA,UAE3C;AAAA,UACA;AAAA,YACC,SACC;AAAA,YACD,MAAM,CAAC,qBAAqB;AAAA,UAC7B;AAAA,QACD;AAAA,MACF,CAAC;AAAA,IACF,
|
|
1
|
+
{"version":3,"sources":["../../../utils/output_parsers/N8nStructuredOutputParser.ts"],"sourcesContent":["import type { Callbacks } from '@langchain/core/callbacks/manager';\nimport { StructuredOutputParser } from 'langchain/output_parsers';\nimport get from 'lodash/get';\nimport type { ISupplyDataFunctions } from 'n8n-workflow';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport { z } from 'zod';\n\nimport { logAiEvent, unwrapNestedOutput } from '../helpers';\n\nconst STRUCTURED_OUTPUT_KEY = '__structured__output';\nconst STRUCTURED_OUTPUT_OBJECT_KEY = '__structured__output__object';\nconst STRUCTURED_OUTPUT_ARRAY_KEY = '__structured__output__array';\n\nexport class N8nStructuredOutputParser extends StructuredOutputParser<\n\tz.ZodType<object, z.ZodTypeDef, object>\n> {\n\tconstructor(\n\t\tprivate context: ISupplyDataFunctions,\n\t\tzodSchema: z.ZodSchema<object>,\n\t) {\n\t\tsuper(zodSchema);\n\t}\n\n\tlc_namespace = ['langchain', 'output_parsers', 'structured'];\n\n\tasync parse(\n\t\ttext: string,\n\t\t_callbacks?: Callbacks,\n\t\terrorMapper?: (error: Error) => Error,\n\t): Promise<object> {\n\t\tconst { index } = this.context.addInputData(NodeConnectionTypes.AiOutputParser, [\n\t\t\t[{ json: { action: 'parse', text } }],\n\t\t]);\n\t\ttry {\n\t\t\tconst jsonString = text.includes('```') ? text.split(/```(?:json)?/)[1] : text;\n\t\t\tconst json = JSON.parse(jsonString.trim());\n\t\t\tconst parsed = await this.schema.parseAsync(json);\n\n\t\t\tlet result = (get(parsed, [STRUCTURED_OUTPUT_KEY, STRUCTURED_OUTPUT_OBJECT_KEY]) ??\n\t\t\t\tget(parsed, [STRUCTURED_OUTPUT_KEY, STRUCTURED_OUTPUT_ARRAY_KEY]) ??\n\t\t\t\tget(parsed, STRUCTURED_OUTPUT_KEY) ??\n\t\t\t\tparsed) as Record<string, unknown>;\n\n\t\t\t// Unwrap any doubly-nested output structures (e.g., {output: {output: {...}}})\n\t\t\tresult = unwrapNestedOutput(result);\n\n\t\t\tlogAiEvent(this.context, 'ai-output-parsed', { text, response: result });\n\n\t\t\tthis.context.addOutputData(NodeConnectionTypes.AiOutputParser, index, [\n\t\t\t\t[{ json: { action: 'parse', response: result } }],\n\t\t\t]);\n\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tconst nodeError = new NodeOperationError(\n\t\t\t\tthis.context.getNode(),\n\t\t\t\t\"Model output doesn't fit required format\",\n\t\t\t\t{\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"To continue the execution when this happens, change the 'On Error' parameter in the root node's settings\",\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tlogAiEvent(this.context, 'ai-output-parsed', {\n\t\t\t\ttext,\n\t\t\t\tresponse: e.message ?? e,\n\t\t\t});\n\n\t\t\tthis.context.addOutputData(NodeConnectionTypes.AiOutputParser, index, nodeError);\n\t\t\tif (errorMapper) {\n\t\t\t\tthrow errorMapper(e);\n\t\t\t}\n\n\t\t\tthrow nodeError;\n\t\t}\n\t}\n\n\tstatic async fromZodJsonSchema(\n\t\tzodSchema: z.ZodSchema<object>,\n\t\tnodeVersion: number,\n\t\tcontext: ISupplyDataFunctions,\n\t): Promise<N8nStructuredOutputParser> {\n\t\tlet returnSchema: z.ZodType<object, z.ZodTypeDef, object>;\n\t\tif (nodeVersion === 1) {\n\t\t\treturnSchema = z.object({\n\t\t\t\t[STRUCTURED_OUTPUT_KEY]: z\n\t\t\t\t\t.object({\n\t\t\t\t\t\t[STRUCTURED_OUTPUT_OBJECT_KEY]: zodSchema.optional(),\n\t\t\t\t\t\t[STRUCTURED_OUTPUT_ARRAY_KEY]: z.array(zodSchema).optional(),\n\t\t\t\t\t})\n\t\t\t\t\t.describe(\n\t\t\t\t\t\t`Wrapper around the output data. It can only contain ${STRUCTURED_OUTPUT_OBJECT_KEY} or ${STRUCTURED_OUTPUT_ARRAY_KEY} but never both.`,\n\t\t\t\t\t)\n\t\t\t\t\t.refine(\n\t\t\t\t\t\t(data) => {\n\t\t\t\t\t\t\t// Validate that one and only one of the properties exists\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\tBoolean(data[STRUCTURED_OUTPUT_OBJECT_KEY]) !==\n\t\t\t\t\t\t\t\tBoolean(data[STRUCTURED_OUTPUT_ARRAY_KEY])\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t'One and only one of __structured__output__object and __structured__output__array should be present.',\n\t\t\t\t\t\t\tpath: [STRUCTURED_OUTPUT_KEY],\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t});\n\t\t} else if (nodeVersion < 1.3) {\n\t\t\treturnSchema = z.object({\n\t\t\t\toutput: zodSchema.optional(),\n\t\t\t});\n\t\t} else {\n\t\t\treturnSchema = z.object({\n\t\t\t\toutput: zodSchema,\n\t\t\t});\n\t\t}\n\n\t\treturn new N8nStructuredOutputParser(context, returnSchema);\n\t}\n\n\tgetSchema() {\n\t\treturn this.schema;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAuC;AACvC,iBAAgB;AAEhB,0BAAwD;AACxD,iBAAkB;AAElB,qBAA+C;AAE/C,MAAM,wBAAwB;AAC9B,MAAM,+BAA+B;AACrC,MAAM,8BAA8B;AAE7B,MAAM,kCAAkC,6CAE7C;AAAA,EACD,YACS,SACR,WACC;AACD,UAAM,SAAS;AAHP;AAMT,wBAAe,CAAC,aAAa,kBAAkB,YAAY;AAAA,EAF3D;A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GAAG;AACtB,qBAAe,aAAE,OAAO;AAAA,QACvB,CAAC,qBAAqB,GAAG,aACvB,OAAO;AAAA,UACP,CAAC,4BAA4B,GAAG,UAAU,SAAS;AAAA,UACnD,CAAC,2BAA2B,GAAG,aAAE,MAAM,SAAS,EAAE,SAAS;AAAA,QAC5D,CAAC,EACA;AAAA,UACA,uDAAuD,4BAA4B,OAAO,2BAA2B;AAAA,QACtH,EACC;AAAA,UACA,CAAC,SAAS;AAET,mBACC,QAAQ,KAAK,4BAA4B,CAAC,MAC1C,QAAQ,KAAK,2BAA2B,CAAC;AAAA,UAE3C;AAAA,UACA;AAAA,YACC,SACC;AAAA,YACD,MAAM,CAAC,qBAAqB;AAAA,UAC7B;AAAA,QACD;AAAA,MACF,CAAC;AAAA,IACF,WAAW,cAAc,KAAK;AAC7B,qBAAe,aAAE,OAAO;AAAA,QACvB,QAAQ,UAAU,SAAS;AAAA,MAC5B,CAAC;AAAA,IACF,OAAO;AACN,qBAAe,aAAE,OAAO;AAAA,QACvB,QAAQ;AAAA,MACT,CAAC;AAAA,IACF;AAEA,WAAO,IAAI,0BAA0B,SAAS,YAAY;AAAA,EAC3D;AAAA,EAEA,YAAY;AACX,WAAO,KAAK;AAAA,EACb;AACD;","names":["get"]}
|
|
@@ -19,16 +19,40 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var schemaParsing_exports = {};
|
|
20
20
|
__export(schemaParsing_exports, {
|
|
21
21
|
convertJsonSchemaToZod: () => convertJsonSchemaToZod,
|
|
22
|
-
|
|
22
|
+
generateSchemaFromExample: () => generateSchemaFromExample,
|
|
23
23
|
throwIfToolSchema: () => throwIfToolSchema
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(schemaParsing_exports);
|
|
26
26
|
var import_json_schema_to_zod = require("@n8n/json-schema-to-zod");
|
|
27
27
|
var import_generate_schema = require("generate-schema");
|
|
28
28
|
var import_n8n_workflow = require("n8n-workflow");
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
function makeAllPropertiesRequired(schema) {
|
|
30
|
+
function isPropertySchema(property) {
|
|
31
|
+
return typeof property === "object" && property !== null && "type" in property;
|
|
32
|
+
}
|
|
33
|
+
if (schema.type === "object" && schema.properties) {
|
|
34
|
+
const properties = Object.keys(schema.properties);
|
|
35
|
+
if (properties.length > 0) {
|
|
36
|
+
schema.required = properties;
|
|
37
|
+
}
|
|
38
|
+
for (const key of properties) {
|
|
39
|
+
if (isPropertySchema(schema.properties[key])) {
|
|
40
|
+
makeAllPropertiesRequired(schema.properties[key]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (schema.type === "array" && schema.items && isPropertySchema(schema.items)) {
|
|
45
|
+
schema.items = makeAllPropertiesRequired(schema.items);
|
|
46
|
+
}
|
|
47
|
+
return schema;
|
|
48
|
+
}
|
|
49
|
+
function generateSchemaFromExample(exampleJsonString, allFieldsRequired = false) {
|
|
50
|
+
const parsedExample = (0, import_n8n_workflow.jsonParse)(exampleJsonString);
|
|
51
|
+
const schema = (0, import_generate_schema.json)(parsedExample);
|
|
52
|
+
if (allFieldsRequired) {
|
|
53
|
+
return makeAllPropertiesRequired(schema);
|
|
54
|
+
}
|
|
55
|
+
return schema;
|
|
32
56
|
}
|
|
33
57
|
function convertJsonSchemaToZod(schema) {
|
|
34
58
|
return (0, import_json_schema_to_zod.jsonSchemaToZod)(schema);
|
|
@@ -45,7 +69,7 @@ function throwIfToolSchema(ctx, error) {
|
|
|
45
69
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
70
|
0 && (module.exports = {
|
|
47
71
|
convertJsonSchemaToZod,
|
|
48
|
-
|
|
72
|
+
generateSchemaFromExample,
|
|
49
73
|
throwIfToolSchema
|
|
50
74
|
});
|
|
51
75
|
//# sourceMappingURL=schemaParsing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../utils/schemaParsing.ts"],"sourcesContent":["import { jsonSchemaToZod } from '@n8n/json-schema-to-zod';\nimport { json as generateJsonSchema } from 'generate-schema';\nimport type { SchemaObject } from 'generate-schema';\nimport type { JSONSchema7 } from 'json-schema';\nimport type { IExecuteFunctions } from 'n8n-workflow';\nimport { NodeOperationError, jsonParse } from 'n8n-workflow';\nimport type { z } from 'zod';\n\nexport function
|
|
1
|
+
{"version":3,"sources":["../../utils/schemaParsing.ts"],"sourcesContent":["import { jsonSchemaToZod } from '@n8n/json-schema-to-zod';\nimport { json as generateJsonSchema } from 'generate-schema';\nimport type { SchemaObject } from 'generate-schema';\nimport type { JSONSchema7 } from 'json-schema';\nimport type { IExecuteFunctions } from 'n8n-workflow';\nimport { NodeOperationError, jsonParse } from 'n8n-workflow';\nimport type { z } from 'zod';\n\nfunction makeAllPropertiesRequired(schema: JSONSchema7): JSONSchema7 {\n\tfunction isPropertySchema(property: unknown): property is JSONSchema7 {\n\t\treturn typeof property === 'object' && property !== null && 'type' in property;\n\t}\n\n\t// Handle object properties\n\tif (schema.type === 'object' && schema.properties) {\n\t\tconst properties = Object.keys(schema.properties);\n\t\tif (properties.length > 0) {\n\t\t\tschema.required = properties;\n\t\t}\n\n\t\tfor (const key of properties) {\n\t\t\tif (isPropertySchema(schema.properties[key])) {\n\t\t\t\tmakeAllPropertiesRequired(schema.properties[key]);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Handle arrays\n\tif (schema.type === 'array' && schema.items && isPropertySchema(schema.items)) {\n\t\tschema.items = makeAllPropertiesRequired(schema.items);\n\t}\n\n\treturn schema;\n}\n\nexport function generateSchemaFromExample(\n\texampleJsonString: string,\n\tallFieldsRequired = false,\n): JSONSchema7 {\n\tconst parsedExample = jsonParse<SchemaObject>(exampleJsonString);\n\n\tconst schema = generateJsonSchema(parsedExample) as JSONSchema7;\n\n\tif (allFieldsRequired) {\n\t\treturn makeAllPropertiesRequired(schema);\n\t}\n\n\treturn schema;\n}\n\nexport function convertJsonSchemaToZod<T extends z.ZodTypeAny = z.ZodTypeAny>(schema: JSONSchema7) {\n\treturn jsonSchemaToZod<T>(schema);\n}\n\nexport function throwIfToolSchema(ctx: IExecuteFunctions, error: Error) {\n\tif (error?.message?.includes('tool input did not match expected schema')) {\n\t\tthrow new NodeOperationError(\n\t\t\tctx.getNode(),\n\t\t\t`${error.message}.\n\t\t\tThis is most likely because some of your tools are configured to require a specific schema. This is not supported by Conversational Agent. Remove the schema from the tool configuration or use Tools agent instead.`,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAgC;AAChC,6BAA2C;AAI3C,0BAA8C;AAG9C,SAAS,0BAA0B,QAAkC;AACpE,WAAS,iBAAiB,UAA4C;AACrE,WAAO,OAAO,aAAa,YAAY,aAAa,QAAQ,UAAU;AAAA,EACvE;AAGA,MAAI,OAAO,SAAS,YAAY,OAAO,YAAY;AAClD,UAAM,aAAa,OAAO,KAAK,OAAO,UAAU;AAChD,QAAI,WAAW,SAAS,GAAG;AAC1B,aAAO,WAAW;AAAA,IACnB;AAEA,eAAW,OAAO,YAAY;AAC7B,UAAI,iBAAiB,OAAO,WAAW,GAAG,CAAC,GAAG;AAC7C,kCAA0B,OAAO,WAAW,GAAG,CAAC;AAAA,MACjD;AAAA,IACD;AAAA,EACD;AAGA,MAAI,OAAO,SAAS,WAAW,OAAO,SAAS,iBAAiB,OAAO,KAAK,GAAG;AAC9E,WAAO,QAAQ,0BAA0B,OAAO,KAAK;AAAA,EACtD;AAEA,SAAO;AACR;AAEO,SAAS,0BACf,mBACA,oBAAoB,OACN;AACd,QAAM,oBAAgB,+BAAwB,iBAAiB;AAE/D,QAAM,aAAS,uBAAAA,MAAmB,aAAa;AAE/C,MAAI,mBAAmB;AACtB,WAAO,0BAA0B,MAAM;AAAA,EACxC;AAEA,SAAO;AACR;AAEO,SAAS,uBAA8D,QAAqB;AAClG,aAAO,2CAAmB,MAAM;AACjC;AAEO,SAAS,kBAAkB,KAAwB,OAAc;AACvE,MAAI,OAAO,SAAS,SAAS,0CAA0C,GAAG;AACzE,UAAM,IAAI;AAAA,MACT,IAAI,QAAQ;AAAA,MACZ,GAAG,MAAM,OAAO;AAAA;AAAA,IAEjB;AAAA,EACD;AACD;","names":["generateJsonSchema"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/n8n-nodes-langchain",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.97.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"dist/nodes/output_parser/OutputParserAutofixing/OutputParserAutofixing.node.js",
|
|
88
88
|
"dist/nodes/output_parser/OutputParserItemList/OutputParserItemList.node.js",
|
|
89
89
|
"dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js",
|
|
90
|
+
"dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js",
|
|
90
91
|
"dist/nodes/retrievers/RetrieverContextualCompression/RetrieverContextualCompression.node.js",
|
|
91
92
|
"dist/nodes/retrievers/RetrieverVectorStore/RetrieverVectorStore.node.js",
|
|
92
93
|
"dist/nodes/retrievers/RetrieverMultiQuery/RetrieverMultiQuery.node.js",
|
|
@@ -135,7 +136,7 @@
|
|
|
135
136
|
"@types/sanitize-html": "^2.11.0",
|
|
136
137
|
"@types/temp": "^0.9.1",
|
|
137
138
|
"tsup": "^8.4.0",
|
|
138
|
-
"n8n-core": "1.
|
|
139
|
+
"n8n-core": "1.97.2"
|
|
139
140
|
},
|
|
140
141
|
"dependencies": {
|
|
141
142
|
"@aws-sdk/client-sso-oidc": "3.808.0",
|
|
@@ -146,11 +147,11 @@
|
|
|
146
147
|
"@google-cloud/resource-manager": "5.3.0",
|
|
147
148
|
"@google/generative-ai": "0.21.0",
|
|
148
149
|
"@huggingface/inference": "2.8.0",
|
|
149
|
-
"@langchain/anthropic": "0.3.
|
|
150
|
+
"@langchain/anthropic": "0.3.21",
|
|
150
151
|
"@langchain/aws": "0.1.3",
|
|
151
152
|
"@langchain/cohere": "0.3.2",
|
|
152
153
|
"@langchain/community": "0.3.24",
|
|
153
|
-
"@langchain/core": "0.3.
|
|
154
|
+
"@langchain/core": "0.3.48",
|
|
154
155
|
"@langchain/google-genai": "0.1.6",
|
|
155
156
|
"@langchain/google-vertexai": "0.1.8",
|
|
156
157
|
"@langchain/groq": "0.1.3",
|
|
@@ -168,7 +169,7 @@
|
|
|
168
169
|
"@n8n/vm2": "3.9.25",
|
|
169
170
|
"@pinecone-database/pinecone": "4.0.0",
|
|
170
171
|
"@qdrant/js-client-rest": "1.14.1",
|
|
171
|
-
"@supabase/supabase-js": "2.
|
|
172
|
+
"@supabase/supabase-js": "2.49.9",
|
|
172
173
|
"@xata.io/client": "0.28.4",
|
|
173
174
|
"@zilliz/milvus2-sdk-node": "^2.5.7",
|
|
174
175
|
"basic-auth": "2.0.1",
|
|
@@ -179,7 +180,7 @@
|
|
|
179
180
|
"form-data": "4.0.0",
|
|
180
181
|
"generate-schema": "2.6.0",
|
|
181
182
|
"html-to-text": "9.0.5",
|
|
182
|
-
"https-proxy-agent": "
|
|
183
|
+
"https-proxy-agent": "7.0.6",
|
|
183
184
|
"jsdom": "23.0.1",
|
|
184
185
|
"langchain": "0.3.11",
|
|
185
186
|
"lodash": "4.17.21",
|
|
@@ -197,10 +198,10 @@
|
|
|
197
198
|
"zod": "3.24.1",
|
|
198
199
|
"zod-to-json-schema": "3.23.3",
|
|
199
200
|
"@n8n/client-oauth2": "0.26.0",
|
|
201
|
+
"n8n-workflow": "1.95.1",
|
|
200
202
|
"@n8n/json-schema-to-zod": "1.3.0",
|
|
201
|
-
"
|
|
202
|
-
"n8n-
|
|
203
|
-
"n8n-nodes-base": "1.95.1"
|
|
203
|
+
"n8n-nodes-base": "1.96.1",
|
|
204
|
+
"@n8n/typescript-config": "1.2.0"
|
|
204
205
|
},
|
|
205
206
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
206
207
|
"homepage": "https://n8n.io",
|