n8n-nodes-simple 2.4.1 → 2.4.2
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/nodes/shared/core/execution/executor.d.ts +2 -2
- package/dist/nodes/shared/core/execution/executor.js +24 -17
- package/dist/nodes/shared/core/execution/executor.js.map +1 -1
- package/dist/nodes/shared/core/execution/messageOperation.js +1 -1
- package/dist/nodes/shared/core/execution/messageOperation.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IExecuteFunctions, INodeExecutionData, IDataObject } from 'n8n-workflow';
|
|
2
2
|
import type { BufferWindowMemory } from 'langchain/memory';
|
|
3
3
|
import { ExtractedParameters } from '../../config/parameters';
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function runModel(executeFunctions: IExecuteFunctions, params: ExtractedParameters, messages: IDataObject[], index: number, modelToUse: string, memory?: BufferWindowMemory): Promise<INodeExecutionData[]>;
|
|
5
|
+
export declare function runModelWithFallback(executeFunctions: IExecuteFunctions, params: ExtractedParameters, messages: IDataObject[], index: number, memory?: BufferWindowMemory): Promise<INodeExecutionData[]>;
|
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.runModel = runModel;
|
|
4
|
+
exports.runModelWithFallback = runModelWithFallback;
|
|
5
5
|
const structuredOutput_1 = require("../request/structuredOutput");
|
|
6
6
|
const setup_1 = require("../tools/setup");
|
|
7
7
|
const body_1 = require("../request/body");
|
|
8
8
|
const executor_1 = require("../tools/executor");
|
|
9
9
|
const outputData_1 = require("./outputData");
|
|
10
10
|
const io_1 = require("../memory/io");
|
|
11
|
-
async function
|
|
11
|
+
async function runModel(executeFunctions, params, messages, index, modelToUse, memory) {
|
|
12
|
+
let responseFormat = (0, structuredOutput_1.configureResponseFormat)(params.responseFormat, params.outputJsonSchemaDefinition, params.structuredOutputName, params.structuredOutputDescription, params.structuredOutputProperties, params.structuredOutputIsArray, params.structuredOutputArrayName, params.structuredOutputArrayDescription);
|
|
13
|
+
const { tools, invokableTools, tool_choice, structuredOutputTool, updatedResponseFormat } = await (0, setup_1.setupTools)(executeFunctions, params.structuredOutputToolsMode, responseFormat);
|
|
14
|
+
const body = (0, body_1.prepareRequestBody)(modelToUse, messages, tools, tool_choice, updatedResponseFormat, params.options, params.customParameters);
|
|
15
|
+
const { response, output } = await (0, executor_1.processToolCalls)(executeFunctions, body, messages, invokableTools, params.maxToolsIterations, params.responseFormat, structuredOutputTool, params.abortSignal);
|
|
16
|
+
const outputData = await (0, outputData_1.prepareOutputData)(response, output, messages, params.addToOutput, executeFunctions, index, body);
|
|
17
|
+
if (memory) {
|
|
18
|
+
await (0, io_1.saveToMemory)(messages, output, params.saveToolCallsInChatMemory, memory);
|
|
19
|
+
}
|
|
20
|
+
return outputData;
|
|
21
|
+
}
|
|
22
|
+
async function runModelWithFallback(executeFunctions, params, messages, index, memory) {
|
|
23
|
+
var _a, _b;
|
|
12
24
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
25
|
+
const item = await runModel(executeFunctions, params, messages, index, params.model, memory);
|
|
26
|
+
if (!item || item.length === 0) {
|
|
27
|
+
throw new Error(`Node execution failed: No data returned. Received: ${JSON.stringify(item)}`);
|
|
28
|
+
}
|
|
29
|
+
if (!((_a = item[0].json) === null || _a === void 0 ? void 0 : _a.output)) {
|
|
30
|
+
throw new Error(`Node execution failed: Output invalid. Output value: ${JSON.stringify((_b = item[0].json) === null || _b === void 0 ? void 0 : _b.output)}`);
|
|
31
|
+
}
|
|
32
|
+
return item;
|
|
15
33
|
}
|
|
16
34
|
catch (error) {
|
|
17
35
|
if (params.fallbackModel) {
|
|
18
36
|
console.error(`Primary model ${params.model} failed with error, trying fallback model ${params.fallbackModel}:`, error);
|
|
19
37
|
try {
|
|
20
|
-
return await
|
|
38
|
+
return await runModel(executeFunctions, params, messages, index, params.fallbackModel, memory);
|
|
21
39
|
}
|
|
22
40
|
catch (fallbackError) {
|
|
23
41
|
console.error(`Fallback model ${params.fallbackModel} also failed:`, fallbackError);
|
|
@@ -27,15 +45,4 @@ async function executeWithFallback(executeFunctions, params, messages, index, me
|
|
|
27
45
|
throw error;
|
|
28
46
|
}
|
|
29
47
|
}
|
|
30
|
-
async function executeSingleModel(executeFunctions, params, messages, index, modelToUse, memory) {
|
|
31
|
-
let responseFormat = (0, structuredOutput_1.configureResponseFormat)(params.responseFormat, params.outputJsonSchemaDefinition, params.structuredOutputName, params.structuredOutputDescription, params.structuredOutputProperties, params.structuredOutputIsArray, params.structuredOutputArrayName, params.structuredOutputArrayDescription);
|
|
32
|
-
const { tools, invokableTools, tool_choice, structuredOutputTool, updatedResponseFormat } = await (0, setup_1.setupTools)(executeFunctions, params.structuredOutputToolsMode, responseFormat);
|
|
33
|
-
const body = (0, body_1.prepareRequestBody)(modelToUse, messages, tools, tool_choice, updatedResponseFormat, params.options, params.customParameters);
|
|
34
|
-
const { response, output } = await (0, executor_1.processToolCalls)(executeFunctions, body, messages, invokableTools, params.maxToolsIterations, params.responseFormat, structuredOutputTool, params.abortSignal);
|
|
35
|
-
const outputData = await (0, outputData_1.prepareOutputData)(response, output, messages, params.addToOutput, executeFunctions, index, body);
|
|
36
|
-
if (memory) {
|
|
37
|
-
await (0, io_1.saveToMemory)(messages, output, params.saveToolCallsInChatMemory, memory);
|
|
38
|
-
}
|
|
39
|
-
return outputData;
|
|
40
|
-
}
|
|
41
48
|
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../nodes/shared/core/execution/executor.ts"],"names":[],"mappings":";;AAaA,
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../nodes/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a,EAAE,CAAC;gBACxB,OAAO,CAAC,KAAK,CAAC,kBAAkB,MAAM,CAAC,aAAa,eAAe,EAAE,aAAa,CAAC,CAAC;gBACpF,MAAM,aAAa,CAAC;YACrB,CAAC;QACF,CAAC;QAED,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC"}
|
|
@@ -9,6 +9,6 @@ async function execute(i) {
|
|
|
9
9
|
const params = (0, parameters_1.extractParameters)(this, i);
|
|
10
10
|
const memory = await (0, io_1.getOptionalMemory)(this);
|
|
11
11
|
const messages = await (0, chatHistory_1.unpackChatHistoryAndMemory)(params.rawMessagesToSend, params.loadToolCallsFromChatMemory, memory);
|
|
12
|
-
return await (0, executor_1.
|
|
12
|
+
return await (0, executor_1.runModelWithFallback)(this, params, messages, i, memory);
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=messageOperation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageOperation.js","sourceRoot":"","sources":["../../../../../nodes/shared/core/execution/messageOperation.ts"],"names":[],"mappings":";;AAUA,0BAyBC;AAjCD,wDAA4D;AAC5D,qCAAiD;AACjD,yDAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"messageOperation.js","sourceRoot":"","sources":["../../../../../nodes/shared/core/execution/messageOperation.ts"],"names":[],"mappings":";;AAUA,0BAyBC;AAjCD,wDAA4D;AAC5D,qCAAiD;AACjD,yDAAqE;AACrE,yCAAkD;AAK3C,KAAK,UAAU,OAAO,CAE5B,CAAS;IAGT,MAAM,MAAM,GAAG,IAAA,8BAAiB,EAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAG1C,MAAM,MAAM,GAAG,MAAM,IAAA,sBAAiB,EAAC,IAAI,CAAC,CAAC;IAG7C,MAAM,QAAQ,GAAG,MAAM,IAAA,wCAA0B,EAChD,MAAM,CAAC,iBAAiB,EACxB,MAAM,CAAC,2BAA2B,EAClC,MAAM,CACN,CAAC;IAGF,OAAO,MAAM,IAAA,+BAAoB,EAChC,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,CAAC,EACD,MAAM,CACN,CAAC;AACH,CAAC"}
|