dify icon indicating copy to clipboard operation
dify copied to clipboard

Support for Nested Iterations in Workflows

Open Arslan-Soomro opened this issue 11 months ago • 2 comments

Self Checks

  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Image In complex workflows, you often need nested iterations. I was trying out Dify because I wanted to simplify creating AI Workflows. I created these workflows using code before. I am creating an AI Workflow in the Legal Domain. Basically, the workflow suggests edits in the legal document (pleading) to improve it. Below are the steps:
  1. It reads the legal document (string) and generates statements (array of strings) using LLM.

  2. (Iteration) For each statement (string), it uses a custom tool that I created to find similar legal documents (judgments) that discuss the statement. Often, these legal documents are too long. So now each statement has associated legal documents (an array of strings).

    • (Iteration) For each legal document (judgment), summarize it so we can fit the insights from the legal documents (judgments), along with the initial legal document (pleading) and some instructions.

Oh wait, Dify doesn't support nested iteration. So I left creating the flow after the second point. I really like the tool but this limitation made me go back to code.

Now I know some people would suggest concatenating the legal documents and summarize that, The legal documents are too long and they would become longer than the context length of the llm, hence I won't be able to summarize them in one go. Other than that its not a proper solution even if it worked, sometimes you would want the llm to focus on only one specific task (document) to maintain the quality of the output.

This is a necessary feature, Can you confirm if there is currently any way to enable nested iterations? If not, I’d love to contribute towards implementing this feature.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • [x] I am interested in contributing to this feature.

Arslan-Soomro avatar Feb 20 '25 15:02 Arslan-Soomro

+1

waylonwang avatar Feb 26 '25 09:02 waylonwang

Hi, @Arslan-Soomro. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary

  • You requested support for nested iterations in Dify workflows.
  • This feature is important for tasks like summarizing legal documents.
  • The absence of this feature has led you to revert to using code.
  • User waylonwang has shown support for this request.

Next Steps

  • Is this issue still relevant to the latest version of the Dify repository? If so, please comment to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Mar 29 '25 16:03 dosubot[bot]

We are planning

Yevanchen avatar Apr 03 '25 09:04 Yevanchen

@crazywoola, the user has indicated that this issue regarding nested iterations in Dify workflows is still relevant as they are planning to move forward with it. Could you please assist them with this request?

dosubot[bot] avatar Apr 03 '25 10:04 dosubot[bot]

+1

Elop1 avatar Apr 08 '25 07:04 Elop1

Hi, @Arslan-Soomro. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You requested support for nested iterations in Dify workflows to handle complex tasks like summarizing legal documents.
  • The absence of this feature has led you to use code as a workaround.
  • Other users, including waylonwang and Elop1, have expressed support for this feature request.
  • I previously marked the issue as stale but noted its relevance, and Yevanchen indicated plans to address it.
  • I requested assistance from crazywoola to move forward with the request.

Next Steps:

  • Please let us know if this issue is still relevant to the latest version of the Dify repository by commenting here to keep the discussion open.
  • If no further updates are provided, the issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar May 09 '25 16:05 dosubot[bot]