@cascadeflow/n8n-nodes-cascadeflow 0.6.7 → 0.7.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/README.md +16 -11
- package/dist/nodes/CascadeFlowAgent/CascadeFlowAgent.node.d.ts +34 -0
- package/dist/nodes/CascadeFlowAgent/CascadeFlowAgent.node.d.ts.map +1 -0
- package/dist/nodes/CascadeFlowAgent/CascadeFlowAgent.node.js +466 -0
- package/dist/nodes/CascadeFlowAgent/CascadeFlowAgent.node.js.map +1 -0
- package/dist/nodes/CascadeFlowAgent/__tests__/cascadeflow-agent-executor.test.d.ts +2 -0
- package/dist/nodes/CascadeFlowAgent/__tests__/cascadeflow-agent-executor.test.d.ts.map +1 -0
- package/dist/nodes/CascadeFlowAgent/__tests__/cascadeflow-agent-executor.test.js +98 -0
- package/dist/nodes/CascadeFlowAgent/__tests__/cascadeflow-agent-executor.test.js.map +1 -0
- package/dist/nodes/CascadeFlowAgent/cascadeflow.svg +15 -0
- package/dist/nodes/LmChatCascadeFlow/LmChatCascadeFlow.node.d.ts +100 -0
- package/dist/nodes/LmChatCascadeFlow/LmChatCascadeFlow.node.d.ts.map +1 -1
- package/dist/nodes/LmChatCascadeFlow/LmChatCascadeFlow.node.js +432 -303
- package/dist/nodes/LmChatCascadeFlow/LmChatCascadeFlow.node.js.map +1 -1
- package/dist/nodes/LmChatCascadeFlow/__tests__/lm-chat-cascadeflow-node.test.d.ts +2 -0
- package/dist/nodes/LmChatCascadeFlow/__tests__/lm-chat-cascadeflow-node.test.d.ts.map +1 -0
- package/dist/nodes/LmChatCascadeFlow/__tests__/lm-chat-cascadeflow-node.test.js +59 -0
- package/dist/nodes/LmChatCascadeFlow/__tests__/lm-chat-cascadeflow-node.test.js.map +1 -0
- package/dist/nodes/LmChatCascadeFlow/cascade-metadata.d.ts +27 -0
- package/dist/nodes/LmChatCascadeFlow/cascade-metadata.d.ts.map +1 -0
- package/dist/nodes/LmChatCascadeFlow/cascade-metadata.js +21 -0
- package/dist/nodes/LmChatCascadeFlow/cascade-metadata.js.map +1 -0
- package/dist/nodes/LmChatCascadeFlow/config.d.ts +41 -0
- package/dist/nodes/LmChatCascadeFlow/config.d.ts.map +1 -0
- package/dist/nodes/LmChatCascadeFlow/config.js +87 -0
- package/dist/nodes/LmChatCascadeFlow/config.js.map +1 -0
- package/package.json +17 -12
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ The cascadeflow node is a **Language Model sub-node** that sits between your AI
|
|
|
61
61
|
|
|
62
62
|
**Result:** 70-80% of queries accept the drafter, saving 40-85% on costs.
|
|
63
63
|
|
|
64
|
-
> **ℹ️ Note:**
|
|
64
|
+
> **ℹ️ Note:** Use **CascadeFlow (Model)** with n8n Chain/LLM nodes, and **CascadeFlow Agent** for agent workflows (tool calling + multi-step). The Agent node adds trace metadata and supports tool routing.
|
|
65
65
|
|
|
66
66
|
## Installation
|
|
67
67
|
|
|
@@ -99,12 +99,12 @@ RUN cd /usr/local/lib/node_modules/n8n && npm install @cascadeflow/n8n-nodes-cas
|
|
|
99
99
|
2. **Add the cascadeflow node**
|
|
100
100
|
- Connect the drafter model to the **Drafter** input
|
|
101
101
|
- Connect the verifier model to the **Verifier** input
|
|
102
|
-
-
|
|
102
|
+
- Optionally adjust the **Quality Threshold** (default: 0.4, and per-complexity thresholds are enabled by default)
|
|
103
103
|
|
|
104
104
|
3. **Connect to a Chain node**
|
|
105
105
|
- The cascadeflow node outputs a Language Model connection
|
|
106
106
|
- Connect it to nodes that accept AI models (Basic LLM Chain, Chain, etc.)
|
|
107
|
-
-
|
|
107
|
+
- For agent workflows, use the **CascadeFlow Agent** node (connect tools to its `Tools` input).
|
|
108
108
|
|
|
109
109
|
### Example Workflow
|
|
110
110
|
|
|
@@ -120,7 +120,7 @@ RUN cd /usr/local/lib/node_modules/n8n && npm install @cascadeflow/n8n-nodes-cas
|
|
|
120
120
|
│ gpt-4o-mini │ │ cascadeflow │ ┌──────────────────┐
|
|
121
121
|
└──────────────────┘ │ Node │──────►│ Basic LLM Chain │
|
|
122
122
|
│ │ │ │
|
|
123
|
-
┌──────────────────┐ │ Threshold: 0.
|
|
123
|
+
┌──────────────────┐ │ Threshold: 0.4 │ └──────────────────┘
|
|
124
124
|
│ OpenAI Model │──────►│ │
|
|
125
125
|
│ gpt-4o │ └──────────────────┘
|
|
126
126
|
└──────────────────┘
|
|
@@ -132,11 +132,16 @@ RUN cd /usr/local/lib/node_modules/n8n && npm install @cascadeflow/n8n-nodes-cas
|
|
|
132
132
|
|
|
133
133
|
#### Quality Threshold (0-1)
|
|
134
134
|
|
|
135
|
-
Controls how aggressively to accept drafter responses
|
|
135
|
+
Controls how aggressively to accept drafter responses when **Use Complexity Thresholds** is disabled.
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
Defaults to **0.4** to match the `simple` tier in CascadeFlow's default per-complexity thresholds.
|
|
138
|
+
|
|
139
|
+
If you enable **Use Complexity Thresholds** (default), acceptance is driven by:
|
|
140
|
+
- trivial: 0.25
|
|
141
|
+
- simple: 0.4
|
|
142
|
+
- moderate: 0.55
|
|
143
|
+
- hard: 0.7
|
|
144
|
+
- expert: 0.8
|
|
140
145
|
|
|
141
146
|
Lower threshold = more cost savings, higher threshold = better quality assurance.
|
|
142
147
|
|
|
@@ -400,7 +405,7 @@ Note: Requires Ollama installed locally
|
|
|
400
405
|
|
|
401
406
|
The logs provide complete visibility into the cascade decision-making process, showing exactly which path was taken for each request.
|
|
402
407
|
|
|
403
|
-
> **ℹ️ Important:**
|
|
408
|
+
> **ℹ️ Important:** If you need agent-style tool orchestration, use the **CascadeFlow Agent** node. It is designed for n8n agent flows and records a step-by-step trace in `response_metadata.cf.trace`.
|
|
404
409
|
|
|
405
410
|
## Compatibility
|
|
406
411
|
|
|
@@ -433,11 +438,11 @@ The logs provide complete visibility into the cascade decision-making process, s
|
|
|
433
438
|
|
|
434
439
|
### Issue: "This node cannot be connected" when connecting to AI Agent
|
|
435
440
|
|
|
436
|
-
**Solution:**
|
|
441
|
+
**Solution:** Use the **CascadeFlow Agent** node for agent workflows. Use the **CascadeFlow (Model)** node for Chain/LLM workflows.
|
|
437
442
|
- ✅ Basic LLM Chain
|
|
438
443
|
- ✅ Chain
|
|
439
444
|
- ✅ Other nodes that accept Language Model connections
|
|
440
|
-
-
|
|
445
|
+
- ✅ CascadeFlow Agent (agent workflows)
|
|
441
446
|
|
|
442
447
|
### Issue: Always escalating to verifier
|
|
443
448
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { INodeType, INodeTypeDescription, ISupplyDataFunctions, SupplyData } from 'n8n-workflow';
|
|
2
|
+
import { CascadeChatModel } from '../LmChatCascadeFlow/LmChatCascadeFlow.node';
|
|
3
|
+
type ToolRoutingMode = 'cascade' | 'verifier';
|
|
4
|
+
export interface ToolRoutingRule {
|
|
5
|
+
toolName: string;
|
|
6
|
+
routing: ToolRoutingMode;
|
|
7
|
+
}
|
|
8
|
+
export interface ToolLike {
|
|
9
|
+
name?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
invoke?: (args: any) => Promise<any>;
|
|
12
|
+
call?: (args: any) => Promise<any>;
|
|
13
|
+
run?: (args: any) => Promise<any>;
|
|
14
|
+
}
|
|
15
|
+
export declare class CascadeFlowAgentExecutor {
|
|
16
|
+
private cascadeModel;
|
|
17
|
+
private maxIterations;
|
|
18
|
+
private toolMap;
|
|
19
|
+
private routingRules;
|
|
20
|
+
constructor(cascadeModel: CascadeChatModel, tools: ToolLike[], routingRules: ToolRoutingRule[], maxIterations: number);
|
|
21
|
+
private normalizeMessages;
|
|
22
|
+
private extractToolCalls;
|
|
23
|
+
private executeTool;
|
|
24
|
+
private resolveRouting;
|
|
25
|
+
private buildTraceEntry;
|
|
26
|
+
invoke(input: any, options?: any): Promise<any>;
|
|
27
|
+
stream(input: any, options?: any): AsyncGenerator<any>;
|
|
28
|
+
}
|
|
29
|
+
export declare class CascadeFlowAgent implements INodeType {
|
|
30
|
+
description: INodeTypeDescription;
|
|
31
|
+
supplyData(this: ISupplyDataFunctions): Promise<SupplyData>;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=CascadeFlowAgent.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CascadeFlowAgent.node.d.ts","sourceRoot":"","sources":["../../../nodes/CascadeFlowAgent/CascadeFlowAgent.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACX,MAAM,cAAc,CAAC;AAQtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAE/E,KAAK,eAAe,GAAG,SAAS,GAAG,UAAU,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,eAAe,CAAC;CAC1B;AAQD,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACnC;AAED,qBAAa,wBAAwB;IAKjC,OAAO,CAAC,YAAY;IAGpB,OAAO,CAAC,aAAa;IAPvB,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,YAAY,CAA+B;gBAGzC,YAAY,EAAE,gBAAgB,EACtC,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,eAAe,EAAE,EACvB,aAAa,EAAE,MAAM;IAQ/B,OAAO,CAAC,iBAAiB;IA8EzB,OAAO,CAAC,gBAAgB;YA4CV,WAAW;IAqBzB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,eAAe;IAkBjB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA4D9C,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC;CAc9D;AAED,qBAAa,gBAAiB,YAAW,SAAS;IAChD,WAAW,EAAE,oBAAoB,CAwM/B;IAEI,UAAU,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;CAgFlE"}
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CascadeFlowAgent = exports.CascadeFlowAgentExecutor = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const messages_1 = require("@langchain/core/messages");
|
|
6
|
+
const LmChatCascadeFlow_node_1 = require("../LmChatCascadeFlow/LmChatCascadeFlow.node");
|
|
7
|
+
class CascadeFlowAgentExecutor {
|
|
8
|
+
constructor(cascadeModel, tools, routingRules, maxIterations) {
|
|
9
|
+
this.cascadeModel = cascadeModel;
|
|
10
|
+
this.maxIterations = maxIterations;
|
|
11
|
+
this.toolMap = new Map(tools.filter((tool) => tool?.name).map((tool) => [tool.name, tool]));
|
|
12
|
+
this.routingRules = new Map(routingRules.map((rule) => [rule.toolName, rule.routing]));
|
|
13
|
+
}
|
|
14
|
+
normalizeMessages(input) {
|
|
15
|
+
const isBaseMessage = (value) => {
|
|
16
|
+
return (value &&
|
|
17
|
+
typeof value === 'object' &&
|
|
18
|
+
typeof value._getType === 'function' &&
|
|
19
|
+
'content' in value);
|
|
20
|
+
};
|
|
21
|
+
const coerceMessage = (value) => {
|
|
22
|
+
if (isBaseMessage(value)) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
if (typeof value === 'string') {
|
|
26
|
+
return new messages_1.HumanMessage(value);
|
|
27
|
+
}
|
|
28
|
+
if (!value || typeof value !== 'object') {
|
|
29
|
+
return new messages_1.HumanMessage(JSON.stringify(value ?? null));
|
|
30
|
+
}
|
|
31
|
+
const role = (value.role ?? value.type ?? '').toString().toLowerCase();
|
|
32
|
+
const content = value.content ?? value.text ?? '';
|
|
33
|
+
if (role === 'system') {
|
|
34
|
+
return new messages_1.SystemMessage(content);
|
|
35
|
+
}
|
|
36
|
+
if (role === 'assistant' || role === 'ai') {
|
|
37
|
+
return new messages_1.AIMessage(content);
|
|
38
|
+
}
|
|
39
|
+
if (role === 'tool') {
|
|
40
|
+
const toolCallId = value.tool_call_id ??
|
|
41
|
+
value.toolCallId ??
|
|
42
|
+
value.tool_callId ??
|
|
43
|
+
value.id ??
|
|
44
|
+
'tool';
|
|
45
|
+
return new messages_1.ToolMessage({
|
|
46
|
+
content: typeof content === 'string' ? content : JSON.stringify(content),
|
|
47
|
+
tool_call_id: String(toolCallId),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// Default: treat as user/human.
|
|
51
|
+
return new messages_1.HumanMessage(content);
|
|
52
|
+
};
|
|
53
|
+
const normalizeList = (values) => values.map(coerceMessage);
|
|
54
|
+
if (Array.isArray(input)) {
|
|
55
|
+
return normalizeList(input);
|
|
56
|
+
}
|
|
57
|
+
if (typeof input === 'string') {
|
|
58
|
+
return [new messages_1.HumanMessage(input)];
|
|
59
|
+
}
|
|
60
|
+
if (input?.messages && Array.isArray(input.messages)) {
|
|
61
|
+
return normalizeList(input.messages);
|
|
62
|
+
}
|
|
63
|
+
if (input?.chatHistory && Array.isArray(input.chatHistory)) {
|
|
64
|
+
const history = normalizeList(input.chatHistory);
|
|
65
|
+
if (typeof input.input === 'string') {
|
|
66
|
+
return [...history, new messages_1.HumanMessage(input.input)];
|
|
67
|
+
}
|
|
68
|
+
return history;
|
|
69
|
+
}
|
|
70
|
+
if (typeof input?.input === 'string') {
|
|
71
|
+
return [new messages_1.HumanMessage(input.input)];
|
|
72
|
+
}
|
|
73
|
+
return [new messages_1.HumanMessage(JSON.stringify(input ?? null))];
|
|
74
|
+
}
|
|
75
|
+
extractToolCalls(message) {
|
|
76
|
+
const additionalKwargs = message.additional_kwargs || {};
|
|
77
|
+
const responseMetadata = message.response_metadata || {};
|
|
78
|
+
const toolCalls = additionalKwargs.tool_calls || responseMetadata.tool_calls;
|
|
79
|
+
if (Array.isArray(toolCalls)) {
|
|
80
|
+
return toolCalls
|
|
81
|
+
.map((toolCall) => {
|
|
82
|
+
const args = toolCall?.function?.arguments ?? toolCall?.arguments ?? '{}';
|
|
83
|
+
let parsedArgs = {};
|
|
84
|
+
try {
|
|
85
|
+
parsedArgs = typeof args === 'string' ? JSON.parse(args) : args;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
parsedArgs = { raw: args };
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
id: toolCall?.id ?? toolCall?.function?.name ?? `tool_${Date.now()}`,
|
|
92
|
+
name: toolCall?.function?.name ?? toolCall?.name,
|
|
93
|
+
args: parsedArgs,
|
|
94
|
+
};
|
|
95
|
+
})
|
|
96
|
+
.filter((call) => Boolean(call.name));
|
|
97
|
+
}
|
|
98
|
+
if (additionalKwargs.function_call) {
|
|
99
|
+
const functionCall = additionalKwargs.function_call;
|
|
100
|
+
let parsedArgs = {};
|
|
101
|
+
try {
|
|
102
|
+
parsedArgs = functionCall.arguments ? JSON.parse(functionCall.arguments) : {};
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
parsedArgs = { raw: functionCall.arguments };
|
|
106
|
+
}
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
id: functionCall.name ?? `tool_${Date.now()}`,
|
|
110
|
+
name: functionCall.name,
|
|
111
|
+
args: parsedArgs,
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
async executeTool(call) {
|
|
118
|
+
const tool = this.toolMap.get(call.name);
|
|
119
|
+
if (!tool) {
|
|
120
|
+
return `Tool '${call.name}' not found`;
|
|
121
|
+
}
|
|
122
|
+
if (tool.invoke) {
|
|
123
|
+
return JSON.stringify(await tool.invoke(call.args));
|
|
124
|
+
}
|
|
125
|
+
if (tool.call) {
|
|
126
|
+
return JSON.stringify(await tool.call(call.args));
|
|
127
|
+
}
|
|
128
|
+
if (tool.run) {
|
|
129
|
+
return JSON.stringify(await tool.run(call.args));
|
|
130
|
+
}
|
|
131
|
+
return `Tool '${call.name}' has no callable method`;
|
|
132
|
+
}
|
|
133
|
+
resolveRouting(toolCalls) {
|
|
134
|
+
for (const call of toolCalls) {
|
|
135
|
+
const routing = this.routingRules.get(call.name);
|
|
136
|
+
if (routing === 'verifier') {
|
|
137
|
+
return 'verifier';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return 'cascade';
|
|
141
|
+
}
|
|
142
|
+
buildTraceEntry(message, toolCalls = []) {
|
|
143
|
+
const responseMetadata = message.response_metadata || {};
|
|
144
|
+
const cf = responseMetadata.cf || {};
|
|
145
|
+
const cascadeflow = responseMetadata.cascadeflow || {};
|
|
146
|
+
return {
|
|
147
|
+
model_used: cf.model_used ?? cascadeflow.model_used ?? 'unknown',
|
|
148
|
+
domain: cf.domain ?? cascadeflow.domain ?? null,
|
|
149
|
+
confidence: cf.confidence ?? cascadeflow.confidence ?? null,
|
|
150
|
+
complexity: cf.complexity ?? cascadeflow.complexity ?? null,
|
|
151
|
+
costs: cf.costs ?? null,
|
|
152
|
+
savings: cf.savings ?? null,
|
|
153
|
+
flow: cascadeflow.flow ?? null,
|
|
154
|
+
reason: cascadeflow.reason ?? null,
|
|
155
|
+
tool_calls: toolCalls.map((call) => call.name),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async invoke(input, options) {
|
|
159
|
+
const messages = this.normalizeMessages(input);
|
|
160
|
+
const trace = [];
|
|
161
|
+
let currentMessages = [...messages];
|
|
162
|
+
let finalMessage = null;
|
|
163
|
+
let iterations = 0;
|
|
164
|
+
while (iterations < this.maxIterations) {
|
|
165
|
+
const message = await this.cascadeModel.invoke(currentMessages, options);
|
|
166
|
+
const toolCalls = this.extractToolCalls(message);
|
|
167
|
+
trace.push(this.buildTraceEntry(message, toolCalls));
|
|
168
|
+
if (toolCalls.length === 0) {
|
|
169
|
+
finalMessage = message;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
const routing = this.resolveRouting(toolCalls);
|
|
173
|
+
currentMessages = [...currentMessages, message];
|
|
174
|
+
for (const call of toolCalls) {
|
|
175
|
+
const toolResult = await this.executeTool(call);
|
|
176
|
+
currentMessages.push(new messages_1.ToolMessage({
|
|
177
|
+
content: toolResult,
|
|
178
|
+
tool_call_id: call.id,
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
if (routing === 'verifier') {
|
|
182
|
+
const verifierMessage = await this.cascadeModel.invokeVerifierDirect(currentMessages, options);
|
|
183
|
+
trace.push(this.buildTraceEntry(verifierMessage));
|
|
184
|
+
finalMessage = verifierMessage;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
iterations += 1;
|
|
188
|
+
}
|
|
189
|
+
if (!finalMessage) {
|
|
190
|
+
finalMessage = new messages_1.AIMessage('Agent did not produce a final response.');
|
|
191
|
+
}
|
|
192
|
+
if (!finalMessage.response_metadata) {
|
|
193
|
+
finalMessage.response_metadata = {};
|
|
194
|
+
}
|
|
195
|
+
finalMessage.response_metadata.cf = {
|
|
196
|
+
...(finalMessage.response_metadata.cf || {}),
|
|
197
|
+
trace,
|
|
198
|
+
};
|
|
199
|
+
return {
|
|
200
|
+
output: finalMessage.content.toString(),
|
|
201
|
+
message: finalMessage,
|
|
202
|
+
trace,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
async *stream(input, options) {
|
|
206
|
+
const messages = this.normalizeMessages(input);
|
|
207
|
+
// For tool-driven execution we currently return a single final response.
|
|
208
|
+
if (this.toolMap.size > 0) {
|
|
209
|
+
yield await this.invoke(messages, options);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const stream = await this.cascadeModel.stream(messages, options);
|
|
213
|
+
for await (const chunk of stream) {
|
|
214
|
+
yield chunk;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.CascadeFlowAgentExecutor = CascadeFlowAgentExecutor;
|
|
219
|
+
class CascadeFlowAgent {
|
|
220
|
+
constructor() {
|
|
221
|
+
this.description = {
|
|
222
|
+
displayName: 'CascadeFlow Agent',
|
|
223
|
+
name: 'cascadeFlowAgent',
|
|
224
|
+
icon: 'file:cascadeflow.svg',
|
|
225
|
+
group: ['transform'],
|
|
226
|
+
version: 1,
|
|
227
|
+
description: 'CascadeFlow AI Agent with drafter/verifier orchestration, tool routing, and trace metadata.',
|
|
228
|
+
defaults: {
|
|
229
|
+
name: 'CascadeFlow Agent',
|
|
230
|
+
},
|
|
231
|
+
codex: {
|
|
232
|
+
categories: ['AI'],
|
|
233
|
+
subcategories: {
|
|
234
|
+
AI: ['Agents'],
|
|
235
|
+
},
|
|
236
|
+
resources: {
|
|
237
|
+
primaryDocumentation: [
|
|
238
|
+
{
|
|
239
|
+
url: 'https://github.com/lemony-ai/cascadeflow',
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
|
|
245
|
+
inputs: [
|
|
246
|
+
{
|
|
247
|
+
displayName: 'Verifier',
|
|
248
|
+
type: 'ai_languageModel',
|
|
249
|
+
maxConnections: 1,
|
|
250
|
+
required: true,
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
displayName: 'Drafter',
|
|
254
|
+
type: 'ai_languageModel',
|
|
255
|
+
maxConnections: 1,
|
|
256
|
+
required: true,
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
displayName: 'Tools',
|
|
260
|
+
type: 'ai_tool',
|
|
261
|
+
maxConnections: 99,
|
|
262
|
+
required: false,
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
|
|
266
|
+
outputs: ['ai_agent'],
|
|
267
|
+
outputNames: ['Agent'],
|
|
268
|
+
properties: [
|
|
269
|
+
{
|
|
270
|
+
displayName: 'Quality Threshold',
|
|
271
|
+
name: 'qualityThreshold',
|
|
272
|
+
type: 'number',
|
|
273
|
+
default: 0.4,
|
|
274
|
+
typeOptions: {
|
|
275
|
+
minValue: 0,
|
|
276
|
+
maxValue: 1,
|
|
277
|
+
numberPrecision: 2,
|
|
278
|
+
},
|
|
279
|
+
description: 'Minimum quality score (0-1) to accept drafter response',
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
displayName: 'Use Complexity Thresholds',
|
|
283
|
+
name: 'useComplexityThresholds',
|
|
284
|
+
type: 'boolean',
|
|
285
|
+
default: true,
|
|
286
|
+
description: 'Whether to use per-complexity confidence thresholds (trivial → expert)',
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
displayName: 'Trivial Threshold',
|
|
290
|
+
name: 'trivialThreshold',
|
|
291
|
+
type: 'number',
|
|
292
|
+
default: 0.25,
|
|
293
|
+
displayOptions: { show: { useComplexityThresholds: [true] } },
|
|
294
|
+
typeOptions: {
|
|
295
|
+
minValue: 0,
|
|
296
|
+
maxValue: 1,
|
|
297
|
+
numberPrecision: 2,
|
|
298
|
+
},
|
|
299
|
+
description: 'Minimum confidence for trivial queries',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
displayName: 'Simple Threshold',
|
|
303
|
+
name: 'simpleThreshold',
|
|
304
|
+
type: 'number',
|
|
305
|
+
default: 0.4,
|
|
306
|
+
displayOptions: { show: { useComplexityThresholds: [true] } },
|
|
307
|
+
typeOptions: {
|
|
308
|
+
minValue: 0,
|
|
309
|
+
maxValue: 1,
|
|
310
|
+
numberPrecision: 2,
|
|
311
|
+
},
|
|
312
|
+
description: 'Minimum confidence for simple queries',
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
displayName: 'Moderate Threshold',
|
|
316
|
+
name: 'moderateThreshold',
|
|
317
|
+
type: 'number',
|
|
318
|
+
default: 0.55,
|
|
319
|
+
displayOptions: { show: { useComplexityThresholds: [true] } },
|
|
320
|
+
typeOptions: {
|
|
321
|
+
minValue: 0,
|
|
322
|
+
maxValue: 1,
|
|
323
|
+
numberPrecision: 2,
|
|
324
|
+
},
|
|
325
|
+
description: 'Minimum confidence for moderate queries',
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
displayName: 'Hard Threshold',
|
|
329
|
+
name: 'hardThreshold',
|
|
330
|
+
type: 'number',
|
|
331
|
+
default: 0.7,
|
|
332
|
+
displayOptions: { show: { useComplexityThresholds: [true] } },
|
|
333
|
+
typeOptions: {
|
|
334
|
+
minValue: 0,
|
|
335
|
+
maxValue: 1,
|
|
336
|
+
numberPrecision: 2,
|
|
337
|
+
},
|
|
338
|
+
description: 'Minimum confidence for hard queries',
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
displayName: 'Expert Threshold',
|
|
342
|
+
name: 'expertThreshold',
|
|
343
|
+
type: 'number',
|
|
344
|
+
default: 0.8,
|
|
345
|
+
displayOptions: { show: { useComplexityThresholds: [true] } },
|
|
346
|
+
typeOptions: {
|
|
347
|
+
minValue: 0,
|
|
348
|
+
maxValue: 1,
|
|
349
|
+
numberPrecision: 2,
|
|
350
|
+
},
|
|
351
|
+
description: 'Minimum confidence for expert queries',
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
displayName: 'Enable Alignment Scoring',
|
|
355
|
+
name: 'useAlignmentScoring',
|
|
356
|
+
type: 'boolean',
|
|
357
|
+
default: true,
|
|
358
|
+
description: 'Whether to score query-response alignment for improved validation accuracy',
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
displayName: 'Enable Complexity Routing',
|
|
362
|
+
name: 'useComplexityRouting',
|
|
363
|
+
type: 'boolean',
|
|
364
|
+
default: true,
|
|
365
|
+
description: 'Whether to route complex queries directly to the verifier',
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
displayName: 'Max Tool Iterations',
|
|
369
|
+
name: 'maxIterations',
|
|
370
|
+
type: 'number',
|
|
371
|
+
default: 3,
|
|
372
|
+
typeOptions: {
|
|
373
|
+
minValue: 1,
|
|
374
|
+
maxValue: 10,
|
|
375
|
+
},
|
|
376
|
+
description: 'Maximum number of tool-call iterations before returning',
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
displayName: 'Tool Routing Rules',
|
|
380
|
+
name: 'toolRoutingRules',
|
|
381
|
+
type: 'fixedCollection',
|
|
382
|
+
typeOptions: {
|
|
383
|
+
multipleValues: true,
|
|
384
|
+
},
|
|
385
|
+
default: {},
|
|
386
|
+
options: [
|
|
387
|
+
{
|
|
388
|
+
name: 'rule',
|
|
389
|
+
displayName: 'Routing Rule',
|
|
390
|
+
values: [
|
|
391
|
+
{
|
|
392
|
+
displayName: 'Tool Name',
|
|
393
|
+
name: 'toolName',
|
|
394
|
+
type: 'string',
|
|
395
|
+
default: '',
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
displayName: 'Routing',
|
|
399
|
+
name: 'routing',
|
|
400
|
+
type: 'options',
|
|
401
|
+
options: [
|
|
402
|
+
{
|
|
403
|
+
name: 'Cascade (Default)',
|
|
404
|
+
value: 'cascade',
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
name: 'Verifier',
|
|
408
|
+
value: 'verifier',
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
default: 'cascade',
|
|
412
|
+
},
|
|
413
|
+
],
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
description: 'Override routing for specific tools (e.g., force verifier after tool call)',
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
async supplyData() {
|
|
422
|
+
const qualityThreshold = this.getNodeParameter('qualityThreshold', 0, 0.4);
|
|
423
|
+
const useAlignmentScoring = this.getNodeParameter('useAlignmentScoring', 0, true);
|
|
424
|
+
const useComplexityRouting = this.getNodeParameter('useComplexityRouting', 0, true);
|
|
425
|
+
const useComplexityThresholds = this.getNodeParameter('useComplexityThresholds', 0, true);
|
|
426
|
+
const maxIterations = this.getNodeParameter('maxIterations', 0, 3);
|
|
427
|
+
const confidenceThresholds = useComplexityThresholds
|
|
428
|
+
? {
|
|
429
|
+
trivial: this.getNodeParameter('trivialThreshold', 0, 0.25),
|
|
430
|
+
simple: this.getNodeParameter('simpleThreshold', 0, 0.4),
|
|
431
|
+
moderate: this.getNodeParameter('moderateThreshold', 0, 0.55),
|
|
432
|
+
hard: this.getNodeParameter('hardThreshold', 0, 0.7),
|
|
433
|
+
expert: this.getNodeParameter('expertThreshold', 0, 0.8),
|
|
434
|
+
}
|
|
435
|
+
: undefined;
|
|
436
|
+
const toolRoutingRaw = this.getNodeParameter('toolRoutingRules', 0, { rule: [] });
|
|
437
|
+
const toolRoutingRules = (toolRoutingRaw?.rule ?? []);
|
|
438
|
+
const drafterModelGetter = async () => {
|
|
439
|
+
const drafterData = await this.getInputConnectionData('ai_languageModel', 1);
|
|
440
|
+
const drafterModel = (Array.isArray(drafterData) ? drafterData[0] : drafterData);
|
|
441
|
+
if (!drafterModel) {
|
|
442
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Drafter model is required. Please connect your DRAFTER model to the Drafter port.');
|
|
443
|
+
}
|
|
444
|
+
return drafterModel;
|
|
445
|
+
};
|
|
446
|
+
const verifierModelGetter = async () => {
|
|
447
|
+
const verifierData = await this.getInputConnectionData('ai_languageModel', 0);
|
|
448
|
+
const verifierModel = (Array.isArray(verifierData) ? verifierData[0] : verifierData);
|
|
449
|
+
if (!verifierModel) {
|
|
450
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Verifier model is required. Please connect your VERIFIER model to the Verifier port.');
|
|
451
|
+
}
|
|
452
|
+
return verifierModel;
|
|
453
|
+
};
|
|
454
|
+
const toolsData = await this.getInputConnectionData('ai_tool', 2).catch(() => []);
|
|
455
|
+
const tools = (Array.isArray(toolsData) ? toolsData : toolsData ? [toolsData] : []);
|
|
456
|
+
// Keep semantic validation off in n8n to avoid OOM / heavy model loads.
|
|
457
|
+
const useSemanticValidation = false;
|
|
458
|
+
const cascadeModel = new LmChatCascadeFlow_node_1.CascadeChatModel(drafterModelGetter, verifierModelGetter, qualityThreshold, useSemanticValidation, useAlignmentScoring, useComplexityRouting, useComplexityThresholds, false, [], new Map(), new Map(), confidenceThresholds);
|
|
459
|
+
const agentExecutor = new CascadeFlowAgentExecutor(cascadeModel, tools, toolRoutingRules, maxIterations);
|
|
460
|
+
return {
|
|
461
|
+
response: agentExecutor,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
exports.CascadeFlowAgent = CascadeFlowAgent;
|
|
466
|
+
//# sourceMappingURL=CascadeFlowAgent.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CascadeFlowAgent.node.js","sourceRoot":"","sources":["../../../nodes/CascadeFlowAgent/CascadeFlowAgent.node.ts"],"names":[],"mappings":";;;AAOA,+CAAkD;AAGlD,uDAA+F;AAG/F,wFAA+E;AAuB/E,MAAa,wBAAwB;IAInC,YACU,YAA8B,EACtC,KAAiB,EACjB,YAA+B,EACvB,aAAqB;QAHrB,iBAAY,GAAZ,YAAY,CAAkB;QAG9B,kBAAa,GAAb,aAAa,CAAQ;QAE7B,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CACpB,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE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MAAM,aAAa,GAAG,IAAI,wBAAwB,CAChD,YAAY,EACZ,KAAK,EACL,gBAAgB,EAChB,aAAa,CACd,CAAC;QAEF,OAAO;YACL,QAAQ,EAAE,aAAa;SACxB,CAAC;IACJ,CAAC;CACF;AA3RD,4CA2RC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cascadeflow-agent-executor.test.d.ts","sourceRoot":"","sources":["../../../../nodes/CascadeFlowAgent/__tests__/cascadeflow-agent-executor.test.ts"],"names":[],"mappings":""}
|