-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Feature/new workflow loop node #13058
Open
Woo0ood
wants to merge
15
commits into
langgenius:plugins/beta
Choose a base branch
from
AICT-Team:feature/new-workflow-loop-node
base: plugins/beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/new workflow loop node #13058
Woo0ood
wants to merge
15
commits into
langgenius:plugins/beta
from
AICT-Team:feature/new-workflow-loop-node
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The main reason is that the original design only considered nodes with nested sub-nodes of type Iterator. After adding the Loop, additional checks and handling are required.
dosubot
bot
added
size:XXL
This PR changes 1000+ lines, ignoring generated files.
🌊 feat:workflow
Workflow related stuff.
labels
Jan 26, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🌊 feat:workflow
Workflow related stuff.
size:XXL
This PR changes 1000+ lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the Loop Node, a feature designed to enable workflows or processes to execute repeatedly until specific conditions or formats are met. The node allows users to define internal variables and outputs that determine whether to exit the loop. A maximum iteration limit can also be set to prevent infinite loops.
The addition of the Loop Node addresses the community’s and team’s demand for executing repeated HTTP interface calls or invoking LLMs multiple times in a workflow. The implementation aligns with the feedback and requirements outlined in Issue #12354.
Resolves #12354
Close #12289
Author
This PR is submitted by the AICT Team from NetDragon Websoft Inc., aiming to contribute to the open-source community. The AICT Team is dedicated to promoting the continuous optimization and functional expansion of Dify and other open-source products. By introducing practical features such as the Loop Node, the team hopes to help community users build more efficient and intelligent workflow solutions, working together to create a stronger Dify ecosystem.
Screenshots
Some Details
This pull request introduces a new feature for handling single loop runs in workflows and advanced chat applications. The changes include adding new API endpoints, updating the app generator and runner classes, and modifying the task pipeline to support loop events.
New API endpoints:
Advanc /edChatDraftRunLoopNodeApi
andWorkflowDraftRunLoopNodeApi
classes to handle POST requests for running draft workflow loop nodes. (api/controllers/console/app/workflow.py
)App generator updates:
single_loop_generate
method inAdvancedChatAppGenerator
andWorkflowAppGenerator
to generate app responses for single loop runs. (api/core/app/apps/advanced_chat/app_generator.py
) [1] (api/core/app/apps/workflow/app_generator.py
) [2]App runner updates:
AdvancedChatAppRunner
andWorkflowAppRunner
to handle single loop runs by adding logic to fetch and process graph and variable pool for loops. (api/core/app/apps/advanced_chat/app_runner.py
) [1] (api/core/app/apps/workflow/app_runner.py
) [2]Task pipeline modifications:
QueueLoopStartEvent
,QueueLoopNextEvent
,QueueLoopCompletedEvent
,QueueNodeInLoopFailedEvent
) and updated the_process_stream_response
method to handle these events. (api/core/app/apps/advanced_chat/generate_task_pipeline.py
) [1] [2] [3] (api/core/app/apps/workflow/generate_task_pipeline.py
) [4] [5] [6]These changes collectively enhance the system's ability to manage and execute single loop runs within workflows and advanced chat applications.
Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods