@n8n/n8n-nodes-langchain 1.92.2 → 1.94.0
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/AzureEntraCognitiveServicesOAuth2Api.credentials.js +5 -22
- package/dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js.map +1 -1
- package/dist/credentials/AzureOpenAiApi.credentials.js +1 -1
- package/dist/credentials/AzureOpenAiApi.credentials.js.map +1 -1
- package/dist/credentials/XAiApi.credentials.js +1 -1
- package/dist/credentials/XAiApi.credentials.js.map +1 -1
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/ToolExecutor/ToolExecutor.node.js +105 -0
- package/dist/nodes/ToolExecutor/ToolExecutor.node.js.map +1 -0
- package/dist/nodes/ToolExecutor/ToolExecutor.node.json +17 -0
- package/dist/nodes/ToolExecutor/utils/convertToSchema.js +64 -0
- package/dist/nodes/ToolExecutor/utils/convertToSchema.js.map +1 -0
- package/dist/nodes/ToolExecutor/utils/executeTool.js +39 -0
- package/dist/nodes/ToolExecutor/utils/executeTool.js.map +1 -0
- package/dist/nodes/agents/Agent/Agent.node.js +19 -394
- package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js +427 -0
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -0
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js +162 -0
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/{description.js → V1/description.js} +2 -34
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V1/description.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V1/execute.js +119 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V1/execute.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js +40 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js +139 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/{execute.js → common.js} +7 -97
- package/dist/nodes/agents/Agent/agents/ToolsAgent/common.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/options.js +62 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/options.js.map +1 -0
- package/dist/nodes/chains/ChainLLM/ChainLlm.node.js +69 -51
- package/dist/nodes/chains/ChainLLM/ChainLlm.node.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js +8 -0
- package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/methods/config.js +5 -0
- package/dist/nodes/chains/ChainLLM/methods/config.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/methods/processItem.js +66 -0
- package/dist/nodes/chains/ChainLLM/methods/processItem.js.map +1 -0
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +71 -95
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
- package/dist/nodes/chains/ChainRetrievalQA/constants.js +49 -0
- package/dist/nodes/chains/ChainRetrievalQA/constants.js.map +1 -0
- package/dist/nodes/chains/ChainRetrievalQA/processItem.js +91 -0
- package/dist/nodes/chains/ChainRetrievalQA/processItem.js.map +1 -0
- package/dist/nodes/chains/ChainSummarization/ChainSummarization.node.js +3 -2
- package/dist/nodes/chains/ChainSummarization/ChainSummarization.node.js.map +1 -1
- package/dist/nodes/chains/ChainSummarization/V2/ChainSummarizationV2.node.js +55 -78
- package/dist/nodes/chains/ChainSummarization/V2/ChainSummarizationV2.node.js.map +1 -1
- package/dist/nodes/chains/ChainSummarization/V2/processItem.js +95 -0
- package/dist/nodes/chains/ChainSummarization/V2/processItem.js.map +1 -0
- package/dist/nodes/chains/InformationExtractor/InformationExtractor.node.js +56 -33
- package/dist/nodes/chains/InformationExtractor/InformationExtractor.node.js.map +1 -1
- package/dist/nodes/chains/InformationExtractor/constants.js +31 -0
- package/dist/nodes/chains/InformationExtractor/constants.js.map +1 -0
- package/dist/nodes/chains/InformationExtractor/processItem.js +50 -0
- package/dist/nodes/chains/InformationExtractor/processItem.js.map +1 -0
- package/dist/nodes/chains/SentimentAnalysis/SentimentAnalysis.node.js +198 -71
- package/dist/nodes/chains/SentimentAnalysis/SentimentAnalysis.node.js.map +1 -1
- package/dist/nodes/chains/TextClassifier/TextClassifier.node.js +83 -54
- package/dist/nodes/chains/TextClassifier/TextClassifier.node.js.map +1 -1
- package/dist/nodes/chains/TextClassifier/constants.js +29 -0
- package/dist/nodes/chains/TextClassifier/constants.js.map +1 -0
- package/dist/nodes/chains/TextClassifier/processItem.js +65 -0
- package/dist/nodes/chains/TextClassifier/processItem.js.map +1 -0
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js +5 -1
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +4 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +6 -1
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
- package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js +4 -1
- package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js +4 -0
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js.map +1 -1
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +4 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatAzureOpenAi/credentials/N8nOAuth2TokenCredential.js +16 -2
- package/dist/nodes/llms/LmChatAzureOpenAi/credentials/N8nOAuth2TokenCredential.js.map +1 -1
- package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js +3 -1
- package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js.map +1 -1
- package/dist/nodes/llms/LmChatGroq/LmChatGroq.node.js +2 -0
- package/dist/nodes/llms/LmChatGroq/LmChatGroq.node.js.map +1 -1
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js +3 -1
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js.map +1 -1
- package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js +3 -1
- package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/loadOptions.js +2 -1
- package/dist/nodes/mcp/McpClientTool/loadOptions.js.map +1 -1
- package/dist/nodes/mcp/McpTrigger/McpServer.js +72 -48
- package/dist/nodes/mcp/McpTrigger/McpServer.js.map +1 -1
- package/dist/nodes/mcp/McpTrigger/McpTrigger.node.js +2 -2
- package/dist/nodes/mcp/McpTrigger/McpTrigger.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.js +1 -0
- package/dist/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js +2 -1
- package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreMilvus/milvus-icon-white.svg +1 -1
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js +6 -1
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js.map +1 -1
- package/dist/types/credentials.json +3 -3
- package/dist/types/nodes.json +13 -11
- package/dist/utils/helpers.js +1 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/httpProxyAgent.js +33 -0
- package/dist/utils/httpProxyAgent.js.map +1 -0
- package/dist/utils/sharedFields.js +29 -0
- package/dist/utils/sharedFields.js.map +1 -1
- package/package.json +13 -11
- package/dist/nodes/agents/Agent/agents/ToolsAgent/description.js.map +0 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js.map +0 -1
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var AgentV1_node_exports = {};
|
|
20
|
+
__export(AgentV1_node_exports, {
|
|
21
|
+
AgentV1: () => AgentV1
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(AgentV1_node_exports);
|
|
24
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
25
|
+
var import_descriptions = require("../../../../utils/descriptions");
|
|
26
|
+
var import_description = require("../agents/ConversationalAgent/description");
|
|
27
|
+
var import_execute = require("../agents/ConversationalAgent/execute");
|
|
28
|
+
var import_description2 = require("../agents/OpenAiFunctionsAgent/description");
|
|
29
|
+
var import_execute2 = require("../agents/OpenAiFunctionsAgent/execute");
|
|
30
|
+
var import_description3 = require("../agents/PlanAndExecuteAgent/description");
|
|
31
|
+
var import_execute3 = require("../agents/PlanAndExecuteAgent/execute");
|
|
32
|
+
var import_description4 = require("../agents/ReActAgent/description");
|
|
33
|
+
var import_execute4 = require("../agents/ReActAgent/execute");
|
|
34
|
+
var import_description5 = require("../agents/SqlAgent/description");
|
|
35
|
+
var import_execute5 = require("../agents/SqlAgent/execute");
|
|
36
|
+
var import_description6 = require("../agents/ToolsAgent/V1/description");
|
|
37
|
+
var import_execute6 = require("../agents/ToolsAgent/V1/execute");
|
|
38
|
+
function getInputs(agent, hasOutputParser) {
|
|
39
|
+
const getInputData = (inputs) => {
|
|
40
|
+
const displayNames = {
|
|
41
|
+
ai_languageModel: "Model",
|
|
42
|
+
ai_memory: "Memory",
|
|
43
|
+
ai_tool: "Tool",
|
|
44
|
+
ai_outputParser: "Output Parser"
|
|
45
|
+
};
|
|
46
|
+
return inputs.map(({ type, filter }) => {
|
|
47
|
+
const isModelType = type === "ai_languageModel";
|
|
48
|
+
let displayName = type in displayNames ? displayNames[type] : void 0;
|
|
49
|
+
if (isModelType && ["openAiFunctionsAgent", "toolsAgent", "conversationalAgent"].includes(agent)) {
|
|
50
|
+
displayName = "Chat Model";
|
|
51
|
+
}
|
|
52
|
+
const input = {
|
|
53
|
+
type,
|
|
54
|
+
displayName,
|
|
55
|
+
required: isModelType,
|
|
56
|
+
maxConnections: ["ai_languageModel", "ai_memory", "ai_outputParser"].includes(
|
|
57
|
+
type
|
|
58
|
+
) ? 1 : void 0
|
|
59
|
+
};
|
|
60
|
+
if (filter) {
|
|
61
|
+
input.filter = filter;
|
|
62
|
+
}
|
|
63
|
+
return input;
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
let specialInputs = [];
|
|
67
|
+
if (agent === "conversationalAgent") {
|
|
68
|
+
specialInputs = [
|
|
69
|
+
{
|
|
70
|
+
type: "ai_languageModel",
|
|
71
|
+
filter: {
|
|
72
|
+
nodes: [
|
|
73
|
+
"@n8n/n8n-nodes-langchain.lmChatAnthropic",
|
|
74
|
+
"@n8n/n8n-nodes-langchain.lmChatAwsBedrock",
|
|
75
|
+
"@n8n/n8n-nodes-langchain.lmChatGroq",
|
|
76
|
+
"@n8n/n8n-nodes-langchain.lmChatOllama",
|
|
77
|
+
"@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
|
78
|
+
"@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
|
|
79
|
+
"@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
|
|
80
|
+
"@n8n/n8n-nodes-langchain.lmChatMistralCloud",
|
|
81
|
+
"@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
|
|
82
|
+
"@n8n/n8n-nodes-langchain.lmChatDeepSeek",
|
|
83
|
+
"@n8n/n8n-nodes-langchain.lmChatOpenRouter",
|
|
84
|
+
"@n8n/n8n-nodes-langchain.lmChatXAiGrok"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: "ai_memory"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: "ai_tool"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "ai_outputParser"
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
} else if (agent === "toolsAgent") {
|
|
99
|
+
specialInputs = [
|
|
100
|
+
{
|
|
101
|
+
type: "ai_languageModel",
|
|
102
|
+
filter: {
|
|
103
|
+
nodes: [
|
|
104
|
+
"@n8n/n8n-nodes-langchain.lmChatAnthropic",
|
|
105
|
+
"@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
|
|
106
|
+
"@n8n/n8n-nodes-langchain.lmChatAwsBedrock",
|
|
107
|
+
"@n8n/n8n-nodes-langchain.lmChatMistralCloud",
|
|
108
|
+
"@n8n/n8n-nodes-langchain.lmChatOllama",
|
|
109
|
+
"@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
|
110
|
+
"@n8n/n8n-nodes-langchain.lmChatGroq",
|
|
111
|
+
"@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
|
|
112
|
+
"@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
|
|
113
|
+
"@n8n/n8n-nodes-langchain.lmChatDeepSeek",
|
|
114
|
+
"@n8n/n8n-nodes-langchain.lmChatOpenRouter",
|
|
115
|
+
"@n8n/n8n-nodes-langchain.lmChatXAiGrok"
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: "ai_memory"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: "ai_tool",
|
|
124
|
+
required: true
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: "ai_outputParser"
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
} else if (agent === "openAiFunctionsAgent") {
|
|
131
|
+
specialInputs = [
|
|
132
|
+
{
|
|
133
|
+
type: "ai_languageModel",
|
|
134
|
+
filter: {
|
|
135
|
+
nodes: [
|
|
136
|
+
"@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
|
137
|
+
"@n8n/n8n-nodes-langchain.lmChatAzureOpenAi"
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: "ai_memory"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
type: "ai_tool",
|
|
146
|
+
required: true
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: "ai_outputParser"
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
} else if (agent === "reActAgent") {
|
|
153
|
+
specialInputs = [
|
|
154
|
+
{
|
|
155
|
+
type: "ai_languageModel"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: "ai_tool"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: "ai_outputParser"
|
|
162
|
+
}
|
|
163
|
+
];
|
|
164
|
+
} else if (agent === "sqlAgent") {
|
|
165
|
+
specialInputs = [
|
|
166
|
+
{
|
|
167
|
+
type: "ai_languageModel"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type: "ai_memory"
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
} else if (agent === "planAndExecuteAgent") {
|
|
174
|
+
specialInputs = [
|
|
175
|
+
{
|
|
176
|
+
type: "ai_languageModel"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
type: "ai_tool"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
type: "ai_outputParser"
|
|
183
|
+
}
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
if (hasOutputParser === false) {
|
|
187
|
+
specialInputs = specialInputs.filter((input) => input.type !== "ai_outputParser");
|
|
188
|
+
}
|
|
189
|
+
return ["main", ...getInputData(specialInputs)];
|
|
190
|
+
}
|
|
191
|
+
const agentTypeProperty = {
|
|
192
|
+
displayName: "Agent",
|
|
193
|
+
name: "agent",
|
|
194
|
+
type: "options",
|
|
195
|
+
noDataExpression: true,
|
|
196
|
+
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
|
197
|
+
options: [
|
|
198
|
+
{
|
|
199
|
+
name: "Tools Agent",
|
|
200
|
+
value: "toolsAgent",
|
|
201
|
+
description: "Utilizes structured tool schemas for precise and reliable tool selection and execution. Recommended for complex tasks requiring accurate and consistent tool usage, but only usable with models that support tool calling."
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "Conversational Agent",
|
|
205
|
+
value: "conversationalAgent",
|
|
206
|
+
description: "Describes tools in the system prompt and parses JSON responses for tool calls. More flexible but potentially less reliable than the Tools Agent. Suitable for simpler interactions or with models not supporting structured schemas."
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "OpenAI Functions Agent",
|
|
210
|
+
value: "openAiFunctionsAgent",
|
|
211
|
+
description: "Leverages OpenAI's function calling capabilities to precisely select and execute tools. Excellent for tasks requiring structured outputs when working with OpenAI models."
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "Plan and Execute Agent",
|
|
215
|
+
value: "planAndExecuteAgent",
|
|
216
|
+
description: "Creates a high-level plan for complex tasks and then executes each step. Suitable for multi-stage problems or when a strategic approach is needed."
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "ReAct Agent",
|
|
220
|
+
value: "reActAgent",
|
|
221
|
+
description: "Combines reasoning and action in an iterative process. Effective for tasks that require careful analysis and step-by-step problem-solving."
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "SQL Agent",
|
|
225
|
+
value: "sqlAgent",
|
|
226
|
+
description: "Specializes in interacting with SQL databases. Ideal for data analysis tasks, generating queries, or extracting insights from structured data."
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
default: ""
|
|
230
|
+
};
|
|
231
|
+
class AgentV1 {
|
|
232
|
+
constructor(baseDescription) {
|
|
233
|
+
this.description = {
|
|
234
|
+
version: [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9],
|
|
235
|
+
...baseDescription,
|
|
236
|
+
defaults: {
|
|
237
|
+
name: "AI Agent",
|
|
238
|
+
color: "#404040"
|
|
239
|
+
},
|
|
240
|
+
inputs: `={{
|
|
241
|
+
((agent, hasOutputParser) => {
|
|
242
|
+
${getInputs.toString()};
|
|
243
|
+
return getInputs(agent, hasOutputParser)
|
|
244
|
+
})($parameter.agent, $parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true)
|
|
245
|
+
}}`,
|
|
246
|
+
outputs: [import_n8n_workflow.NodeConnectionTypes.Main],
|
|
247
|
+
credentials: [
|
|
248
|
+
{
|
|
249
|
+
// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed
|
|
250
|
+
name: "mySql",
|
|
251
|
+
required: true,
|
|
252
|
+
testedBy: "mysqlConnectionTest",
|
|
253
|
+
displayOptions: {
|
|
254
|
+
show: {
|
|
255
|
+
agent: ["sqlAgent"],
|
|
256
|
+
"/dataSource": ["mysql"]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "postgres",
|
|
262
|
+
required: true,
|
|
263
|
+
displayOptions: {
|
|
264
|
+
show: {
|
|
265
|
+
agent: ["sqlAgent"],
|
|
266
|
+
"/dataSource": ["postgres"]
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
properties: [
|
|
272
|
+
{
|
|
273
|
+
displayName: 'Tip: Get a feel for agents with our quick <a href="https://docs.n8n.io/advanced-ai/intro-tutorial/" target="_blank">tutorial</a> or see an <a href="/templates/1954" target="_blank">example</a> of how this node works',
|
|
274
|
+
name: "notice_tip",
|
|
275
|
+
type: "notice",
|
|
276
|
+
default: "",
|
|
277
|
+
displayOptions: {
|
|
278
|
+
show: {
|
|
279
|
+
agent: ["conversationalAgent", "toolsAgent"]
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
displayName: "This node is using Agent that has been deprecated. Please switch to using 'Tools Agent' instead.",
|
|
285
|
+
name: "deprecated",
|
|
286
|
+
type: "notice",
|
|
287
|
+
default: "",
|
|
288
|
+
displayOptions: {
|
|
289
|
+
show: {
|
|
290
|
+
agent: [
|
|
291
|
+
"conversationalAgent",
|
|
292
|
+
"openAiFunctionsAgent",
|
|
293
|
+
"planAndExecuteAgent",
|
|
294
|
+
"reActAgent",
|
|
295
|
+
"sqlAgent"
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
// Make Conversational Agent the default agent for versions 1.5 and below
|
|
301
|
+
{
|
|
302
|
+
...agentTypeProperty,
|
|
303
|
+
options: agentTypeProperty?.options?.filter(
|
|
304
|
+
(o) => "value" in o && o.value !== "toolsAgent"
|
|
305
|
+
),
|
|
306
|
+
displayOptions: { show: { "@version": [{ _cnd: { lte: 1.5 } }] } },
|
|
307
|
+
default: "conversationalAgent"
|
|
308
|
+
},
|
|
309
|
+
// Make Tools Agent the default agent for versions 1.6 and 1.7
|
|
310
|
+
{
|
|
311
|
+
...agentTypeProperty,
|
|
312
|
+
displayOptions: { show: { "@version": [{ _cnd: { between: { from: 1.6, to: 1.7 } } }] } },
|
|
313
|
+
default: "toolsAgent"
|
|
314
|
+
},
|
|
315
|
+
// Make Tools Agent the only agent option for versions 1.8 and above
|
|
316
|
+
{
|
|
317
|
+
...agentTypeProperty,
|
|
318
|
+
type: "hidden",
|
|
319
|
+
displayOptions: { show: { "@version": [{ _cnd: { gte: 1.8 } }] } },
|
|
320
|
+
default: "toolsAgent"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
...import_descriptions.promptTypeOptions,
|
|
324
|
+
displayOptions: {
|
|
325
|
+
hide: {
|
|
326
|
+
"@version": [{ _cnd: { lte: 1.2 } }],
|
|
327
|
+
agent: ["sqlAgent"]
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
...import_descriptions.textFromPreviousNode,
|
|
333
|
+
displayOptions: {
|
|
334
|
+
show: { promptType: ["auto"], "@version": [{ _cnd: { gte: 1.7 } }] },
|
|
335
|
+
// SQL Agent has data source and credentials parameters so we need to include this input there manually
|
|
336
|
+
// to preserve the order
|
|
337
|
+
hide: {
|
|
338
|
+
agent: ["sqlAgent"]
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
...import_descriptions.textInput,
|
|
344
|
+
displayOptions: {
|
|
345
|
+
show: {
|
|
346
|
+
promptType: ["define"]
|
|
347
|
+
},
|
|
348
|
+
hide: {
|
|
349
|
+
agent: ["sqlAgent"]
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
displayName: "For more reliable structured output parsing, consider using the Tools agent",
|
|
355
|
+
name: "notice",
|
|
356
|
+
type: "notice",
|
|
357
|
+
default: "",
|
|
358
|
+
displayOptions: {
|
|
359
|
+
show: {
|
|
360
|
+
hasOutputParser: [true],
|
|
361
|
+
agent: [
|
|
362
|
+
"conversationalAgent",
|
|
363
|
+
"reActAgent",
|
|
364
|
+
"planAndExecuteAgent",
|
|
365
|
+
"openAiFunctionsAgent"
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
displayName: "Require Specific Output Format",
|
|
372
|
+
name: "hasOutputParser",
|
|
373
|
+
type: "boolean",
|
|
374
|
+
default: false,
|
|
375
|
+
noDataExpression: true,
|
|
376
|
+
displayOptions: {
|
|
377
|
+
hide: {
|
|
378
|
+
"@version": [{ _cnd: { lte: 1.2 } }],
|
|
379
|
+
agent: ["sqlAgent"]
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${import_n8n_workflow.NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,
|
|
385
|
+
name: "notice",
|
|
386
|
+
type: "notice",
|
|
387
|
+
default: "",
|
|
388
|
+
displayOptions: {
|
|
389
|
+
show: {
|
|
390
|
+
hasOutputParser: [true],
|
|
391
|
+
agent: ["toolsAgent"]
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
...import_description6.toolsAgentProperties,
|
|
396
|
+
...import_description.conversationalAgentProperties,
|
|
397
|
+
...import_description2.openAiFunctionsAgentProperties,
|
|
398
|
+
...import_description4.reActAgentAgentProperties,
|
|
399
|
+
...import_description5.sqlAgentAgentProperties,
|
|
400
|
+
...import_description3.planAndExecuteAgentProperties
|
|
401
|
+
]
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
async execute() {
|
|
405
|
+
const agentType = this.getNodeParameter("agent", 0, "");
|
|
406
|
+
const nodeVersion = this.getNode().typeVersion;
|
|
407
|
+
if (agentType === "conversationalAgent") {
|
|
408
|
+
return await import_execute.conversationalAgentExecute.call(this, nodeVersion);
|
|
409
|
+
} else if (agentType === "toolsAgent") {
|
|
410
|
+
return await import_execute6.toolsAgentExecute.call(this);
|
|
411
|
+
} else if (agentType === "openAiFunctionsAgent") {
|
|
412
|
+
return await import_execute2.openAiFunctionsAgentExecute.call(this, nodeVersion);
|
|
413
|
+
} else if (agentType === "reActAgent") {
|
|
414
|
+
return await import_execute4.reActAgentAgentExecute.call(this, nodeVersion);
|
|
415
|
+
} else if (agentType === "sqlAgent") {
|
|
416
|
+
return await import_execute5.sqlAgentAgentExecute.call(this);
|
|
417
|
+
} else if (agentType === "planAndExecuteAgent") {
|
|
418
|
+
return await import_execute3.planAndExecuteAgentExecute.call(this, nodeVersion);
|
|
419
|
+
}
|
|
420
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), `The agent type "${agentType}" is not supported`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
424
|
+
0 && (module.exports = {
|
|
425
|
+
AgentV1
|
|
426
|
+
});
|
|
427
|
+
//# sourceMappingURL=AgentV1.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/agents/Agent/V1/AgentV1.node.ts"],"sourcesContent":["import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tINodeInputConfiguration,\n\tINodeInputFilter,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tINodeProperties,\n\tNodeConnectionType,\n\tINodeTypeBaseDescription,\n} from 'n8n-workflow';\n\nimport { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';\n\nimport { conversationalAgentProperties } from '../agents/ConversationalAgent/description';\nimport { conversationalAgentExecute } from '../agents/ConversationalAgent/execute';\nimport { openAiFunctionsAgentProperties } from '../agents/OpenAiFunctionsAgent/description';\nimport { openAiFunctionsAgentExecute } from '../agents/OpenAiFunctionsAgent/execute';\nimport { planAndExecuteAgentProperties } from '../agents/PlanAndExecuteAgent/description';\nimport { planAndExecuteAgentExecute } from '../agents/PlanAndExecuteAgent/execute';\nimport { reActAgentAgentProperties } from '../agents/ReActAgent/description';\nimport { reActAgentAgentExecute } from '../agents/ReActAgent/execute';\nimport { sqlAgentAgentProperties } from '../agents/SqlAgent/description';\nimport { sqlAgentAgentExecute } from '../agents/SqlAgent/execute';\nimport { toolsAgentProperties } from '../agents/ToolsAgent/V1/description';\nimport { toolsAgentExecute } from '../agents/ToolsAgent/V1/execute';\n\n// Function used in the inputs expression to figure out which inputs to\n// display based on the agent type\nfunction getInputs(\n\tagent:\n\t\t| 'toolsAgent'\n\t\t| 'conversationalAgent'\n\t\t| 'openAiFunctionsAgent'\n\t\t| 'planAndExecuteAgent'\n\t\t| 'reActAgent'\n\t\t| 'sqlAgent',\n\thasOutputParser?: boolean,\n): Array<NodeConnectionType | INodeInputConfiguration> {\n\tinterface SpecialInput {\n\t\ttype: NodeConnectionType;\n\t\tfilter?: INodeInputFilter;\n\t\trequired?: boolean;\n\t}\n\n\tconst getInputData = (\n\t\tinputs: SpecialInput[],\n\t): Array<NodeConnectionType | INodeInputConfiguration> => {\n\t\tconst displayNames: { [key: string]: string } = {\n\t\t\tai_languageModel: 'Model',\n\t\t\tai_memory: 'Memory',\n\t\t\tai_tool: 'Tool',\n\t\t\tai_outputParser: 'Output Parser',\n\t\t};\n\n\t\treturn inputs.map(({ type, filter }) => {\n\t\t\tconst isModelType = type === ('ai_languageModel' as NodeConnectionType);\n\t\t\tlet displayName = type in displayNames ? displayNames[type] : undefined;\n\t\t\tif (\n\t\t\t\tisModelType &&\n\t\t\t\t['openAiFunctionsAgent', 'toolsAgent', 'conversationalAgent'].includes(agent)\n\t\t\t) {\n\t\t\t\tdisplayName = 'Chat Model';\n\t\t\t}\n\t\t\tconst input: INodeInputConfiguration = {\n\t\t\t\ttype,\n\t\t\t\tdisplayName,\n\t\t\t\trequired: isModelType,\n\t\t\t\tmaxConnections: ['ai_languageModel', 'ai_memory', 'ai_outputParser'].includes(\n\t\t\t\t\ttype as NodeConnectionType,\n\t\t\t\t)\n\t\t\t\t\t? 1\n\t\t\t\t\t: undefined,\n\t\t\t};\n\n\t\t\tif (filter) {\n\t\t\t\tinput.filter = filter;\n\t\t\t}\n\n\t\t\treturn input;\n\t\t});\n\t};\n\n\tlet specialInputs: SpecialInput[] = [];\n\n\tif (agent === 'conversationalAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAnthropic',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAwsBedrock',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGroq',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOllama',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleGemini',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleVertex',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatMistralCloud',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatDeepSeek',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenRouter',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatXAiGrok',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'toolsAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAnthropic',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAwsBedrock',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatMistralCloud',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOllama',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGroq',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleVertex',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleGemini',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatDeepSeek',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenRouter',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatXAiGrok',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'openAiFunctionsAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'reActAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'sqlAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'planAndExecuteAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t}\n\n\tif (hasOutputParser === false) {\n\t\tspecialInputs = specialInputs.filter((input) => input.type !== 'ai_outputParser');\n\t}\n\treturn ['main', ...getInputData(specialInputs)];\n}\n\nconst agentTypeProperty: INodeProperties = {\n\tdisplayName: 'Agent',\n\tname: 'agent',\n\ttype: 'options',\n\tnoDataExpression: true,\n\t// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items\n\toptions: [\n\t\t{\n\t\t\tname: 'Tools Agent',\n\t\t\tvalue: 'toolsAgent',\n\t\t\tdescription:\n\t\t\t\t'Utilizes structured tool schemas for precise and reliable tool selection and execution. Recommended for complex tasks requiring accurate and consistent tool usage, but only usable with models that support tool calling.',\n\t\t},\n\t\t{\n\t\t\tname: 'Conversational Agent',\n\t\t\tvalue: 'conversationalAgent',\n\t\t\tdescription:\n\t\t\t\t'Describes tools in the system prompt and parses JSON responses for tool calls. More flexible but potentially less reliable than the Tools Agent. Suitable for simpler interactions or with models not supporting structured schemas.',\n\t\t},\n\t\t{\n\t\t\tname: 'OpenAI Functions Agent',\n\t\t\tvalue: 'openAiFunctionsAgent',\n\t\t\tdescription:\n\t\t\t\t\"Leverages OpenAI's function calling capabilities to precisely select and execute tools. Excellent for tasks requiring structured outputs when working with OpenAI models.\",\n\t\t},\n\t\t{\n\t\t\tname: 'Plan and Execute Agent',\n\t\t\tvalue: 'planAndExecuteAgent',\n\t\t\tdescription:\n\t\t\t\t'Creates a high-level plan for complex tasks and then executes each step. Suitable for multi-stage problems or when a strategic approach is needed.',\n\t\t},\n\t\t{\n\t\t\tname: 'ReAct Agent',\n\t\t\tvalue: 'reActAgent',\n\t\t\tdescription:\n\t\t\t\t'Combines reasoning and action in an iterative process. Effective for tasks that require careful analysis and step-by-step problem-solving.',\n\t\t},\n\t\t{\n\t\t\tname: 'SQL Agent',\n\t\t\tvalue: 'sqlAgent',\n\t\t\tdescription:\n\t\t\t\t'Specializes in interacting with SQL databases. Ideal for data analysis tasks, generating queries, or extracting insights from structured data.',\n\t\t},\n\t],\n\tdefault: '',\n};\n\nexport class AgentV1 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\tversion: [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9],\n\t\t\t...baseDescription,\n\t\t\tdefaults: {\n\t\t\t\tname: 'AI Agent',\n\t\t\t\tcolor: '#404040',\n\t\t\t},\n\t\t\tinputs: `={{\n\t\t\t\t((agent, hasOutputParser) => {\n\t\t\t\t\t${getInputs.toString()};\n\t\t\t\t\treturn getInputs(agent, hasOutputParser)\n\t\t\t\t})($parameter.agent, $parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true)\n\t\t\t}}`,\n\t\t\toutputs: [NodeConnectionTypes.Main],\n\t\t\tcredentials: [\n\t\t\t\t{\n\t\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed\n\t\t\t\t\tname: 'mySql',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttestedBy: 'mysqlConnectionTest',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t\t'/dataSource': ['mysql'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'postgres',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t\t'/dataSource': ['postgres'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'Tip: Get a feel for agents with our quick <a href=\"https://docs.n8n.io/advanced-ai/intro-tutorial/\" target=\"_blank\">tutorial</a> or see an <a href=\"/templates/1954\" target=\"_blank\">example</a> of how this node works',\n\t\t\t\t\tname: 'notice_tip',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['conversationalAgent', 'toolsAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t\"This node is using Agent that has been deprecated. Please switch to using 'Tools Agent' instead.\",\n\t\t\t\t\tname: 'deprecated',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: [\n\t\t\t\t\t\t\t\t'conversationalAgent',\n\t\t\t\t\t\t\t\t'openAiFunctionsAgent',\n\t\t\t\t\t\t\t\t'planAndExecuteAgent',\n\t\t\t\t\t\t\t\t'reActAgent',\n\t\t\t\t\t\t\t\t'sqlAgent',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Make Conversational Agent the default agent for versions 1.5 and below\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\toptions: agentTypeProperty?.options?.filter(\n\t\t\t\t\t\t(o) => 'value' in o && o.value !== 'toolsAgent',\n\t\t\t\t\t),\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { lte: 1.5 } }] } },\n\t\t\t\t\tdefault: 'conversationalAgent',\n\t\t\t\t},\n\t\t\t\t// Make Tools Agent the default agent for versions 1.6 and 1.7\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { between: { from: 1.6, to: 1.7 } } }] } },\n\t\t\t\t\tdefault: 'toolsAgent',\n\t\t\t\t},\n\t\t\t\t// Make Tools Agent the only agent option for versions 1.8 and above\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\ttype: 'hidden',\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { gte: 1.8 } }] } },\n\t\t\t\t\tdefault: 'toolsAgent',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...promptTypeOptions,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textFromPreviousNode,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: { promptType: ['auto'], '@version': [{ _cnd: { gte: 1.7 } }] },\n\t\t\t\t\t\t// SQL Agent has data source and credentials parameters so we need to include this input there manually\n\t\t\t\t\t\t// to preserve the order\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textInput,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['define'],\n\t\t\t\t\t\t},\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'For more reliable structured output parsing, consider using the Tools agent',\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t\tagent: [\n\t\t\t\t\t\t\t\t'conversationalAgent',\n\t\t\t\t\t\t\t\t'reActAgent',\n\t\t\t\t\t\t\t\t'planAndExecuteAgent',\n\t\t\t\t\t\t\t\t'openAiFunctionsAgent',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Require Specific Output Format',\n\t\t\t\t\tname: 'hasOutputParser',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t\tagent: ['toolsAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\n\t\t\t\t...toolsAgentProperties,\n\t\t\t\t...conversationalAgentProperties,\n\t\t\t\t...openAiFunctionsAgentProperties,\n\t\t\t\t...reActAgentAgentProperties,\n\t\t\t\t...sqlAgentAgentProperties,\n\t\t\t\t...planAndExecuteAgentProperties,\n\t\t\t],\n\t\t};\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst agentType = this.getNodeParameter('agent', 0, '') as string;\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tif (agentType === 'conversationalAgent') {\n\t\t\treturn await conversationalAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'toolsAgent') {\n\t\t\treturn await toolsAgentExecute.call(this);\n\t\t} else if (agentType === 'openAiFunctionsAgent') {\n\t\t\treturn await openAiFunctionsAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'reActAgent') {\n\t\t\treturn await reActAgentAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'sqlAgent') {\n\t\t\treturn await sqlAgentAgentExecute.call(this);\n\t\t} else if (agentType === 'planAndExecuteAgent') {\n\t\t\treturn await planAndExecuteAgentExecute.call(this, nodeVersion);\n\t\t}\n\n\t\tthrow new NodeOperationError(this.getNode(), `The agent type \"${agentType}\" is not supported`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;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ty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var AgentV2_node_exports = {};
|
|
20
|
+
__export(AgentV2_node_exports, {
|
|
21
|
+
AgentV2: () => AgentV2
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(AgentV2_node_exports);
|
|
24
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
25
|
+
var import_descriptions = require("../../../../utils/descriptions");
|
|
26
|
+
var import_description = require("../agents/ToolsAgent/V2/description");
|
|
27
|
+
var import_execute = require("../agents/ToolsAgent/V2/execute");
|
|
28
|
+
function getInputs(hasOutputParser) {
|
|
29
|
+
const getInputData = (inputs) => {
|
|
30
|
+
const displayNames = {
|
|
31
|
+
ai_languageModel: "Model",
|
|
32
|
+
ai_memory: "Memory",
|
|
33
|
+
ai_tool: "Tool",
|
|
34
|
+
ai_outputParser: "Output Parser"
|
|
35
|
+
};
|
|
36
|
+
return inputs.map(({ type, filter }) => {
|
|
37
|
+
const isModelType = type === "ai_languageModel";
|
|
38
|
+
let displayName = type in displayNames ? displayNames[type] : void 0;
|
|
39
|
+
if (isModelType) {
|
|
40
|
+
displayName = "Chat Model";
|
|
41
|
+
}
|
|
42
|
+
const input = {
|
|
43
|
+
type,
|
|
44
|
+
displayName,
|
|
45
|
+
required: isModelType,
|
|
46
|
+
maxConnections: ["ai_languageModel", "ai_memory", "ai_outputParser"].includes(
|
|
47
|
+
type
|
|
48
|
+
) ? 1 : void 0
|
|
49
|
+
};
|
|
50
|
+
if (filter) {
|
|
51
|
+
input.filter = filter;
|
|
52
|
+
}
|
|
53
|
+
return input;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
let specialInputs = [
|
|
57
|
+
{
|
|
58
|
+
type: "ai_languageModel",
|
|
59
|
+
filter: {
|
|
60
|
+
nodes: [
|
|
61
|
+
"@n8n/n8n-nodes-langchain.lmChatAnthropic",
|
|
62
|
+
"@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
|
|
63
|
+
"@n8n/n8n-nodes-langchain.lmChatAwsBedrock",
|
|
64
|
+
"@n8n/n8n-nodes-langchain.lmChatMistralCloud",
|
|
65
|
+
"@n8n/n8n-nodes-langchain.lmChatOllama",
|
|
66
|
+
"@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
|
67
|
+
"@n8n/n8n-nodes-langchain.lmChatGroq",
|
|
68
|
+
"@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
|
|
69
|
+
"@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
|
|
70
|
+
"@n8n/n8n-nodes-langchain.lmChatDeepSeek",
|
|
71
|
+
"@n8n/n8n-nodes-langchain.lmChatOpenRouter",
|
|
72
|
+
"@n8n/n8n-nodes-langchain.lmChatXAiGrok"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: "ai_memory"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: "ai_tool",
|
|
81
|
+
required: true
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "ai_outputParser"
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
if (hasOutputParser === false) {
|
|
88
|
+
specialInputs = specialInputs.filter((input) => input.type !== "ai_outputParser");
|
|
89
|
+
}
|
|
90
|
+
return ["main", ...getInputData(specialInputs)];
|
|
91
|
+
}
|
|
92
|
+
class AgentV2 {
|
|
93
|
+
constructor(baseDescription) {
|
|
94
|
+
this.description = {
|
|
95
|
+
...baseDescription,
|
|
96
|
+
version: 2,
|
|
97
|
+
defaults: {
|
|
98
|
+
name: "AI Agent",
|
|
99
|
+
color: "#404040"
|
|
100
|
+
},
|
|
101
|
+
inputs: `={{
|
|
102
|
+
((hasOutputParser) => {
|
|
103
|
+
${getInputs.toString()};
|
|
104
|
+
return getInputs(hasOutputParser)
|
|
105
|
+
})($parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true)
|
|
106
|
+
}}`,
|
|
107
|
+
outputs: [import_n8n_workflow.NodeConnectionTypes.Main],
|
|
108
|
+
properties: [
|
|
109
|
+
{
|
|
110
|
+
displayName: 'Tip: Get a feel for agents with our quick <a href="https://docs.n8n.io/advanced-ai/intro-tutorial/" target="_blank">tutorial</a> or see an <a href="/templates/1954" target="_blank">example</a> of how this node works',
|
|
111
|
+
name: "notice_tip",
|
|
112
|
+
type: "notice",
|
|
113
|
+
default: ""
|
|
114
|
+
},
|
|
115
|
+
import_descriptions.promptTypeOptions,
|
|
116
|
+
{
|
|
117
|
+
...import_descriptions.textFromPreviousNode,
|
|
118
|
+
displayOptions: {
|
|
119
|
+
show: {
|
|
120
|
+
promptType: ["auto"]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
...import_descriptions.textInput,
|
|
126
|
+
displayOptions: {
|
|
127
|
+
show: {
|
|
128
|
+
promptType: ["define"]
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
displayName: "Require Specific Output Format",
|
|
134
|
+
name: "hasOutputParser",
|
|
135
|
+
type: "boolean",
|
|
136
|
+
default: false,
|
|
137
|
+
noDataExpression: true
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${import_n8n_workflow.NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,
|
|
141
|
+
name: "notice",
|
|
142
|
+
type: "notice",
|
|
143
|
+
default: "",
|
|
144
|
+
displayOptions: {
|
|
145
|
+
show: {
|
|
146
|
+
hasOutputParser: [true]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
...import_description.toolsAgentProperties
|
|
151
|
+
]
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async execute() {
|
|
155
|
+
return await import_execute.toolsAgentExecute.call(this);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {
|
|
160
|
+
AgentV2
|
|
161
|
+
});
|
|
162
|
+
//# sourceMappingURL=AgentV2.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/agents/Agent/V2/AgentV2.node.ts"],"sourcesContent":["import { NodeConnectionTypes } from 'n8n-workflow';\nimport type {\n\tINodeInputConfiguration,\n\tINodeInputFilter,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tNodeConnectionType,\n\tINodeTypeBaseDescription,\n} from 'n8n-workflow';\n\nimport { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';\n\nimport { toolsAgentProperties } from '../agents/ToolsAgent/V2/description';\nimport { toolsAgentExecute } from '../agents/ToolsAgent/V2/execute';\n\n// Function used in the inputs expression to figure out which inputs to\n// display based on the agent type\nfunction getInputs(hasOutputParser?: boolean): Array<NodeConnectionType | INodeInputConfiguration> {\n\tinterface SpecialInput {\n\t\ttype: NodeConnectionType;\n\t\tfilter?: INodeInputFilter;\n\t\trequired?: boolean;\n\t}\n\n\tconst getInputData = (\n\t\tinputs: SpecialInput[],\n\t): Array<NodeConnectionType | INodeInputConfiguration> => {\n\t\tconst displayNames: { [key: string]: string } = {\n\t\t\tai_languageModel: 'Model',\n\t\t\tai_memory: 'Memory',\n\t\t\tai_tool: 'Tool',\n\t\t\tai_outputParser: 'Output Parser',\n\t\t};\n\n\t\treturn inputs.map(({ type, filter }) => {\n\t\t\tconst isModelType = type === 'ai_languageModel';\n\t\t\tlet displayName = type in displayNames ? displayNames[type] : undefined;\n\t\t\tif (isModelType) {\n\t\t\t\tdisplayName = 'Chat Model';\n\t\t\t}\n\t\t\tconst input: INodeInputConfiguration = {\n\t\t\t\ttype,\n\t\t\t\tdisplayName,\n\t\t\t\trequired: isModelType,\n\t\t\t\tmaxConnections: ['ai_languageModel', 'ai_memory', 'ai_outputParser'].includes(\n\t\t\t\t\ttype as NodeConnectionType,\n\t\t\t\t)\n\t\t\t\t\t? 1\n\t\t\t\t\t: undefined,\n\t\t\t};\n\n\t\t\tif (filter) {\n\t\t\t\tinput.filter = filter;\n\t\t\t}\n\n\t\t\treturn input;\n\t\t});\n\t};\n\n\tlet specialInputs: SpecialInput[] = [\n\t\t{\n\t\t\ttype: 'ai_languageModel',\n\t\t\tfilter: {\n\t\t\t\tnodes: [\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAnthropic',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAwsBedrock',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatMistralCloud',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOllama',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGroq',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleVertex',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleGemini',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatDeepSeek',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenRouter',\n\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatXAiGrok',\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'ai_memory',\n\t\t},\n\t\t{\n\t\t\ttype: 'ai_tool',\n\t\t\trequired: true,\n\t\t},\n\t\t{\n\t\t\ttype: 'ai_outputParser',\n\t\t},\n\t];\n\n\tif (hasOutputParser === false) {\n\t\tspecialInputs = specialInputs.filter((input) => input.type !== 'ai_outputParser');\n\t}\n\treturn ['main', ...getInputData(specialInputs)];\n}\n\nexport class AgentV2 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\t...baseDescription,\n\t\t\tversion: 2,\n\t\t\tdefaults: {\n\t\t\t\tname: 'AI Agent',\n\t\t\t\tcolor: '#404040',\n\t\t\t},\n\t\t\tinputs: `={{\n\t\t\t\t((hasOutputParser) => {\n\t\t\t\t\t${getInputs.toString()};\n\t\t\t\t\treturn getInputs(hasOutputParser)\n\t\t\t\t})($parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true)\n\t\t\t}}`,\n\t\t\toutputs: [NodeConnectionTypes.Main],\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'Tip: Get a feel for agents with our quick <a href=\"https://docs.n8n.io/advanced-ai/intro-tutorial/\" target=\"_blank\">tutorial</a> or see an <a href=\"/templates/1954\" target=\"_blank\">example</a> of how this node works',\n\t\t\t\t\tname: 'notice_tip',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t},\n\t\t\t\tpromptTypeOptions,\n\t\t\t\t{\n\t\t\t\t\t...textFromPreviousNode,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['auto'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textInput,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['define'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Require Specific Output Format',\n\t\t\t\t\tname: 'hasOutputParser',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...toolsAgentProperties,\n\t\t\t],\n\t\t};\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\treturn await toolsAgentExecute.call(this);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoC;AAYpC,0BAAmE;AAEnE,yBAAqC;AACrC,qBAAkC;AAIlC,SAAS,UAAU,iBAAgF;AAOlG,QAAM,eAAe,CACpB,WACyD;AACzD,UAAM,eAA0C;AAAA,MAC/C,kBAAkB;AAAA,MAClB,WAAW;AAAA,MACX,SAAS;AAAA,MACT,iBAAiB;AAAA,IAClB;AAEA,WAAO,OAAO,IAAI,CAAC,EAAE,MAAM,OAAO,MAA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