-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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/newnew workflow loop node #14863
Merged
laipz8200
merged 25 commits into
langgenius:main
from
AICT-Team:feature/newnew-workflow-loop-node
Mar 5, 2025
Merged
Feature/newnew workflow loop node #14863
laipz8200
merged 25 commits into
langgenius:main
from
AICT-Team:feature/newnew-workflow-loop-node
Mar 5, 2025
+6,032
−160
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
b443478
to
305e051
Compare
2025-03-04.22.37.46.movSuggestion:
|
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.
Export the formatNode functions for both Iteration and Loop, and merge them into a unified method called formatIterationAndLoopNode. This method will handle the NodeTracing List uniformly, addressing the timing issues in the tracing logs caused by the previous categorized handling.
04aaacf
to
6588bfd
Compare
I have addressed the first suggestion. The second suggestion will be handled later (maybe🌚..). append: all done |
crazywoola
approved these changes
Mar 5, 2025
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.
Good job!
|
laipz8200
approved these changes
Mar 5, 2025
4 tasks
jackzhuo
pushed a commit
to jackzhuo/dify
that referenced
this pull request
Mar 14, 2025
Co-authored-by: arkunzz <[email protected]>
5 tasks
parambharat
pushed a commit
to parambharat/dify
that referenced
this pull request
Mar 31, 2025
Co-authored-by: arkunzz <[email protected]>
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
📚 documentation
Improvements or additions to documentation
🌊 feat:workflow
Workflow related stuff.
lgtm
This PR has been approved by a maintainer
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
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.
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.
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