@cascadeflow/n8n-nodes-cascadeflow 0.7.9 → 1.0.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +271 -301
  3. package/package.json +12 -13
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lemony Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -20,48 +20,16 @@
20
20
 
21
21
  ![cascadeflow Domain Routing](../../../.github/assets/n8n-CF-domains.jpg)
22
22
 
23
- This is an n8n community node that brings cascadeflow's intelligent AI model cascading to n8n workflows.
23
+ This package provides **two nodes** for n8n workflows:
24
24
 
25
- **cascadeflow** reduces LLM API costs by 40-85% by trying a cheap model first, validating quality, and only escalating to expensive models when needed.
25
+ | Node | Type | Use case |
26
+ |------|------|----------|
27
+ | **CascadeFlow (Model)** | Language Model sub-node | Drop-in replacement for any AI Chat Model. Wire into Basic LLM Chain, Chain, or any node that accepts a Language Model. |
28
+ | **CascadeFlow Agent** | Standalone agent node | Full agent with tool calling, memory, and multi-step reasoning. Wire directly into workflows like Chat Trigger → Agent → response. |
26
29
 
27
- [n8n](https://n8n.io/) is a fair-code licensed workflow automation platform.
28
-
29
- ## How It Works
30
-
31
- The cascadeflow node is a **Language Model sub-node** that sits between your AI models and downstream n8n nodes (like Basic LLM Chain, Chain, or any node that accepts Language Model inputs):
32
-
33
- ![cascadeflow n8n Workflow](../../../.github/assets/n8n-CF.png)
34
-
35
- **Architecture:**
36
-
37
- ```
38
- ┌─────────────┐
39
- │ Drafter │ (e.g., Claude Haiku, GPT-4o-mini)
40
- │ AI Model │
41
- └──────┬──────┘
42
-
43
- ├──────► ┌──────────────┐
44
- │ │ cascadeflow │
45
- │ │ Node │ ────► ┌──────────────┐
46
- │ └──────────────┘ │ Basic Chain │
47
- ├──────► Quality checks │ Chain │
48
- │ Cascades if needed │ & more │
49
- │ └──────────────┘
50
- ┌──────┴──────┐
51
- │ Verifier │ (e.g., Claude Sonnet, GPT-4o)
52
- │ AI Model │
53
- └─────────────┘
54
- ```
55
-
56
- **Flow:**
57
- 1. Query goes to cheap drafter model first
58
- 2. cascadeflow validates the response quality
59
- 3. If quality passes → return drafter response (fast + cheap ✅)
60
- 4. If quality fails → escalate to verifier model (slower but accurate ⚠️)
30
+ Both nodes share the same cascade engine: try a cheap drafter first, validate quality, escalate to a verifier only when needed. **40-85% cost savings.**
61
31
 
62
- **Result:** 70-80% of queries accept the drafter, saving 40-85% on costs.
63
-
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.
32
+ [n8n](https://n8n.io/) is a fair-code licensed workflow automation platform.
65
33
 
66
34
  ## Installation
67
35
 
@@ -76,8 +44,6 @@ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes
76
44
 
77
45
  ### Manual installation
78
46
 
79
- To get started install the package in your n8n root directory:
80
-
81
47
  ```bash
82
48
  npm install @cascadeflow/n8n-nodes-cascadeflow
83
49
  ```
@@ -88,25 +54,62 @@ For Docker-based deployments add the following line before the font installation
88
54
  RUN cd /usr/local/lib/node_modules/n8n && npm install @cascadeflow/n8n-nodes-cascadeflow
89
55
  ```
90
56
 
91
- ## Quick Start
57
+ ---
92
58
 
93
- ### Basic Setup
59
+ ## Node 1: CascadeFlow (Model)
94
60
 
95
- 1. **Add two AI Chat Model nodes** (e.g., OpenAI Chat Model, Anthropic Chat Model, Ollama Chat Model)
96
- - Configure one as your **drafter** (cheap model like `gpt-4o-mini` or `claude-3-5-haiku-20241022`)
97
- - Configure one as your **verifier** (powerful model like `gpt-4o` or `claude-3-5-sonnet-20241022`)
61
+ A **Language Model sub-node** (`ai_languageModel` output) that acts as a drop-in cascading wrapper around two models.
98
62
 
99
- 2. **Add the cascadeflow node**
100
- - Connect the drafter model to the **Drafter** input
101
- - Connect the verifier model to the **Verifier** input
102
- - Optionally adjust the **Quality Threshold** (default: 0.4, and per-complexity thresholds are enabled by default)
63
+ ### When to use
103
64
 
104
- 3. **Connect to a Chain node**
105
- - The cascadeflow node outputs a Language Model connection
106
- - Connect it to nodes that accept AI models (Basic LLM Chain, Chain, etc.)
107
- - For agent workflows, use the **CascadeFlow Agent** node (connect tools to its `Tools` input).
65
+ - You want to plug cascadeflow into an existing chain or LLM node
66
+ - No tool calling or memory needed
67
+ - Works with: Basic LLM Chain, Chain, Question and Answer Chain, Summarization Chain, and any node that accepts a Language Model input
108
68
 
109
- ### Example Workflow
69
+ ### Architecture
70
+
71
+ ```
72
+ ┌─────────────┐
73
+ │ Drafter │ (e.g., Claude Haiku, GPT-4o-mini)
74
+ └──────┬──────┘
75
+
76
+ ├──────► ┌──────────────┐
77
+ │ │ CascadeFlow │
78
+ │ │ (Model) │ ────► ┌──────────────┐
79
+ │ └──────────────┘ │ Basic Chain │
80
+ │ Quality checks │ Chain │
81
+ │ Cascades if needed │ & more │
82
+ │ └──────────────┘
83
+ ┌──────┴──────┐
84
+ │ Verifier │ (e.g., Claude Sonnet, GPT-4o)
85
+ └─────────────┘
86
+ ```
87
+
88
+ ### Inputs
89
+
90
+ | Port | Type | Required | Description |
91
+ |------|------|----------|-------------|
92
+ | Verifier | `ai_languageModel` | Yes | Powerful model used when drafter quality is too low |
93
+ | Drafter | `ai_languageModel` | Yes | Cheap/fast model tried first |
94
+ | Domain models | `ai_languageModel` | No | Appear when domain cascading is enabled |
95
+
96
+ ### Output
97
+
98
+ | Port | Type | Description |
99
+ |------|------|-------------|
100
+ | Model | `ai_languageModel` | Language Model connection for downstream chain/LLM nodes |
101
+
102
+ ### Parameters
103
+
104
+ | Parameter | Default | Description |
105
+ |-----------|---------|-------------|
106
+ | Quality Threshold | 0.4 | Minimum quality score (0-1) to accept drafter response |
107
+ | Use Complexity Thresholds | true | Per-complexity confidence thresholds (trivial→expert) |
108
+ | Enable Alignment Scoring | true | Score query-response alignment for better validation |
109
+ | Enable Complexity Routing | true | Route complex queries directly to verifier |
110
+ | Enable Domain Cascading | false | Detect query domain and route to specialized models |
111
+
112
+ ### Quick Start
110
113
 
111
114
  ```
112
115
  ┌──────────────────┐
@@ -117,8 +120,8 @@ RUN cd /usr/local/lib/node_modules/n8n && npm install @cascadeflow/n8n-nodes-cas
117
120
  v
118
121
  ┌──────────────────┐ ┌──────────────────┐
119
122
  │ OpenAI Model │──────►│ │
120
- │ gpt-4o-mini │ │ cascadeflow │ ┌──────────────────┐
121
- └──────────────────┘ │ Node │──────►│ Basic LLM Chain │
123
+ │ gpt-4o-mini │ │ CascadeFlow │ ┌──────────────────┐
124
+ └──────────────────┘ │ (Model) │──────►│ Basic LLM Chain │
122
125
  │ │ │ │
123
126
  ┌──────────────────┐ │ Threshold: 0.4 │ └──────────────────┘
124
127
  │ OpenAI Model │──────►│ │
@@ -126,41 +129,157 @@ RUN cd /usr/local/lib/node_modules/n8n && npm install @cascadeflow/n8n-nodes-cas
126
129
  └──────────────────┘
127
130
  ```
128
131
 
129
- ## Configuration
132
+ ---
133
+
134
+ ## Node 2: CascadeFlow Agent
135
+
136
+ A **standalone agent node** (`main` in/out) with its own agent loop, tool calling, memory, and per-tool cascade/verifier routing.
137
+
138
+ ### When to use
139
+
140
+ - You need tool calling with cascade-aware routing
141
+ - You want memory (conversation history) built in
142
+ - You want to wire directly into a workflow (Chat Trigger → Agent → response)
143
+ - You need per-tool routing rules (force verifier after specific tools)
144
+ - You need tool call validation (drafter tool calls verified before execution)
145
+
146
+ ### Architecture
147
+
148
+ ```
149
+ ┌──────────────────┐
150
+ │ Chat Trigger │
151
+ │ or any node │
152
+ └────────┬─────────┘
153
+ │ (main)
154
+ v
155
+ ┌──────────────────────────────────────────┐
156
+ │ CascadeFlow Agent │
157
+ │ │
158
+ │ ┌─────────┐ ┌─────────┐ ┌──────────┐│
159
+ │ │ Verifier│ │ Drafter │ │ Memory ││
160
+ │ └────┬────┘ └────┬────┘ └────┬─────┘│
161
+ │ │ │ │ │
162
+ │ ┌────┴────────────┴────┐ │ │
163
+ │ │ Cascade Engine │◄──────┘ │
164
+ │ │ + Agent Loop │ │
165
+ │ └──────────┬───────────┘ │
166
+ │ │ │
167
+ │ ┌──────────┴───────────┐ │
168
+ │ │ Tools │ │
169
+ │ └──────────────────────┘ │
170
+ └──────────────────┬───────────────────────┘
171
+ │ (main)
172
+ v
173
+ ┌──────────────────┐
174
+ │ Next node │
175
+ │ (response, etc.) │
176
+ └──────────────────┘
177
+ ```
178
+
179
+ ### Inputs
180
+
181
+ | Port | Type | Required | Description |
182
+ |------|------|----------|-------------|
183
+ | (main) | `main` | Yes | Workflow items from upstream node (e.g., Chat Trigger) |
184
+ | Verifier | `ai_languageModel` | Yes | Powerful model for verification and escalation |
185
+ | Drafter | `ai_languageModel` | Yes | Cheap/fast model tried first |
186
+ | Memory | `ai_memory` | No | Chat memory (e.g., Window Buffer Memory) for conversation history |
187
+ | Tools | `ai_tool` | No | Up to 99 tools for the agent to call |
188
+ | Domain models | `ai_languageModel` | No | Appear when domain cascading is enabled |
189
+
190
+ ### Output
191
+
192
+ | Port | Type | Description |
193
+ |------|------|-------------|
194
+ | Output | `main` | Workflow items with `output`, cascade metadata, and `trace` |
195
+
196
+ The output JSON for each item contains:
197
+
198
+ ```json
199
+ {
200
+ "output": "The agent's final response text",
201
+ "model_used": "gpt-4o-mini",
202
+ "domain": "code",
203
+ "confidence": 0.85,
204
+ "trace": [
205
+ { "model_used": "gpt-4o-mini", "tool_calls": ["search"] },
206
+ { "model_used": "gpt-4o", "tool_calls": [] }
207
+ ]
208
+ }
209
+ ```
210
+
211
+ ### Parameters
212
+
213
+ | Parameter | Default | Description |
214
+ |-----------|---------|-------------|
215
+ | System Message | (empty) | System prompt for the agent |
216
+ | Text | `{{ $json.chatInput }}` | User input message. Auto-wires with Chat Trigger. |
217
+ | Quality Threshold | 0.4 | Minimum quality score to accept drafter response |
218
+ | Use Complexity Thresholds | true | Per-complexity confidence thresholds |
219
+ | Enable Tool Call Validation | true | Validate drafter tool calls before execution; re-generate with verifier on failure |
220
+ | Max Tool Iterations | 3 | Maximum tool-call loop iterations |
221
+ | Tool Routing Rules | (none) | Per-tool routing overrides (cascade or force verifier) |
222
+ | Enable Domain Cascading | false | Domain-specific model routing |
223
+
224
+ ### Quick Start
225
+
226
+ ```
227
+ ┌──────────────────┐
228
+ │ Chat Trigger │
229
+ └────────┬─────────┘
230
+
231
+ v
232
+ ┌──────────────────────────────────────────┐
233
+ │ CascadeFlow Agent │
234
+ │ │
235
+ │ Claude Haiku ──► Drafter │
236
+ │ Claude Sonnet ─► Verifier │ ┌──────────────────┐
237
+ │ Window Buffer ─► Memory │──────►│ Respond to │
238
+ │ HTTP Request ──► Tool │ │ Webhook │
239
+ │ Calculator ────► Tool │ └──────────────────┘
240
+ └──────────────────────────────────────────┘
241
+ ```
242
+
243
+ ### Tool Routing Rules
130
244
 
131
- ### Node Parameters
245
+ Override cascade behavior for specific tools:
132
246
 
133
- #### Quality Threshold (0-1)
247
+ | Routing | Behavior |
248
+ |---------|----------|
249
+ | **Cascade** (default) | Drafter generates tool calls, cascade validates |
250
+ | **Verifier** | After this tool executes, the verifier generates the final response |
134
251
 
135
- Controls how aggressively to accept drafter responses when **Use Complexity Thresholds** is disabled.
252
+ Use verifier routing for high-stakes tools (e.g., database writes, payment APIs) where you want the powerful model to interpret results.
136
253
 
137
- Defaults to **0.4** to match the `simple` tier in CascadeFlow's default per-complexity thresholds.
254
+ ### Tool Call Validation
138
255
 
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
256
+ When enabled (default), the agent validates drafter-generated tool calls before executing them:
257
+ - JSON syntax check
258
+ - Schema validation
259
+ - Safety checks
145
260
 
146
- Lower threshold = more cost savings, higher threshold = better quality assurance.
261
+ If validation fails, tool calls are re-generated by the verifier model, preventing malformed or unsafe tool invocations.
147
262
 
148
- ## Multi-Domain Cascading (Optional)
263
+ ---
149
264
 
150
- cascadeflow supports **intelligent domain-specific cascading** - automatically detecting the type of query and routing it to a specialized model for that domain.
265
+ ## Shared Features
151
266
 
152
- ### How It Works
267
+ Both nodes share these capabilities:
153
268
 
154
- 1. **Enable Domain Cascading** in the node settings
155
- 2. **Toggle individual domains** you want to support
156
- 3. **Connect domain-specific models** to the new input ports that appear
269
+ ### Cascade Flow
157
270
 
158
- When a query comes in, cascadeflow:
159
- 1. Detects the domain (e.g., "Write a Python function" → Code domain)
160
- 2. Routes to the specialized model for that domain (if connected)
161
- 3. Falls back to drafter verifier cascade if no domain model is available
271
+ 1. Query goes to cheap drafter model first
272
+ 2. cascadeflow validates the response quality
273
+ 3. If quality passes return drafter response (fast + cheap)
274
+ 4. If quality failsescalate to verifier model (slower but accurate)
162
275
 
163
- ### Supported Domains
276
+ **Result:** 70-80% of queries accept the drafter, saving 40-85% on costs.
277
+
278
+ ### Multi-Domain Cascading (Optional)
279
+
280
+ Both nodes support domain-specific cascading. Enable it in the node settings to automatically detect query domains and route to specialized models.
281
+
282
+ **Supported domains:**
164
283
 
165
284
  | Domain | Description | Example Queries |
166
285
  |--------|-------------|-----------------|
@@ -172,31 +291,34 @@ When a query comes in, cascadeflow:
172
291
  | **Medical** | Healthcare, medical knowledge, clinical | "What are the symptoms of...", "Explain this diagnosis..." |
173
292
  | **Financial** | Finance, accounting, investment analysis | "Analyze this stock...", "Calculate ROI..." |
174
293
  | **Science** | Scientific knowledge, research, experiments | "Explain quantum...", "How does photosynthesis..." |
175
-
176
- ### Setup Example
177
-
178
- ```
179
- ┌──────────────────┐
180
- │ Claude Haiku │──► Drafter (default cheap model)
181
- └──────────────────┘
182
- ┌──────────────────┐
183
- │ GPT-4o │──► Verifier (default powerful model)
184
- └──────────────────┘
185
- ┌──────────────────┐ ┌──────────────────┐
186
- │ DeepSeek Coder │──► Code │ │
187
- └──────────────────┘ │ │
188
- ┌──────────────────┐ │ cascadeflow │──► Chain
189
- │ Qwen Math │──► Math │ Node │
190
- └──────────────────┘ │ │
191
- ┌──────────────────┐ │ │
192
- │ Claude Sonnet │──► Legal│ │
193
- └──────────────────┘ └──────────────────┘
194
- ```
195
-
196
- ### When to Use Domain Cascading
197
-
198
- - **Use it when**: You have domain-specific models that excel in certain areas (e.g., DeepSeek for code, specialized medical models)
199
- - **Skip it when**: Your drafter/verifier combination handles all domains well enough
294
+ | **Structured** | JSON, XML, structured output | "Generate a JSON schema..." |
295
+ | **RAG** | Retrieval-augmented generation | "Based on the document..." |
296
+ | **Conversation** | General chat, small talk | "How are you?", "Tell me about..." |
297
+ | **Tool** | Tool-oriented queries | "Search for...", "Calculate..." |
298
+ | **Summary** | Summarization tasks | "Summarize this article..." |
299
+ | **Translation** | Language translation | "Translate to French..." |
300
+ | **Multimodal** | Image/audio/video queries | "Describe this image..." |
301
+ | **General** | Catch-all domain | Everything else |
302
+
303
+ **Setup:**
304
+ 1. Enable Domain Cascading in node settings
305
+ 2. Toggle individual domains
306
+ 3. Connect domain-specific models to the new input ports
307
+ 4. Optionally enable domain verifiers to override the global verifier per domain
308
+
309
+ ### Complexity Thresholds
310
+
311
+ When enabled (default), acceptance is driven by query complexity:
312
+
313
+ | Complexity | Default Threshold |
314
+ |------------|-------------------|
315
+ | Trivial | 0.25 |
316
+ | Simple | 0.40 |
317
+ | Moderate | 0.55 |
318
+ | Hard | 0.70 |
319
+ | Expert | 0.80 |
320
+
321
+ ---
200
322
 
201
323
  ## Flow Visualization
202
324
 
@@ -204,69 +326,34 @@ When a query comes in, cascadeflow:
204
326
 
205
327
  cascadeflow provides detailed logging of every cascade decision in n8n's UI:
206
328
 
207
- 1. **Execute your workflow** with the cascadeflow node
208
- 2. **Click on the downstream Chain node** after execution (the node that receives cascadeflow output)
209
- 3. **Navigate to the "Logs" tab**
329
+ 1. **Execute your workflow**
330
+ 2. **For CascadeFlow (Model):** Click the downstream Chain node "Logs" tab
331
+ 3. **For CascadeFlow Agent:** Click the Agent node → "Output" tab (trace is in the output JSON)
210
332
 
211
- You'll see detailed flow information like:
333
+ Example log output:
212
334
 
213
335
  ```
214
- 🎯 cascadeflow: Trying drafter model...
215
- 📊 Quality validation: confidence=0.85, method=heuristic
216
- 🎯 Alignment: 0.82
217
-
218
- ┌─────────────────────────────────────────┐
219
- │ ✅ FLOW: DRAFTER ACCEPTED (FAST PATH) │
220
- └─────────────────────────────────────────┘
221
- Query → Drafter → Quality Check ✅ → Response
222
- ⚡ Fast & Cheap: Used drafter model only
223
- Confidence: 0.85 (threshold: 0.70)
224
- Quality score: 0.85
225
- Latency: 420ms
226
- 💰 Cost savings: ~93.8% (used cheap model)
227
- 📊 Stats: 7 drafter, 2 verifier
228
- ```
336
+ CascadeFlow: Trying drafter model...
337
+ Quality validation: confidence=0.85, method=heuristic
338
+ Alignment: 0.82
229
339
 
230
- Or when escalating:
231
-
232
- ```
233
- 🎯 cascadeflow: Trying drafter model...
234
- 📊 Quality validation: confidence=0.62, method=heuristic
235
-
236
- ┌────────────────────────────────────────────────┐
237
- │ ⚠️ FLOW: ESCALATED TO VERIFIER (SLOW PATH) │
238
- └────────────────────────────────────────────────┘
239
- Query → Drafter → Quality Check ❌ → Verifier → Response
240
- 🔄 Escalating: Drafter quality too low, using verifier
241
- Confidence: 0.62 < 0.70 (threshold)
242
- Reason: Simple check failed (confidence: 0.62 < 0.70)
243
- Drafter latency: 380ms
244
- 🔄 Loading verifier model...
245
- ✅ Verifier completed successfully
246
- Verifier latency: 890ms
247
- Total latency: 1270ms (drafter: 380ms + verifier: 890ms)
248
- 💰 Cost: Full verifier cost (0% savings this request)
249
- 📊 Stats: 7 drafter (77.8%), 2 verifier
340
+ FLOW: DRAFTER ACCEPTED (FAST PATH)
341
+ Query -> Drafter -> Quality Check -> Response
342
+ Confidence: 0.85 (threshold: 0.70)
343
+ Cost savings: ~93.8% (used cheap model)
250
344
  ```
251
345
 
252
- ### What the Logs Show
253
-
254
- - **Flow path taken**: Drafter accepted, escalated to verifier, or error fallback
255
- - **Quality scores**: Confidence level and alignment scores
256
- - **Latency breakdown**: Time spent on each model
257
- - **Cost analysis**: Savings percentage for each request
258
- - **Running statistics**: Acceptance rate across all requests
346
+ ---
259
347
 
260
348
  ## Recommended Model Configurations
261
349
 
262
- ### ⭐ Best Overall: Claude Haiku + GPT-4o (Recommended)
350
+ ### Claude Haiku + GPT-4o (Recommended)
263
351
 
264
352
  ```
265
353
  Drafter: claude-3-5-haiku-20241022
266
354
  Verifier: gpt-4o
267
355
  Savings: ~73% average
268
- Why: Haiku's fast, high-quality drafts + GPT-4o's reasoning
269
- Use for: General purpose, coding, reasoning, complex queries
356
+ Best for: General purpose, coding, reasoning
270
357
  ```
271
358
 
272
359
  ### Anthropic Only (High Quality)
@@ -275,7 +362,6 @@ Use for: General purpose, coding, reasoning, complex queries
275
362
  Drafter: claude-3-5-haiku-20241022
276
363
  Verifier: claude-3-5-sonnet-20241022
277
364
  Savings: ~70% average
278
- Why: Consistent Anthropic experience, excellent quality
279
365
  ```
280
366
 
281
367
  ### OpenAI Only (Good Balance)
@@ -284,7 +370,6 @@ Why: Consistent Anthropic experience, excellent quality
284
370
  Drafter: gpt-4o-mini
285
371
  Verifier: gpt-4o
286
372
  Savings: ~85% average
287
- Why: Both models from same provider, great cost efficiency
288
373
  ```
289
374
 
290
375
  ### Ultra Fast with Ollama (Local)
@@ -293,119 +378,38 @@ Why: Both models from same provider, great cost efficiency
293
378
  Drafter: ollama/qwen2.5:3b (local)
294
379
  Verifier: gpt-4o (cloud)
295
380
  Savings: ~99% on drafter calls (no API cost)
296
- Why: Local model for drafts, cloud for verification
297
381
  Note: Requires Ollama installed locally
298
382
  ```
299
383
 
300
- ## Cost Savings Examples
301
-
302
- **Example: Claude Haiku + GPT-4o**
303
-
304
- | Scenario | Traditional (GPT-4o only) | cascadeflow (Haiku + GPT-4o) | Savings |
305
- |----------|---------------------------|------------------------------|---------|
306
- | Simple Q&A (75% acceptance) | $0.0025 | $0.0008 | 68% |
307
- | Complex query (25% escalation) | $0.0025 | $0.0025 | 0% (correctly escalated) |
308
- | **Average** | **$0.0025** | **$0.00115** | **54%** |
309
-
310
- **Monthly savings (10,000 queries):**
311
- - Traditional (GPT-4o only): $25.00
312
- - cascadeflow (Haiku + GPT-4o): $11.50
313
- - **You save: $13.50/month** (54% savings)
314
-
315
- **Monthly savings (100,000 queries):**
316
- - Traditional (GPT-4o only): $250.00
317
- - cascadeflow (Haiku + GPT-4o): $115.00
318
- - **You save: $135.00/month** (54% savings)
319
-
320
- ## Example Workflows
321
-
322
- ### Customer Support Bot
384
+ ---
323
385
 
324
- ```
325
- ┌──────────────────┐
326
- │ Webhook │ ← Customer question
327
- │ (POST /support) │
328
- └────────┬─────────┘
329
-
330
- v
331
- ┌─────────────────────────────────────┐
332
- │ Claude Haiku ────┐ │
333
- │ │ cascadeflow │ ┌──────────────────┐
334
- │ Claude Sonnet ───┴─► Node │──────►│ Basic Chain │
335
- └─────────────────────────────────────┘ │ (responds) │
336
- └──────┬───────────┘
337
-
338
- v
339
- ┌──────────────────┐
340
- │ Send Response │
341
- └──────────────────┘
342
- ```
386
+ ## Troubleshooting
343
387
 
344
- ### Content Generation
388
+ ### "Drafter model is required"
345
389
 
346
- ```
347
- ┌──────────────────┐
348
- │ Schedule Trigger │ ← Daily at 9am
349
- │ (Daily) │
350
- └────────┬─────────┘
351
-
352
- v
353
- ┌────────────────────────────────────────┐
354
- │ GPT-4o-mini ─────┐ │
355
- │ │ cascadeflow │ ┌──────────────────┐
356
- │ GPT-4o ──────────┴─► Node │──────►│ Basic Chain │
357
- └────────────────────────────────────────┘ │ (generates) │
358
- └──────┬───────────┘
359
-
360
- v
361
- ┌──────────────────┐
362
- │ Save to Notion │
363
- └──────────────────┘
364
- ```
390
+ Make sure you've connected an AI Chat Model to the **Drafter** input port.
365
391
 
366
- ### Code Review Assistant
392
+ ### "Verifier model is required"
367
393
 
368
- ```
369
- ┌──────────────────┐
370
- │ GitHub Trigger │ ← New PR
371
- │ (PR opened) │
372
- └────────┬─────────┘
373
-
374
- v
375
- ┌─────────────────────────────────────┐
376
- │ Ollama qwen2.5 ──┐ │
377
- │ │ cascadeflow │ ┌──────────────────┐
378
- │ GPT-4o ──────────┴─► Node │──────►│ Basic Chain │
379
- └─────────────────────────────────────┘ │ (reviews code) │
380
- └──────┬───────────┘
381
-
382
- v
383
- ┌──────────────────┐
384
- │ Post Comment │
385
- └──────────────────┘
386
- ```
394
+ Make sure you've connected an AI Chat Model to the **Verifier** input port.
387
395
 
388
- ## UI Visualization Note
396
+ ### Not seeing cascade logs
389
397
 
390
- ⚠️ **Important:** Due to n8n's rendering conventions, the node visualization always highlights the **Drafter** connection as active (green), regardless of which model was actually used at runtime. This is because n8n highlights the first input in a sub-node's definition.
398
+ - **CascadeFlow (Model):** Logs appear in the downstream Chain node's "Logs" tab, not the cascadeflow node itself.
399
+ - **CascadeFlow Agent:** Cascade metadata and trace are in the output JSON of the Agent node.
391
400
 
392
- **This does not affect functionality** - the cascade logic works correctly. The drafter is always tried first, and the verifier is only loaded when needed.
401
+ ### Always escalating to verifier
393
402
 
394
- **To see the actual cascade flow and which model was used:**
403
+ 1. Try lowering the Quality Threshold (0.3-0.4)
404
+ 2. Verify your drafter model is actually a cheaper/faster model
405
+ 3. Check logs for the confidence scores being reported
395
406
 
396
- 1. Execute your workflow
397
- 2. Click on the downstream Chain node after execution (the node that receives cascadeflow output)
398
- 3. Navigate to the **"Logs"** tab
399
- 4. You'll see detailed flow information showing:
400
- - Whether the drafter was accepted or escalated to verifier
401
- - Quality confidence scores and validation methods
402
- - Latency breakdown for each model
403
- - Cost savings percentage
404
- - Running statistics across all executions
407
+ ### "This node cannot be connected"
405
408
 
406
- The logs provide complete visibility into the cascade decision-making process, showing exactly which path was taken for each request.
409
+ - Use **CascadeFlow (Model)** with Chain/LLM nodes that accept Language Model inputs
410
+ - Use **CascadeFlow Agent** for standalone agent workflows with tool calling and memory
407
411
 
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`.
412
+ ---
409
413
 
410
414
  ## Compatibility
411
415
 
@@ -418,45 +422,11 @@ The logs provide complete visibility into the cascade decision-making process, s
418
422
  - Google PaLM Chat Model
419
423
  - And more...
420
424
 
421
- ## Troubleshooting
422
-
423
- ### Issue: "Drafter model is required"
424
-
425
- **Solution:** Make sure you've connected an AI Chat Model to the **Drafter** input (second input, bottom position).
426
-
427
- ### Issue: "Verifier model is required"
428
-
429
- **Solution:** Make sure you've connected an AI Chat Model to the **Verifier** input (first input, top position).
430
-
431
- ### Issue: Not seeing cascade logs
432
-
433
- **Solution:**
434
- 1. Make sure your workflow has executed successfully
435
- 2. Click on the **Chain node that receives the cascadeflow output** (Basic LLM Chain, Chain, etc.)
436
- 3. Navigate to the **"Logs"** tab (not the "Output" tab)
437
- 4. The logs appear in the downstream node, not the cascadeflow node itself
438
-
439
- ### Issue: "This node cannot be connected" when connecting to AI Agent
440
-
441
- **Solution:** Use the **CascadeFlow Agent** node for agent workflows. Use the **CascadeFlow (Model)** node for Chain/LLM workflows.
442
- - ✅ Basic LLM Chain
443
- - ✅ Chain
444
- - ✅ Other nodes that accept Language Model connections
445
- - ✅ CascadeFlow Agent (agent workflows)
446
-
447
- ### Issue: Always escalating to verifier
448
-
449
- **Solution:**
450
- 1. Check your Quality Threshold setting (try lowering to 0.6-0.65)
451
- 2. Verify your drafter model is actually a cheaper/faster model
452
- 3. Check the logs to see the confidence scores being reported
453
-
454
425
  ## Resources
455
426
 
456
427
  - [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
457
428
  - [cascadeflow GitHub](https://github.com/lemony-ai/cascadeflow)
458
429
  - [cascadeflow Documentation](https://github.com/lemony-ai/cascadeflow/blob/main/README.md)
459
- - [Full n8n Integration Guide](https://github.com/lemony-ai/cascadeflow/blob/main/docs/guides/n8n_integration.md)
460
430
 
461
431
  ## License
462
432
 
@@ -464,29 +434,29 @@ The logs provide complete visibility into the cascade decision-making process, s
464
434
 
465
435
  ## Version History
466
436
 
467
- ### v0.6.7 (Latest)
437
+ ### v1.0.0 (Latest)
468
438
 
469
- - **Multi-domain cascading docs**: Added documentation for 8-domain intelligent cascading
470
- - **Removed semantic validation**: Disabled ML-based semantic validation to prevent out-of-memory crashes
471
- - **Shorter domain labels**: Domain input labels simplified (Code, Math, Data, etc.)
439
+ - **CascadeFlow Agent → standalone node**: Converted from `supplyData()` sub-node to `execute()` node with main in/out
440
+ - **Memory support**: Added `ai_memory` input for conversation history (Window Buffer Memory, etc.)
441
+ - **System message & text params**: Agent node now has its own system prompt and text input (defaults to `{{ $json.chatInput }}`)
442
+ - **Direct workflow wiring**: Chat Trigger → CascadeFlow Agent → response, no intermediate Chain node needed
472
443
 
473
- ### v0.6.4
444
+ ### v0.7.x
474
445
 
475
- - **Individual domain toggles**: Replaced multi-select with individual boolean toggles for each domain
476
- - **Dynamic input ports**: Domain model inputs appear dynamically as each domain is enabled
446
+ - **Domain cascading labels**: Shortened domain input labels, section dividers, tool call validation on by default
447
+ - **Single getInputConnectionData call**: Correct model resolution and n8n highlighting
477
448
 
478
- ### v0.6.3
449
+ ### v0.6.x
479
450
 
480
- - **16-domain routing**: Support for intelligent routing across 16 specialized domains (code, math, data, creative, legal, medical, financial, science, and more)
451
+ - **Multi-domain cascading**: 16-domain intelligent routing with individual toggles and dynamic input ports
452
+ - **Removed semantic validation**: Disabled ML-based semantic validation to prevent OOM crashes
481
453
  - **Circuit breaker**: Added circuit breaker pattern for improved reliability
482
- - **Domain-specific models**: Connect specialized models for different query types
483
454
 
484
455
  ### v0.5.0
485
456
 
486
- - **Flow visualization in n8n Logs tab**: Detailed cascade flow logging with visual boxes
487
- - **Real-time quality metrics**: Confidence scores, alignment scores, latency breakdown, and cost savings
457
+ - **Flow visualization**: Detailed cascade flow logging in n8n Logs tab
488
458
  - **Quality validator integration**: Integrated QualityValidator from @cascadeflow/core
489
- - **Better cascade decisions**: Complexity-aware validation replacing naive length-based checks
459
+ - **Complexity-aware validation**: Replacing naive length-based checks
490
460
 
491
461
  ### v0.4.x and earlier
492
462
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascadeflow/n8n-nodes-cascadeflow",
3
- "version": "0.7.9",
3
+ "version": "1.0.1",
4
4
  "description": "n8n node for cascadeflow - Smart AI model cascading with 40-85% cost savings",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -21,15 +21,6 @@
21
21
  "url": "https://github.com/lemony-ai/cascadeflow.git",
22
22
  "directory": "packages/integrations/n8n"
23
23
  },
24
- "scripts": {
25
- "build": "tsc && gulp build:icons",
26
- "dev": "tsc --watch",
27
- "test": "vitest run",
28
- "format": "prettier nodes credentials --write",
29
- "lint": "eslint \"nodes/**/*.ts\" \"credentials/**/*.ts\" package.json",
30
- "lintfix": "eslint \"nodes/**/*.ts\" \"credentials/**/*.ts\" package.json --fix",
31
- "prepublishOnly": "npm run build && npm run lint"
32
- },
33
24
  "files": [
34
25
  "dist"
35
26
  ],
@@ -61,7 +52,15 @@
61
52
  "access": "public"
62
53
  },
63
54
  "dependencies": {
64
- "@langchain/core": "^0.3.0",
65
- "@cascadeflow/core": "^0.6.0"
55
+ "@langchain/core": "^1.1.0",
56
+ "@cascadeflow/core": "^1.0.1"
57
+ },
58
+ "scripts": {
59
+ "build": "tsc && gulp build:icons",
60
+ "dev": "tsc --watch",
61
+ "test": "vitest run",
62
+ "format": "prettier nodes credentials --write",
63
+ "lint": "eslint \"nodes/**/*.ts\" \"credentials/**/*.ts\" package.json",
64
+ "lintfix": "eslint \"nodes/**/*.ts\" \"credentials/**/*.ts\" package.json --fix"
66
65
  }
67
- }
66
+ }