-
-
Notifications
You must be signed in to change notification settings - Fork 23.5k
ParallelSubflows - Custom Tool #5624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ParallelSubflows - Custom Tool #5624
Conversation
Summary of ChangesHello @TS-Eichhorn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers a significant enhancement to Flowise by introducing a 'Parallel Subflows' tool node. This new capability allows users to orchestrate and execute multiple subflows simultaneously, greatly improving efficiency for complex workflows like multi-agent systems or fan-out/fan-in patterns. The node is highly customizable, offering granular control over individual subflow behaviors and comprehensive reporting on execution performance, making it easier to build and optimize sophisticated AI applications. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new Parallel Subflows tool, which is a great addition for orchestrating parallel workflows in Flowise. The implementation is robust, with features like concurrency control, timeouts, and detailed timing metrics.
My review focuses on a critical security vulnerability and some improvements to the code and documentation for clarity and correctness.
Key points:
- Security: There's a critical code injection vulnerability in
ParallelSubflows.tsdue to the use of theFunctionconstructor for parsing JSON. I've suggested replacing it with a safer parser. - Code Quality: I found some dead code in
core.tsthat should be removed. - Documentation: The
README.mdhas some inconsistencies in file paths and a minor typo that should be corrected to avoid confusion for users.
Overall, this is a well-designed feature. Addressing these points will make it even better.
| function convertToValidJSONString(inputString: string) { | ||
| try { | ||
| const obj = Function('return ' + inputString)() | ||
| return JSON.stringify(obj, null, 2) | ||
| } catch { | ||
| return '' | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of Function('return ' + inputString)() is a major security vulnerability as it can execute arbitrary JavaScript code, equivalent to eval(). This could lead to Remote Code Execution (RCE).
To safely parse lenient JSON (with unquoted keys, single quotes, etc.), please use a library like json5, which seems to be an existing dependency in this project.
First, add the following import at the top of the file:
import JSON5 from 'json5'Then, apply the suggested code change.
| function convertToValidJSONString(inputString: string) { | |
| try { | |
| const obj = Function('return ' + inputString)() | |
| return JSON.stringify(obj, null, 2) | |
| } catch { | |
| return '' | |
| } | |
| } | |
| function convertToValidJSONString(inputString: string) { | |
| try { | |
| const obj = JSON5.parse(inputString) | |
| return JSON.stringify(obj, null, 2) | |
| } catch { | |
| return '' | |
| } | |
| } |
| packages/components/nodes/tools/ParallelSubflows/ | ||
| packages/components/nodes/utilities/ParallelSubflows/ | ||
| ``` | ||
|
|
||
| 2. Add the files: | ||
|
|
||
| - `ParallelSubflows.ts` → `packages/components/nodes/tools/ParallelSubflows/ParallelSubflows.ts` | ||
| - `core.ts` → `packages/components/nodes/utilities/ParallelSubflows/core.ts` | ||
| - (Optional) `parallel.svg` in the repo root (used in this README) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The installation instructions contain incorrect file paths for core.ts and parallel.svg. This can be confusing for users trying to install this custom node.
- The
core.tsfile should be in.../tools/ParallelSubflows/, not.../utilities/ParallelSubflows/. - The
parallel.svgfile should also be placed within the.../tools/ParallelSubflows/directory, not the repo root.
The suggested change corrects these paths and removes the instruction to create an unnecessary utilities directory.
| packages/components/nodes/tools/ParallelSubflows/ | |
| packages/components/nodes/utilities/ParallelSubflows/ | |
| ``` | |
| 2. Add the files: | |
| - `ParallelSubflows.ts` → `packages/components/nodes/tools/ParallelSubflows/ParallelSubflows.ts` | |
| - `core.ts` → `packages/components/nodes/utilities/ParallelSubflows/core.ts` | |
| - (Optional) `parallel.svg` in the repo root (used in this README) | |
| packages/components/nodes/tools/ParallelSubflows/ |
- Add the files:
ParallelSubflows.ts→packages/components/nodes/tools/ParallelSubflows/ParallelSubflows.tscore.ts→packages/components/nodes/tools/ParallelSubflows/core.ts- (Optional)
parallel.svg→packages/components/nodes/tools/ParallelSubflows/parallel.svg
|
|
||
| 3. Build & run Flowise as you normally do (e.g., `pnpm build` then start the app). | ||
| 4. In the Flowise UI, add the **Parallel Subflows** node to your flow. | ||
| Addional information related to custom nodes in flowise can be found here: https://docs.flowiseai.com/contributing/building-node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo here. It should be 'Additional' instead of 'Addional'.
| Addional information related to custom nodes in flowise can be found here: https://docs.flowiseai.com/contributing/building-node | |
| Additional information related to custom nodes in flowise can be found here: https://docs.flowiseai.com/contributing/building-node |
| if (typeof (globalThis as any).AbortSignal?.timeout === 'function') { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Add Parallel Subflows Node for Flowise
Summary
This PR introduces a new Parallel Subflows tool node for Flowise that enables launching multiple subflows in parallel, with configurable concurrency, per-branch settings, robust timeout and failure handling, and rich timing insights. The node is designed to support fan-out / fan-in and multi-agent orchestration patterns.
✨ Key Features
maxParallellimitcontinue(default) orfail-fasttext,json, orfullexecution metadata{{input}},{{vars.*}}) for dynamic prompts🧩 What’s Included
ParallelSubflows.ts– Flowise tool node definitioncore.ts– parallel execution and orchestration engineparallel.svgfor UI / documentation visuals/predict/{id}API🧩 Use cases