n8n-nodes-simple 0.2.3 → 0.3.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/credentials/SimpleOpenAiApi.credentials.d.ts +2 -2
- package/dist/credentials/SimpleOpenAiApi.credentials.js +1 -1
- package/dist/credentials/SimpleOpenAiApi.credentials.js.map +1 -1
- package/dist/nodes/CoreAgent/CoreAgent.node.d.ts +2 -3
- package/dist/nodes/CoreAgent/CoreAgent.node.js +2 -14
- package/dist/nodes/CoreAgent/CoreAgent.node.js.map +1 -1
- package/dist/nodes/CoreAgent/descriptions.d.ts +2 -0
- package/dist/nodes/CoreAgent/descriptions.js +21 -0
- package/dist/nodes/CoreAgent/descriptions.js.map +1 -0
- package/dist/nodes/Subagent/Subagent.node.d.ts +3 -4
- package/dist/nodes/Subagent/Subagent.node.js +4 -17
- package/dist/nodes/Subagent/Subagent.node.js.map +1 -1
- package/dist/nodes/Subagent/descriptions.d.ts +2 -0
- package/dist/nodes/Subagent/descriptions.js +22 -0
- package/dist/nodes/Subagent/descriptions.js.map +1 -0
- package/dist/nodes/shared/actions/message.operation.js +58 -38
- package/dist/nodes/shared/actions/message.operation.js.map +1 -1
- package/dist/nodes/shared/actions/router.js +1 -1
- package/dist/nodes/shared/actions/router.js.map +1 -1
- package/dist/nodes/shared/actions/tool.d.ts +2 -0
- package/dist/nodes/shared/actions/{asTool.js → tool.js} +9 -9
- package/dist/nodes/shared/actions/tool.js.map +1 -0
- package/dist/nodes/shared/{helpers/api → api}/errorHandling.js +6 -9
- package/dist/nodes/shared/api/errorHandling.js.map +1 -0
- package/dist/nodes/shared/{helpers/api/apiRequest.d.ts → api/openAiApiRequest.d.ts} +1 -1
- package/dist/nodes/shared/{helpers/api/apiRequest.js → api/openAiApiRequest.js} +3 -3
- package/dist/nodes/shared/api/openAiApiRequest.js.map +1 -0
- package/dist/nodes/shared/{helpers/api/interfaces.js → api/types.js} +1 -1
- package/dist/nodes/shared/api/types.js.map +1 -0
- package/dist/nodes/shared/{helpers/api → api}/utils.js +13 -10
- package/dist/nodes/shared/api/utils.js.map +1 -0
- package/dist/nodes/shared/constants.js.map +1 -0
- package/dist/nodes/shared/createNodeTypeDescription.js +14 -48
- package/dist/nodes/shared/createNodeTypeDescription.js.map +1 -1
- package/dist/nodes/shared/message/processor.d.ts +7 -0
- package/dist/nodes/shared/{helpers/asCoreNode/chatUnpacker.js → message/processor.js} +27 -3
- package/dist/nodes/shared/message/processor.js.map +1 -0
- package/dist/nodes/shared/{helpers/asCoreNode/messageModel.d.ts → message/types.d.ts} +3 -0
- package/dist/nodes/shared/{helpers/asCoreNode/messageModel.js → message/types.js} +1 -1
- package/dist/nodes/shared/message/types.js.map +1 -0
- package/dist/nodes/shared/methods/listSearch.js +2 -2
- package/dist/nodes/shared/methods/listSearch.js.map +1 -1
- package/dist/nodes/shared/properties.js +135 -128
- package/dist/nodes/shared/properties.js.map +1 -1
- package/dist/nodes/shared/tool/customFields.js.map +1 -0
- package/dist/nodes/shared/{helpers/asTool/toolSchemaParsing.js → tool/schemaGenerator.js} +1 -1
- package/dist/nodes/shared/tool/schemaGenerator.js.map +1 -0
- package/dist/nodes/shared/{helpers/asTool → tool}/subagentTool.js +3 -2
- package/dist/nodes/shared/tool/subagentTool.js.map +1 -0
- package/dist/nodes/shared/{helpers/asToolUser/langchainHelpers.js → toolManager/getConnectedTools.js} +4 -4
- package/dist/nodes/shared/toolManager/getConnectedTools.js.map +1 -0
- package/dist/nodes/shared/{helpers/asToolUser/N8nTool.d.ts → toolManager/n8nTool.d.ts} +2 -2
- package/dist/nodes/shared/{helpers/asToolUser/N8nTool.js → toolManager/n8nTool.js} +3 -3
- package/dist/nodes/shared/toolManager/n8nTool.js.map +1 -0
- package/dist/package.json +6 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/dist/credentials/gradientOpenAi.svg +0 -9
- package/dist/nodes/shared/actions/asTool.d.ts +0 -2
- package/dist/nodes/shared/actions/asTool.js.map +0 -1
- package/dist/nodes/shared/gradientRobot.svg +0 -11
- package/dist/nodes/shared/gradientRobotRed.svg +0 -11
- package/dist/nodes/shared/helpers/api/apiRequest.js.map +0 -1
- package/dist/nodes/shared/helpers/api/errorHandling.js.map +0 -1
- package/dist/nodes/shared/helpers/api/interfaces.js.map +0 -1
- package/dist/nodes/shared/helpers/api/utils.js.map +0 -1
- package/dist/nodes/shared/helpers/asCoreNode/chatUnpacker.d.ts +0 -6
- package/dist/nodes/shared/helpers/asCoreNode/chatUnpacker.js.map +0 -1
- package/dist/nodes/shared/helpers/asCoreNode/constants.js.map +0 -1
- package/dist/nodes/shared/helpers/asCoreNode/messageModel.js.map +0 -1
- package/dist/nodes/shared/helpers/asCoreNode/stepsExtractor.d.ts +0 -6
- package/dist/nodes/shared/helpers/asCoreNode/stepsExtractor.js +0 -27
- package/dist/nodes/shared/helpers/asCoreNode/stepsExtractor.js.map +0 -1
- package/dist/nodes/shared/helpers/asTool/customFields.js.map +0 -1
- package/dist/nodes/shared/helpers/asTool/subagentTool.js.map +0 -1
- package/dist/nodes/shared/helpers/asTool/toolSchemaParsing.js.map +0 -1
- package/dist/nodes/shared/helpers/asToolUser/N8nTool.js.map +0 -1
- package/dist/nodes/shared/helpers/asToolUser/langchainHelpers.js.map +0 -1
- /package/dist/nodes/shared/{helpers/api → api}/errorHandling.d.ts +0 -0
- /package/dist/nodes/shared/{helpers/api/interfaces.d.ts → api/types.d.ts} +0 -0
- /package/dist/nodes/shared/{helpers/api → api}/utils.d.ts +0 -0
- /package/dist/nodes/shared/{helpers/asCoreNode/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/nodes/shared/{helpers/asCoreNode/constants.js → constants.js} +0 -0
- /package/dist/nodes/shared/{helpers/asTool → tool}/customFields.d.ts +0 -0
- /package/dist/nodes/shared/{helpers/asTool → tool}/customFields.js +0 -0
- /package/dist/nodes/shared/{helpers/asTool/toolSchemaParsing.d.ts → tool/schemaGenerator.d.ts} +0 -0
- /package/dist/nodes/shared/{helpers/asTool → tool}/subagentTool.d.ts +0 -0
- /package/dist/nodes/shared/{helpers/asToolUser/langchainHelpers.d.ts → toolManager/getConnectedTools.d.ts} +0 -0
|
@@ -4,8 +4,8 @@ export declare class SimpleOpenAiApi implements ICredentialType {
|
|
|
4
4
|
displayName: string;
|
|
5
5
|
documentationUrl: string;
|
|
6
6
|
icon: {
|
|
7
|
-
readonly light: "file
|
|
8
|
-
readonly dark: "file
|
|
7
|
+
readonly light: "file:../../icons/gradientOpenAi.svg";
|
|
8
|
+
readonly dark: "file:../../icons/gradientOpenAi.svg";
|
|
9
9
|
};
|
|
10
10
|
properties: INodeProperties[];
|
|
11
11
|
authenticate: IAuthenticateGeneric;
|
|
@@ -6,7 +6,7 @@ class SimpleOpenAiApi {
|
|
|
6
6
|
this.name = 'simpleOpenAiApi';
|
|
7
7
|
this.displayName = 'Simple OpenAI API';
|
|
8
8
|
this.documentationUrl = 'https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-langchain.openai/text-operations/#message-a-model';
|
|
9
|
-
this.icon = { light: 'file
|
|
9
|
+
this.icon = { light: 'file:../../icons/gradientOpenAi.svg', dark: 'file:../../icons/gradientOpenAi.svg' };
|
|
10
10
|
this.properties = [
|
|
11
11
|
{
|
|
12
12
|
displayName: 'API Key',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleOpenAiApi.credentials.js","sourceRoot":"","sources":["../../credentials/SimpleOpenAiApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,eAAe;IAA5B;QACC,SAAI,GAAG,iBAAiB,CAAC;QAEzB,gBAAW,GAAG,mBAAmB,CAAC;QAElC,qBAAgB,GAAG,gHAAgH,CAAC;QAEpI,SAAI,GAAG,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"SimpleOpenAiApi.credentials.js","sourceRoot":"","sources":["../../credentials/SimpleOpenAiApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,eAAe;IAA5B;QACC,SAAI,GAAG,iBAAiB,CAAC;QAEzB,gBAAW,GAAG,mBAAmB,CAAC;QAElC,qBAAgB,GAAG,gHAAgH,CAAC;QAEpI,SAAI,GAAG,EAAE,KAAK,EAAE,qCAAqC,EAAE,IAAI,EAAE,qCAAqC,EAAW,CAAC;QAE9G,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;aACX;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,2BAA2B;gBACpC,WAAW,EACV,uBAAuB;aACxB;YACD;gBACC,WAAW,EAAE,4BAA4B;gBACzC,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,IAAI,EAAE,uDAAuD;gBAC7D,WAAW,EACV,8MAA8M;aAC/M;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,aAAa,EAAE,iCAAiC;oBAChD,qBAAqB,EAAE,kCAAkC;iBACzD;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,SAAS;aACd;SACD,CAAC;IACH,CAAC;CAAA;AAtDD,0CAsDC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type IExecuteFunctions, type INodeType
|
|
1
|
+
import { type IExecuteFunctions, type INodeType } from 'n8n-workflow';
|
|
2
2
|
import { listSearch } from '../shared/methods';
|
|
3
3
|
export declare class CoreAgent implements INodeType {
|
|
4
|
-
description: INodeTypeDescription;
|
|
5
|
-
constructor();
|
|
4
|
+
description: import("n8n-workflow").INodeTypeDescription;
|
|
6
5
|
methods: {
|
|
7
6
|
listSearch: typeof listSearch;
|
|
8
7
|
};
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoreAgent = void 0;
|
|
4
|
-
const
|
|
4
|
+
const descriptions_1 = require("./descriptions");
|
|
5
5
|
const router_1 = require("../shared/actions/router");
|
|
6
6
|
const methods_1 = require("../shared/methods");
|
|
7
7
|
class CoreAgent {
|
|
8
8
|
constructor() {
|
|
9
|
+
this.description = descriptions_1.coreAgentDescription;
|
|
9
10
|
this.methods = {
|
|
10
11
|
listSearch: methods_1.listSearch,
|
|
11
12
|
};
|
|
12
|
-
this.description = (0, createNodeTypeDescription_1.createNodeTypeDescription)('coreAgent', {
|
|
13
|
-
displayName: 'AI Agent',
|
|
14
|
-
defaults: { name: 'AI Agent' },
|
|
15
|
-
description: 'Agent capable of using tools, subagents, and structured output.',
|
|
16
|
-
icon: { light: 'file:../shared/gradientRobot.svg', dark: 'file:../shared/gradientRobot.svg' },
|
|
17
|
-
codex: {
|
|
18
|
-
alias: ['Special', 'General', 'AI', 'Agent', 'Subagent', 'OpenAI', 'LiteLLM', 'LangChain', 'ChatGPT', 'assistant', 'Chat', 'Conversational', 'Plan and Execute', 'ReAct'],
|
|
19
|
-
categories: ['AI'],
|
|
20
|
-
subcategories: {
|
|
21
|
-
AI: ['Agents', 'Miscellaneous', 'Root Nodes'],
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
13
|
}
|
|
26
14
|
async execute() {
|
|
27
15
|
return await router_1.router.call(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreAgent.node.js","sourceRoot":"","sources":["../../../nodes/CoreAgent/CoreAgent.node.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CoreAgent.node.js","sourceRoot":"","sources":["../../../nodes/CoreAgent/CoreAgent.node.ts"],"names":[],"mappings":";;;AAKA,iDAAsD;AACtD,qDAAkD;AAClD,+CAA+C;AAE/C,MAAa,SAAS;IAAtB;QACC,gBAAW,GAAG,mCAAoB,CAAC;QAEnC,YAAO,GAAG;YACT,UAAU,EAAV,oBAAU;SACV,CAAC;IAMH,CAAC;IAHA,KAAK,CAAC,OAAO;QACZ,OAAO,MAAM,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACD;AAXD,8BAWC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coreAgentDescription = void 0;
|
|
4
|
+
const createNodeTypeDescription_1 = require("../shared/createNodeTypeDescription");
|
|
5
|
+
exports.coreAgentDescription = (0, createNodeTypeDescription_1.createNodeTypeDescription)('coreAgent', {
|
|
6
|
+
displayName: 'AI Agent',
|
|
7
|
+
defaults: { name: 'AI Agent' },
|
|
8
|
+
subtitle: '={{ ($parameter.modelId.split("/")[1] || $parameter.modelId) }}',
|
|
9
|
+
description: 'Agent capable of using tools, subagents, and structured output.',
|
|
10
|
+
codex: {
|
|
11
|
+
alias: [
|
|
12
|
+
'Special', 'General', 'AI', 'Agent', 'Subagent', 'OpenAI', 'LiteLLM',
|
|
13
|
+
'LangChain', 'ChatGPT', 'assistant', 'Chat', 'Conversational', 'Plan and Execute', 'ReAct'
|
|
14
|
+
],
|
|
15
|
+
categories: ['AI'],
|
|
16
|
+
subcategories: {
|
|
17
|
+
AI: ['Agents', 'Miscellaneous', 'Root Nodes'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=descriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../../../nodes/CoreAgent/descriptions.ts"],"names":[],"mappings":";;;AAAA,mFAAgF;AAGnE,QAAA,oBAAoB,GAAyB,IAAA,qDAAyB,EAClF,WAAW,EACX;IACC,WAAW,EAAE,UAAU;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;IAC9B,QAAQ,EAAE,iEAAiE;IAC3E,WAAW,EAAE,iEAAiE;IAC9E,KAAK,EAAE;QACN,KAAK,EAAE;YACN,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS;YACpE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,OAAO;SAC1F;QACD,UAAU,EAAE,CAAC,IAAI,CAAC;QAClB,aAAa,EAAE;YACd,EAAE,EAAE,CAAC,QAAQ,EAAE,eAAe,EAAE,YAAY,CAAC;SAC7C;KACD;CACD,CACD,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { type IExecuteFunctions, type
|
|
1
|
+
import { type IExecuteFunctions, type ISupplyDataFunctions, type INodeType, type SupplyData } from 'n8n-workflow';
|
|
2
2
|
import { listSearch } from '../shared/methods';
|
|
3
3
|
export declare class Subagent implements INodeType {
|
|
4
|
-
description: INodeTypeDescription;
|
|
5
|
-
constructor();
|
|
4
|
+
description: import("n8n-workflow").INodeTypeDescription;
|
|
6
5
|
methods: {
|
|
7
6
|
listSearch: typeof listSearch;
|
|
8
7
|
};
|
|
9
8
|
execute(this: IExecuteFunctions): Promise<import("n8n-workflow").INodeExecutionData[][]>;
|
|
10
|
-
supplyData(this:
|
|
9
|
+
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
11
10
|
}
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Subagent = void 0;
|
|
4
|
-
const
|
|
4
|
+
const descriptions_1 = require("./descriptions");
|
|
5
5
|
const router_1 = require("../shared/actions/router");
|
|
6
|
-
const
|
|
6
|
+
const tool_1 = require("../shared/actions/tool");
|
|
7
7
|
const methods_1 = require("../shared/methods");
|
|
8
8
|
class Subagent {
|
|
9
9
|
constructor() {
|
|
10
|
+
this.description = descriptions_1.subAgentDescription;
|
|
10
11
|
this.methods = {
|
|
11
12
|
listSearch: methods_1.listSearch,
|
|
12
13
|
};
|
|
13
|
-
this.description = (0, createNodeTypeDescription_1.createNodeTypeDescription)('subAgent', {
|
|
14
|
-
displayName: 'AI Subagent',
|
|
15
|
-
defaults: { name: 'AI Subagent' },
|
|
16
|
-
description: 'Subagent capable of using tools and subagents.',
|
|
17
|
-
icon: { light: 'file:../shared/gradientRobot.svg', dark: 'file:../shared/gradientRobot.svg' },
|
|
18
|
-
codex: {
|
|
19
|
-
alias: ['Special', 'General', 'AI', 'Agent', 'Subagent', 'OpenAI', 'LiteLLM', 'LangChain', 'ChatGPT', 'assistant', 'Chat', 'Conversational', 'Plan and Execute', 'ReAct', 'Tools'],
|
|
20
|
-
categories: ['AI'],
|
|
21
|
-
subcategories: {
|
|
22
|
-
AI: ['Miscellaneous', 'Tools'],
|
|
23
|
-
Tools: ['Recommended Tools', 'Other Tools'],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
14
|
}
|
|
28
15
|
async execute() {
|
|
29
16
|
return await router_1.router.call(this);
|
|
30
17
|
}
|
|
31
18
|
async supplyData(itemIndex) {
|
|
32
|
-
return await
|
|
19
|
+
return await tool_1.executeAsTool.call(this, itemIndex);
|
|
33
20
|
}
|
|
34
21
|
}
|
|
35
22
|
exports.Subagent = Subagent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subagent.node.js","sourceRoot":"","sources":["../../../nodes/Subagent/Subagent.node.ts"],"names":[],"mappings":";;;AAOA,
|
|
1
|
+
{"version":3,"file":"Subagent.node.js","sourceRoot":"","sources":["../../../nodes/Subagent/Subagent.node.ts"],"names":[],"mappings":";;;AAOA,iDAAqD;AACrD,qDAAkD;AAClD,iDAAuD;AACvD,+CAA+C;AAE/C,MAAa,QAAQ;IAArB;QACC,gBAAW,GAAG,kCAAmB,CAAC;QAElC,YAAO,GAAG;YACT,UAAU,EAAV,oBAAU;SACV,CAAC;IAWH,CAAC;IARA,KAAK,CAAC,OAAO;QACZ,OAAO,MAAM,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAGD,KAAK,CAAC,UAAU,CAA6B,SAAiB;QAC7D,OAAO,MAAM,oBAAa,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;CACD;AAhBD,4BAgBC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subAgentDescription = void 0;
|
|
4
|
+
const createNodeTypeDescription_1 = require("../shared/createNodeTypeDescription");
|
|
5
|
+
exports.subAgentDescription = (0, createNodeTypeDescription_1.createNodeTypeDescription)('subAgent', {
|
|
6
|
+
displayName: 'AI Subagent',
|
|
7
|
+
defaults: { name: 'AI Subagent' },
|
|
8
|
+
subtitle: '={{ $parameter.name + " | " + ($parameter.modelId.split("/")[1] || $parameter.modelId) }}',
|
|
9
|
+
description: 'Subagent capable of using tools and subagents.',
|
|
10
|
+
codex: {
|
|
11
|
+
alias: [
|
|
12
|
+
'Special', 'General', 'AI', 'Agent', 'Subagent', 'OpenAI', 'LiteLLM',
|
|
13
|
+
'LangChain', 'ChatGPT', 'assistant', 'Chat', 'Conversational', 'Plan and Execute', 'ReAct', 'Tools'
|
|
14
|
+
],
|
|
15
|
+
categories: ['AI'],
|
|
16
|
+
subcategories: {
|
|
17
|
+
AI: ['Miscellaneous', 'Tools'],
|
|
18
|
+
Tools: ['Recommended Tools', 'Other Tools'],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=descriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../../../nodes/Subagent/descriptions.ts"],"names":[],"mappings":";;;AAAA,mFAAgF;AAGnE,QAAA,mBAAmB,GAAyB,IAAA,qDAAyB,EACjF,UAAU,EACV;IACC,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;IACjC,QAAQ,EAAE,2FAA2F;IACrG,WAAW,EAAE,gDAAgD;IAC7D,KAAK,EAAE;QACN,KAAK,EAAE;YACN,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS;YACpE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO;SACnG;QACD,UAAU,EAAE,CAAC,IAAI,CAAC;QAClB,aAAa,EAAE;YACd,EAAE,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC;YAC9B,KAAK,EAAE,CAAC,mBAAmB,EAAE,aAAa,CAAC;SAC3C;KACD;CACD,CACD,CAAC"}
|
|
@@ -7,29 +7,33 @@ exports.execute = execute;
|
|
|
7
7
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
8
8
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
9
9
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
10
|
-
const
|
|
11
|
-
const utils_1 = require("../
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const chatUnpacker_1 = require("../helpers/asCoreNode/chatUnpacker");
|
|
10
|
+
const openAiApiRequest_1 = require("../api/openAiApiRequest");
|
|
11
|
+
const utils_1 = require("../api/utils");
|
|
12
|
+
const getConnectedTools_1 = require("../toolManager/getConnectedTools");
|
|
13
|
+
const types_1 = require("../message/types");
|
|
14
|
+
const processor_1 = require("../message/processor");
|
|
16
15
|
async function execute(i, parentMessageContentStr = '', parentMessageContentObj = {}) {
|
|
17
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18
17
|
const model = this.getNodeParameter('modelId', i, '', { extractValue: true });
|
|
19
|
-
const temperature = this.getNodeParameter('temperature', i, 1);
|
|
20
18
|
const agentType = this.getNodeParameter('agentType', i, 'coreAgent');
|
|
21
19
|
const rawMessagesToSend = this.getNodeParameter('messagesToSend.values', i, []);
|
|
22
20
|
const inputSchemaType = this.getNodeParameter('inputSchemaType', i, '');
|
|
23
|
-
const
|
|
21
|
+
const responseFormat = this.getNodeParameter('responseFormat', i, '');
|
|
24
22
|
const addToOutput = this.getNodeParameter('addToOutput', i, []);
|
|
25
23
|
const outputJsonSchema = this.getNodeParameter('outputJsonSchema', i, '');
|
|
26
24
|
const options = this.getNodeParameter('options', i, {});
|
|
27
25
|
const maxToolsIterations = this.getNodeParameter('options.maxToolsIterations', i, 15);
|
|
28
26
|
const customParameters = this.getNodeParameter('options.customParameters', i, '{}');
|
|
29
27
|
const abortSignal = this.getExecutionCancelSignal();
|
|
30
|
-
|
|
28
|
+
let memoryInput;
|
|
29
|
+
try {
|
|
30
|
+
memoryInput = (await this.getInputConnectionData("ai_memory", 0, undefined));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
memoryInput = undefined;
|
|
34
|
+
}
|
|
31
35
|
let memory = Array.isArray(memoryInput) ? memoryInput[0] : memoryInput;
|
|
32
|
-
let messages = await (0,
|
|
36
|
+
let messages = await (0, processor_1.unpackChatHistoryAndMemory)(rawMessagesToSend, memory);
|
|
33
37
|
messages = messages.filter(item => item.content !== '');
|
|
34
38
|
if (inputSchemaType === 'default' && parentMessageContentStr !== '') {
|
|
35
39
|
messages.push({ role: "user", content: parentMessageContentStr });
|
|
@@ -42,16 +46,30 @@ async function execute(i, parentMessageContentStr = '', parentMessageContentObj
|
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
48
|
let response_format;
|
|
45
|
-
if (structuredOutput) {
|
|
49
|
+
if (responseFormat === 'structuredOutput') {
|
|
46
50
|
response_format = { type: 'json_schema', json_schema: JSON.parse(outputJsonSchema) };
|
|
47
51
|
}
|
|
52
|
+
else if (responseFormat === 'jsonMode') {
|
|
53
|
+
response_format = { type: 'json_object' };
|
|
54
|
+
}
|
|
48
55
|
let tools;
|
|
49
56
|
let externalTools = [];
|
|
50
57
|
const enforceUniqueNames = true;
|
|
51
|
-
externalTools = await (0,
|
|
58
|
+
externalTools = await (0, getConnectedTools_1.getConnectedTools)(this, enforceUniqueNames, false);
|
|
59
|
+
let invokableTools = [];
|
|
52
60
|
if (externalTools.length) {
|
|
53
|
-
|
|
61
|
+
for (const tool of externalTools) {
|
|
62
|
+
if ('tools' in tool && Array.isArray(tool.tools)) {
|
|
63
|
+
for (const subTool of tool.tools) {
|
|
64
|
+
invokableTools.push(subTool);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
invokableTools.push(tool);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
54
71
|
}
|
|
72
|
+
tools = invokableTools.map(utils_1.formatToOpenAITool);
|
|
55
73
|
let customParamsObj = {};
|
|
56
74
|
if (customParameters && customParameters.trim() !== '') {
|
|
57
75
|
try {
|
|
@@ -67,18 +85,17 @@ async function execute(i, parentMessageContentStr = '', parentMessageContentObj
|
|
|
67
85
|
]);
|
|
68
86
|
const body = {
|
|
69
87
|
model,
|
|
70
|
-
temperature,
|
|
71
88
|
messages,
|
|
72
89
|
tools,
|
|
73
90
|
response_format,
|
|
74
91
|
...cleanOptions,
|
|
75
92
|
...customParamsObj
|
|
76
93
|
};
|
|
77
|
-
if (!Array.isArray(messages) || !messages.every(
|
|
94
|
+
if (!Array.isArray(messages) || !messages.every(types_1.isValidMessage)) {
|
|
78
95
|
throw new Error("Invalid or missing 'messages' in the request body.");
|
|
79
96
|
}
|
|
80
97
|
const originalMessagesLength = messages.length;
|
|
81
|
-
let response = (await
|
|
98
|
+
let response = (await openAiApiRequest_1.openAiApiRequest.call(this, 'POST', `/chat/completions`, {
|
|
82
99
|
body,
|
|
83
100
|
}));
|
|
84
101
|
if (!response)
|
|
@@ -94,31 +111,33 @@ async function execute(i, parentMessageContentStr = '', parentMessageContentObj
|
|
|
94
111
|
for (const toolCall of toolCalls) {
|
|
95
112
|
const functionName = toolCall.function.name;
|
|
96
113
|
const functionArgs = toolCall.function.arguments;
|
|
97
|
-
let
|
|
98
|
-
for (const tool of
|
|
114
|
+
let content = null;
|
|
115
|
+
for (const tool of invokableTools !== null && invokableTools !== void 0 ? invokableTools : []) {
|
|
99
116
|
if (tool.name === functionName) {
|
|
100
117
|
const parsedArgs = (0, n8n_workflow_1.jsonParse)(functionArgs);
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
content = await tool.invoke(parsedArgs);
|
|
119
|
+
content = Array.isArray(content) && typeof ((_c = content[0]) === null || _c === void 0 ? void 0 : _c.text) === 'string'
|
|
120
|
+
? content[0].text
|
|
121
|
+
: content;
|
|
103
122
|
}
|
|
104
123
|
}
|
|
105
|
-
if (typeof
|
|
106
|
-
|
|
124
|
+
if (typeof content === 'object') {
|
|
125
|
+
content = JSON.stringify(content);
|
|
107
126
|
}
|
|
108
127
|
messages.push({
|
|
109
128
|
tool_call_id: toolCall.id,
|
|
110
129
|
role: 'tool',
|
|
111
|
-
content:
|
|
130
|
+
content: content,
|
|
112
131
|
});
|
|
113
132
|
}
|
|
114
|
-
response = (await
|
|
133
|
+
response = (await openAiApiRequest_1.openAiApiRequest.call(this, 'POST', `/chat/completions`, {
|
|
115
134
|
body,
|
|
116
135
|
}));
|
|
117
136
|
toolCalls = response.choices[0].message.tool_calls;
|
|
118
137
|
currentIteration += 1;
|
|
119
138
|
}
|
|
120
139
|
const outputData = [];
|
|
121
|
-
if (
|
|
140
|
+
if (agentType == "subAgent" && parentMessageContentStr !== '') {
|
|
122
141
|
outputData.push({
|
|
123
142
|
json: { response: response },
|
|
124
143
|
pairedItem: { item: 0 },
|
|
@@ -135,23 +154,23 @@ async function execute(i, parentMessageContentStr = '', parentMessageContentObj
|
|
|
135
154
|
return choice;
|
|
136
155
|
});
|
|
137
156
|
}
|
|
157
|
+
outputData.push({ json: { output: response.choices[0].message.content }, pairedItem: { item: i } });
|
|
138
158
|
if (addToOutput.includes("fullResponse")) {
|
|
139
|
-
outputData.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
outputData.push({ json: { response: { choices: response.choices } }, pairedItem: { item: i } });
|
|
159
|
+
outputData.forEach(item => {
|
|
160
|
+
item.json.response = response;
|
|
161
|
+
});
|
|
143
162
|
}
|
|
144
163
|
const newMessages = messages.slice(originalMessagesLength);
|
|
145
|
-
if (addToOutput.includes("
|
|
164
|
+
if (addToOutput.includes("tool_calls")) {
|
|
146
165
|
outputData.forEach(item => {
|
|
147
|
-
item.json.
|
|
166
|
+
item.json.tool_calls = (0, processor_1.extractToolMessages)(newMessages);
|
|
148
167
|
});
|
|
149
168
|
}
|
|
150
169
|
if (addToOutput.includes("chatHistory")) {
|
|
151
|
-
const
|
|
170
|
+
const includeToolCallsInChatHistory = this.getNodeParameter('includeToolCallsInChatHistory', i, true);
|
|
152
171
|
const includeSystemMessagesInChatHistory = this.getNodeParameter('includeSystemMessagesInChatHistory', i, true);
|
|
153
172
|
let chatHistoryMessages = structuredClone(messages);
|
|
154
|
-
if (!
|
|
173
|
+
if (!includeToolCallsInChatHistory) {
|
|
155
174
|
chatHistoryMessages = chatHistoryMessages
|
|
156
175
|
.filter(msg => msg.content !== null && msg.role !== 'tool')
|
|
157
176
|
.map(({ role, content }) => ({ role, content }));
|
|
@@ -160,7 +179,7 @@ async function execute(i, parentMessageContentStr = '', parentMessageContentObj
|
|
|
160
179
|
chatHistoryMessages = chatHistoryMessages
|
|
161
180
|
.filter(msg => msg.role !== 'system');
|
|
162
181
|
}
|
|
163
|
-
if ((
|
|
182
|
+
if ((_e = (_d = response === null || response === void 0 ? void 0 : response.choices) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) {
|
|
164
183
|
const rootMessage = {
|
|
165
184
|
role: response.choices[0].message.role,
|
|
166
185
|
content: response.choices[0].message.content,
|
|
@@ -179,14 +198,15 @@ async function execute(i, parentMessageContentStr = '', parentMessageContentObj
|
|
|
179
198
|
outputData.forEach(item => {
|
|
180
199
|
const reordered = {
|
|
181
200
|
request: item.json.request,
|
|
182
|
-
|
|
201
|
+
tool_calls: item.json.tool_calls,
|
|
183
202
|
response: item.json.response,
|
|
203
|
+
output: item.json.output,
|
|
184
204
|
chat_history: item.json.chat_history,
|
|
185
205
|
};
|
|
186
206
|
item.json = Object.fromEntries(Object.entries(reordered).filter(([_, value]) => value !== undefined));
|
|
187
207
|
});
|
|
188
|
-
if (memory && ((
|
|
189
|
-
const lastUserMessageContent = ((
|
|
208
|
+
if (memory && ((_g = (_f = response === null || response === void 0 ? void 0 : response.choices) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.message)) {
|
|
209
|
+
const lastUserMessageContent = ((_h = [...messages].reverse().find(msg => msg.role === 'user')) === null || _h === void 0 ? void 0 : _h.content) || '';
|
|
190
210
|
const lastAssistantMessageContent = response.choices[0].message.content;
|
|
191
211
|
try {
|
|
192
212
|
await memory.saveContext({ input: lastUserMessageContent }, { output: lastAssistantMessageContent });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.operation.js","sourceRoot":"","sources":["../../../../nodes/shared/actions/message.operation.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"message.operation.js","sourceRoot":"","sources":["../../../../nodes/shared/actions/message.operation.ts"],"names":[],"mappings":";;;;;AAmBA,0BAiUC;AA9UD,+CAAyC;AAEzC,uDAAgC;AAChC,4DAAoC;AAEpC,8DAA2D;AAE3D,wCAAkD;AAClD,wEAAqE;AACrE,4CAA0D;AA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CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QAExE,IAAI,CAAC;YACJ,MAAM,MAAM,CAAC,WAAW,CACvB,EAAE,KAAK,EAAE,sBAAsB,EAAE,EACjC,EAAE,MAAM,EAAE,2BAA2B,EAAE,CACvC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.router = router;
|
|
37
37
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
38
38
|
const messageOperation = __importStar(require("./message.operation"));
|
|
39
|
-
const errorHandling_1 = require("../
|
|
39
|
+
const errorHandling_1 = require("../api/errorHandling");
|
|
40
40
|
async function router(parentMessageContentStr = '', parentMessageContentObj = {}) {
|
|
41
41
|
var _a, _b;
|
|
42
42
|
const returnData = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../nodes/shared/actions/router.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../nodes/shared/actions/router.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,wBAsCC;AAhDD,+CAKsB;AAEtB,sEAAuD;AACvD,wDAA6D;AAEtD,KAAK,UAAU,MAAM,CAA0B,0BAAkC,EAAE,EAAE,0BAAkC,EAAE;;IAE/H,MAAM,UAAU,GAAyB,EAAE,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAClC,IAAI,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,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@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.executeAsTool = executeAsTool;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const tools_1 = require("@langchain/core/tools");
|
|
6
|
-
const subagentTool_1 = require("../
|
|
7
|
-
const
|
|
8
|
-
const customFields_1 = require("../
|
|
6
|
+
const subagentTool_1 = require("../tool/subagentTool");
|
|
7
|
+
const schemaGenerator_1 = require("../tool/schemaGenerator");
|
|
8
|
+
const customFields_1 = require("../tool/customFields");
|
|
9
9
|
async function executeAsTool(itemIndex) {
|
|
10
10
|
const name = this.getNodeParameter('name', itemIndex, 'subagent');
|
|
11
11
|
const description = this.getNodeParameter('description', itemIndex, 'Call this to message an AI subagent.');
|
|
12
12
|
const toolHandler = async (input) => {
|
|
13
13
|
const formattedInput = typeof input === 'string' ? { input } : input;
|
|
14
|
-
const { index } = this.addInputData(
|
|
14
|
+
const { index } = this.addInputData(n8n_workflow_1.NodeConnectionTypes.AiTool, [[{ json: formattedInput }]]);
|
|
15
15
|
let response = '';
|
|
16
16
|
let executionError;
|
|
17
17
|
try {
|
|
@@ -32,10 +32,10 @@ async function executeAsTool(itemIndex) {
|
|
|
32
32
|
response = `There was an error: "${executionError.message}"`;
|
|
33
33
|
}
|
|
34
34
|
if (executionError) {
|
|
35
|
-
void this.addOutputData(
|
|
35
|
+
void this.addOutputData(n8n_workflow_1.NodeConnectionTypes.AiTool, index, executionError);
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
|
-
void this.addOutputData(
|
|
38
|
+
void this.addOutputData(n8n_workflow_1.NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);
|
|
39
39
|
}
|
|
40
40
|
return response;
|
|
41
41
|
};
|
|
@@ -57,7 +57,7 @@ async function executeAsTool(itemIndex) {
|
|
|
57
57
|
}
|
|
58
58
|
case 'inputJsonExample': {
|
|
59
59
|
const inputJsonExampleParameters = this.getNodeParameter('inputJsonExampleParameters', itemIndex, '');
|
|
60
|
-
parsedJsonParameters = (0,
|
|
60
|
+
parsedJsonParameters = (0, schemaGenerator_1.generateSchema)(inputJsonExampleParameters);
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
case 'inputJsonSchema': {
|
|
@@ -70,7 +70,7 @@ async function executeAsTool(itemIndex) {
|
|
|
70
70
|
return { response: tool };
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
const zodSchema = (0,
|
|
73
|
+
const zodSchema = (0, schemaGenerator_1.convertJsonSchemaToZod)(parsedJsonParameters);
|
|
74
74
|
tool = new tools_1.DynamicStructuredTool({
|
|
75
75
|
schema: zodSchema,
|
|
76
76
|
...commonToolOptions,
|
|
@@ -84,4 +84,4 @@ async function executeAsTool(itemIndex) {
|
|
|
84
84
|
response: tool,
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
//# sourceMappingURL=
|
|
87
|
+
//# sourceMappingURL=tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../nodes/shared/actions/tool.ts"],"names":[],"mappings":";;AAoBA,sCAqGC;AAzHD,+CASsB;AAEtB,iDAA2E;AAI3E,uDAAoD;AACpD,6DAAiF;AACjF,uDAA8F;AAGvF,KAAK,UAAU,aAAa,CAA6B,SAAiB;IAGhF,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAW,CAAC;IAC5E,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,SAAS,EAAE,sCAAsC,CAAW,CAAC;IAEtH,MAAM,WAAW,GAAG,KAAK,EAAE,KAA2B,EAAmB,EAAE;QACxE,MAAM,cAAc,GAAgB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAGlF,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,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AAC,CAAC;YAEjF,IAAI,GAAG,IAAI,6BAAqB,CAAC;gBAChC,MAAM,EAAE,SAAS;gBACjB,GAAG,iBAAiB;aACpB,CAAC,CAAC;QAEJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,iCAAkB,CAC3B,IAAI,CAAC,OAAO,EAAE,EACd,0CAA0C,GAAG,KAAK,CAClD,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO;QACN,QAAQ,EAAE,IAAI;KACd,CAAC;AACH,CAAC"}
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.openAiFailedAttemptHandler = void 0;
|
|
4
4
|
exports.getCustomErrorMessage = getCustomErrorMessage;
|
|
5
5
|
exports.isOpenAiError = isOpenAiError;
|
|
6
|
-
const
|
|
6
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
7
|
const openai_1 = require("openai");
|
|
8
|
+
const error_1 = require("openai/error");
|
|
8
9
|
const errorMap = {
|
|
9
|
-
insufficient_quota: '
|
|
10
|
+
insufficient_quota: 'Insufficient quota detected. <a href="https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-langchain.openai/common-issues/#insufficient-quota" target="_blank">Learn more</a> about resolving this issue',
|
|
10
11
|
rate_limit_exceeded: 'OpenAI: Rate limit reached',
|
|
11
12
|
};
|
|
12
13
|
function getCustomErrorMessage(errorCode) {
|
|
@@ -16,15 +17,11 @@ function isOpenAiError(error) {
|
|
|
16
17
|
return error instanceof error_1.OpenAIError;
|
|
17
18
|
}
|
|
18
19
|
const openAiFailedAttemptHandler = (error) => {
|
|
20
|
+
var _a;
|
|
19
21
|
if (error instanceof openai_1.RateLimitError) {
|
|
20
22
|
const errorCode = error === null || error === void 0 ? void 0 : error.code;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (customErrorMessage) {
|
|
24
|
-
error.message = customErrorMessage;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
throw error;
|
|
23
|
+
const errorMessage = (_a = getCustomErrorMessage(errorCode !== null && errorCode !== void 0 ? errorCode : 'rate_limit_exceeded')) !== null && _a !== void 0 ? _a : errorMap.rate_limit_exceeded;
|
|
24
|
+
throw new n8n_workflow_1.OperationalError(errorMessage, { cause: error });
|
|
28
25
|
}
|
|
29
26
|
};
|
|
30
27
|
exports.openAiFailedAttemptHandler = openAiFailedAttemptHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHandling.js","sourceRoot":"","sources":["../../../../nodes/shared/api/errorHandling.ts"],"names":[],"mappings":";;;AAWA,sDAEC;AAED,sCAEC;AAhBD,+CAAgD;AAChD,mCAAwC;AACxC,wCAA2C;AAE3C,MAAM,QAAQ,GAA2B;IACxC,kBAAkB,EACjB,kNAAkN;IACnN,mBAAmB,EAAE,4BAA4B;CACjD,CAAC;AAEF,SAAgB,qBAAqB,CAAC,SAAiB;IACtD,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED,SAAgB,aAAa,CAAC,KAAU;IACvC,OAAO,KAAK,YAAY,mBAAW,CAAC;AACrC,CAAC;AAEM,MAAM,0BAA0B,GAAG,CAAC,KAAU,EAAE,EAAE;;IACxD,IAAI,KAAK,YAAY,uBAAc,EAAE,CAAC;QAGrC,MAAM,SAAS,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC;QAC9B,MAAM,YAAY,GACjB,MAAA,qBAAqB,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,qBAAqB,CAAC,mCAAI,QAAQ,CAAC,mBAAmB,CAAC;QAC3F,MAAM,IAAI,+BAAgB,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;AACF,CAAC,CAAC;AATW,QAAA,0BAA0B,8BASrC"}
|
|
@@ -6,5 +6,5 @@ type RequestParameters = {
|
|
|
6
6
|
uri?: string;
|
|
7
7
|
option?: IDataObject;
|
|
8
8
|
};
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function openAiApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, endpoint: string, parameters?: RequestParameters): Promise<any>;
|
|
10
10
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
async function
|
|
3
|
+
exports.openAiApiRequest = openAiApiRequest;
|
|
4
|
+
async function openAiApiRequest(method, endpoint, parameters) {
|
|
5
5
|
const { body, qs, uri, option, headers } = parameters !== null && parameters !== void 0 ? parameters : {};
|
|
6
6
|
const credentials = await this.getCredentials('simpleOpenAiApi');
|
|
7
7
|
const baseUrl = String(credentials.baseUrl || 'https://api.openai.com/v1');
|
|
@@ -20,4 +20,4 @@ async function apiRequest(method, endpoint, parameters) {
|
|
|
20
20
|
}
|
|
21
21
|
return await this.helpers.requestWithAuthentication.call(this, 'simpleOpenAiApi', options);
|
|
22
22
|
}
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=openAiApiRequest.js.map
|