Skip to content
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

LLM node can not produce stream response in workflow mode when IF-ELSE nested IF-ELSE #15162

Closed
5 tasks done
yunzhuqing opened this issue Mar 7, 2025 · 12 comments · Fixed by #14065
Closed
5 tasks done
Labels
🤔 cant-reproduce We can not reproduce it or the information is limited 🌊 feat:workflow Workflow related stuff.

Comments

@yunzhuqing
Copy link

Self Checks

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

Dify version

0.15.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Workflow was defined as below:
Image

TRUE branch will produce stream response,however, ELSE branch will block until all nodes has been executed

TRUE branch outputs is

Image

ELSE branch outputs

Image

The problem code maybe _fetch_node_ids_in_reachable_branch in StreamProcessor

Image

for ELSE branch, the condition is always true, the nodes after 'IF-ELSE 2' can not be append reachable_node_ids,

Image

these nodes will be deleted, this results stream_out_end_node_ids is always None

Image

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

@dosubot dosubot bot added the 🌊 feat:workflow Workflow related stuff. label Mar 7, 2025
Copy link

dosubot bot commented Mar 7, 2025

@yunzhuqing Hello! I'm here to help you with your reported issue. If you need assistance with bug resolution, have questions, or want to become a contributor, I'm the bot to talk to.

The issue you're encountering seems to be related to how the StreamProcessor class handles the ELSE branch in nested IF-ELSE statements. Specifically, the _fetch_node_ids_in_reachable_branch method may not be correctly identifying nodes in the ELSE branch as reachable, leading to their removal by the _remove_node_ids_in_unreachable_branch method. This results in stream_out_end_node_ids being None, which blocks the stream response until all nodes are executed.

To address this, you might want to investigate the logic within _fetch_node_ids_in_reachable_branch to ensure it correctly identifies nodes in the ELSE branch as reachable. This involves checking the conditions related to branch_identify and ensuring that nodes following an ELSE branch are not prematurely removed from the workflow execution path. Adjusting this logic should help in maintaining the integrity of the workflow and allow the ELSE branch to produce stream responses as expected.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@yunzhuqing
Copy link
Author

`
def _fetch_node_ids_in_reachable_branch(self, node_id: str, branch_identify: Optional[str] = None) -> list[str]:
node_ids = []
for edge in self.graph.edge_mapping.get(node_id, []):
if edge.target_node_id == self.graph.root_node_id:
continue

        # Only follow edges that match the branch_identify or have no run_condition
        if edge.run_condition and edge.run_condition.branch_identify:
            if not branch_identify or edge.run_condition.branch_identify != branch_identify:
                continue

        node_ids.append(edge.target_node_id)
        node_ids.extend(self._fetch_node_ids_in_reachable_branch(edge.target_node_id, branch_identify))
    return node_ids

`
this condition may be useless

if edge.run_condition and edge.run_condition.branch_identify: if not branch_identify or edge.run_condition.branch_identify != branch_identify: continue

before run into _fetch_node_ids_in_reachable_branch, same condition has checked

i try to comment this segemnt, ELSE branch will work and produce stream response

@crazywoola
Copy link
Member

crazywoola commented Mar 7, 2025

I think this should be fixed in 1.0.0

@crazywoola crazywoola added the 🤔 cant-reproduce We can not reproduce it or the information is limited label Mar 7, 2025
@yunzhuqing
Copy link
Author

here is my workflow yaml, maybe can help reporduce it, i try import it into https://cloud.dify.ai, i does not work yet

Can you fix it on 0.15.x, 1.x now has so many bugs
`
app:
description: ''
icon: 🤖
icon_background: '#FFEAD5'
mode: workflow
name: 复杂IF-ELSE工作流
use_icon_as_answer_icon: false
dependencies:

  • current_identifier: null
    type: marketplace
    value:
    marketplace_plugin_unique_identifier: langgenius/openai:0.0.7@11ec0b1909200f62b6ebf2cec1da981a9071d11c1ee0e2ef332ce89bcffa2544
    kind: app
    version: 0.1.5
    workflow:
    conversation_variables: []
    environment_variables: []
    features:
    file_upload:
    allowed_file_extensions:
    - .JPG
    - .JPEG
    - .PNG
    - .GIF
    - .WEBP
    - .SVG
    allowed_file_types:
    - image
    allowed_file_upload_methods:
    - local_file
    - remote_url
    enabled: false
    fileUploadConfig:
    audio_file_size_limit: 50
    batch_count_limit: 5
    file_size_limit: 15
    image_file_size_limit: 5
    video_file_size_limit: 100
    workflow_file_upload_limit: 10
    image:
    enabled: false
    number_limits: 3
    transfer_methods:
    - local_file
    - remote_url
    number_limits: 3
    opening_statement: ''
    retriever_resource:
    enabled: true
    sensitive_word_avoidance:
    enabled: false
    speech_to_text:
    enabled: false
    suggested_questions: []
    suggested_questions_after_answer:
    enabled: false
    text_to_speech:
    enabled: false
    language: ''
    voice: ''
    graph:
    edges:
    • data:
      isInIteration: false
      sourceType: llm
      targetType: end
      id: 1741079850797-source-1741079855710-target
      source: '1741079850797'
      sourceHandle: source
      target: '1741079855710'
      targetHandle: target
      type: custom
      zIndex: 0
    • data:
      isInIteration: false
      sourceType: variable-aggregator
      targetType: llm
      id: 1741093509560-source-1741079850797-target
      source: '1741093509560'
      sourceHandle: source
      target: '1741079850797'
      targetHandle: target
      type: custom
      zIndex: 0
    • data:
      isInIteration: false
      sourceType: start
      targetType: if-else
      id: 1740992702922-source-1741178641430-target
      source: '1740992702922'
      sourceHandle: source
      target: '1741178641430'
      targetHandle: target
      type: custom
      zIndex: 0
    • data:
      isInIteration: false
      sourceType: if-else
      targetType: code
      id: 1741178641430-true-1741178777224-target
      source: '1741178641430'
      sourceHandle: 'true'
      target: '1741178777224'
      targetHandle: target
      type: custom
      zIndex: 0
    • data:
      isInIteration: false
      sourceType: code
      targetType: if-else
      id: 1741178841840-source-1741251811883-target
      source: '1741178841840'
      sourceHandle: source
      target: '1741251811883'
      targetHandle: target
      type: custom
      zIndex: 0
    • data:
      isInIteration: false
      sourceType: if-else
      targetType: variable-aggregator
      id: 1741251811883-true-1741093509560-target
      selected: false
      source: '1741251811883'
      sourceHandle: 'true'
      target: '1741093509560'
      targetHandle: target
      type: custom
      zIndex: 0
    • data:
      isInIteration: false
      sourceType: code
      targetType: if-else
      id: 1741178777224-source-1741251865690-target
      source: '1741178777224'
      sourceHandle: source
      target: '1741251865690'
      targetHandle: target
      type: custom
      zIndex: 0
    • data:
      isInIteration: false
      sourceType: if-else
      targetType: variable-aggregator
      id: 1741251865690-true-1741093509560-target
      selected: false
      source: '1741251865690'
      sourceHandle: 'true'
      target: '1741093509560'
      targetHandle: target
      type: custom
      zIndex: 0
    • data:
      isInIteration: false
      sourceType: if-else
      targetType: code
      id: 1741178641430-2320a209-47cc-4779-9aca-6c9c7ca3da8a-1741178841840-target
      source: '1741178641430'
      sourceHandle: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
      target: '1741178841840'
      targetHandle: target
      type: custom
      zIndex: 0
      nodes:
    • data:
      desc: ''
      selected: false
      title: 开始
      type: start
      variables:
      • label: query
        max_length: 48
        options: []
        required: true
        type: text-input
        variable: query
        height: 89
        id: '1740992702922'
        position:
        x: 30
        y: 287
        positionAbsolute:
        x: 30
        y: 287
        selected: false
        sourcePosition: right
        targetPosition: left
        type: custom
        width: 243
    • data:
      context:
      enabled: false
      variable_selector: []
      desc: ''
      model:
      completion_params:
      temperature: 0.7
      mode: chat
      name: gpt-4o-mini
      provider: langgenius/openai/openai
      prompt_template:
      • id: 2fbc7ba7-c14d-4fd7-b951-705db4341cee
        role: system
        text: 你是一个小助手, 协助用户解答问题。
      • id: 86073a3b-bb02-48d2-90e6-272af7fda3f0
        role: user
        text: '{{#1741093509560.output#}}'
        selected: false
        title: LLM
        type: llm
        variables: []
        vision:
        enabled: false
        height: 89
        id: '1741079850797'
        position:
        x: 1762.8571428571422
        y: 495.57142857142867
        positionAbsolute:
        x: 1762.8571428571422
        y: 495.57142857142867
        selected: false
        sourcePosition: right
        targetPosition: left
        type: custom
        width: 243
    • data:
      desc: ''
      outputs:
      • value_selector:
        • '1741079850797'
        • text
          variable: text
          selected: false
          title: 结束
          type: end
          height: 89
          id: '1741079855710'
          position:
          x: 2171.5603164922986
          y: 512.7142857142858
          positionAbsolute:
          x: 2171.5603164922986
          y: 512.7142857142858
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      desc: ''
      output_type: string
      selected: false
      title: 变量聚合器
      type: variable-aggregator
      variables:
        • '1741178777224'
        • result
        • '1741178841840'
        • result
          height: 128
          id: '1741093509560'
          position:
          x: 1306
          y: 475.57142857142867
          positionAbsolute:
          x: 1306
          y: 475.57142857142867
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      cases:
      • case_id: 'true'
        conditions:
        • comparison_operator: contains
          id: 3a674dba-945a-48f1-8c49-0c2858f5d742
          value: test1
          varType: string
          variable_selector:
          • '1740992702922'
          • query
            id: 'true'
            logical_operator: and
      • case_id: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
        conditions:
        • comparison_operator: contains
          id: dd227bb2-5a0f-4567-945d-9777eee34a87
          value: test2
          varType: string
          variable_selector:
          • '1740992702922'
          • query
            id: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支
            type: if-else
            height: 173
            id: '1741178641430'
            position:
            x: 334
            y: 287
            positionAbsolute:
            x: 334
            y: 287
            selected: false
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
    • data:
      code: "\ndef main(arg1: str) -> dict:\n return {\n "result": arg1
      \ + "是一个测试用例,测试用例的编写规范是啥,推荐一些常用的规范",\n }\n"
      code_language: python3
      desc: 代码执行
      outputs:
      result:
      children: null
      type: string
      selected: false
      title: code1
      type: code
      variables:
      • value_selector:
        • '1740992702922'
        • query
          variable: arg1
          height: 81
          id: '1741178777224'
          position:
          x: 629.4285714285714
          y: 194.42857142857136
          positionAbsolute:
          x: 629.4285714285714
          y: 194.42857142857136
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      code: "\ndef main(arg1: str) -> dict:\n return {\n "result": arg1
      \ + "是一个linux 命令,linux 常用命令有哪些",\n }\n"
      code_language: python3
      desc: ''
      outputs:
      result:
      children: null
      type: string
      selected: false
      title: code2
      type: code
      variables:
      • value_selector:
        • '1740992702922'
        • query
          variable: arg1
          height: 53
          id: '1741178841840'
          position:
          x: 603.7142857142857
          y: 756.7142857142858
          positionAbsolute:
          x: 603.7142857142857
          y: 756.7142857142858
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      cases:
      • case_id: 'true'
        conditions:
        • comparison_operator: contains
          id: bb7f6b2d-a8b5-4675-be8c-b192b49bf90e
          value: 命令
          varType: string
          variable_selector:
          • '1741178841840'
          • result
            id: 'true'
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支 2
            type: if-else
            height: 125
            id: '1741251811883'
            position:
            x: 957.7142857142856
            y: 715.5714285714287
            positionAbsolute:
            x: 957.7142857142856
            y: 715.5714285714287
            selected: true
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
    • data:
      cases:
      • case_id: 'true'
        conditions:
        • comparison_operator: contains
          id: 708308cc-3d5e-4695-8c71-22c3ab00068d
          value: 规范
          varType: string
          variable_selector:
          • '1741178777224'
          • result
            id: 'true'
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支 4
            type: if-else
            height: 125
            id: '1741251865690'
            position:
            x: 946.2857142857142
            y: 186.99999999999997
            positionAbsolute:
            x: 946.2857142857142
            y: 186.99999999999997
            selected: false
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
            viewport:
            x: 118.85777845539099
            y: 37.45000000000002
            zoom: 0.7

`

@Nov1c444
Copy link
Collaborator

Nov1c444 commented Mar 7, 2025

here is my workflow yaml, maybe can help reporduce it, i try import it into https://cloud.dify.ai, i does not work yet

Can you fix it on 0.15.x, 1.x now has so many bugs ` app: description: '' icon: 🤖 icon_background: '#FFEAD5' mode: workflow name: 复杂IF-ELSE工作流 use_icon_as_answer_icon: false dependencies:

  • current_identifier: null
    type: marketplace
    value:
    marketplace_plugin_unique_identifier: langgenius/openai:0.0.7@11ec0b1909200f62b6ebf2cec1da981a9071d11c1ee0e2ef332ce89bcffa2544
    kind: app
    version: 0.1.5
    workflow:
    conversation_variables: []
    environment_variables: []
    features:
    file_upload:
    allowed_file_extensions:

    • .JPG
    • .JPEG
    • .PNG
    • .GIF
    • .WEBP
    • .SVG
      allowed_file_types:
    • image
      allowed_file_upload_methods:
    • local_file
    • remote_url
      enabled: false
      fileUploadConfig:
      audio_file_size_limit: 50
      batch_count_limit: 5
      file_size_limit: 15
      image_file_size_limit: 5
      video_file_size_limit: 100
      workflow_file_upload_limit: 10
      image:
      enabled: false
      number_limits: 3
      transfer_methods:
    • local_file
    • remote_url
      number_limits: 3
      opening_statement: ''
      retriever_resource:
      enabled: true
      sensitive_word_avoidance:
      enabled: false
      speech_to_text:
      enabled: false
      suggested_questions: []
      suggested_questions_after_answer:
      enabled: false
      text_to_speech:
      enabled: false
      language: ''
      voice: ''
      graph:
      edges:
    • data:
      isInIteration: false
      sourceType: llm
      targetType: end
      id: 1741079850797-source-1741079855710-target
      source: '1741079850797'
      sourceHandle: source
      target: '1741079855710'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: variable-aggregator
      targetType: llm
      id: 1741093509560-source-1741079850797-target
      source: '1741093509560'
      sourceHandle: source
      target: '1741079850797'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: start
      targetType: if-else
      id: 1740992702922-source-1741178641430-target
      source: '1740992702922'
      sourceHandle: source
      target: '1741178641430'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: code
      id: 1741178641430-true-1741178777224-target
      source: '1741178641430'
      sourceHandle: 'true'
      target: '1741178777224'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: code
      targetType: if-else
      id: 1741178841840-source-1741251811883-target
      source: '1741178841840'
      sourceHandle: source
      target: '1741251811883'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: variable-aggregator
      id: 1741251811883-true-1741093509560-target
      selected: false
      source: '1741251811883'
      sourceHandle: 'true'
      target: '1741093509560'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: code
      targetType: if-else
      id: 1741178777224-source-1741251865690-target
      source: '1741178777224'
      sourceHandle: source
      target: '1741251865690'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: variable-aggregator
      id: 1741251865690-true-1741093509560-target
      selected: false
      source: '1741251865690'
      sourceHandle: 'true'
      target: '1741093509560'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: code
      id: 1741178641430-2320a209-47cc-4779-9aca-6c9c7ca3da8a-1741178841840-target
      source: '1741178641430'
      sourceHandle: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
      target: '1741178841840'
      targetHandle: target
      type: custom
      zIndex: 0
      nodes:

    • data:
      desc: ''
      selected: false
      title: 开始
      type: start
      variables:

      • label: query
        max_length: 48
        options: []
        required: true
        type: text-input
        variable: query
        height: 89
        id: '1740992702922'
        position:
        x: 30
        y: 287
        positionAbsolute:
        x: 30
        y: 287
        selected: false
        sourcePosition: right
        targetPosition: left
        type: custom
        width: 243
    • data:
      context:
      enabled: false
      variable_selector: []
      desc: ''
      model:
      completion_params:
      temperature: 0.7
      mode: chat
      name: gpt-4o-mini
      provider: langgenius/openai/openai
      prompt_template:

      • id: 2fbc7ba7-c14d-4fd7-b951-705db4341cee
        role: system
        text: 你是一个小助手, 协助用户解答问题。
      • id: 86073a3b-bb02-48d2-90e6-272af7fda3f0
        role: user
        text: '{{#1741093509560.output#}}'
        selected: false
        title: LLM
        type: llm
        variables: []
        vision:
        enabled: false
        height: 89
        id: '1741079850797'
        position:
        x: 1762.8571428571422
        y: 495.57142857142867
        positionAbsolute:
        x: 1762.8571428571422
        y: 495.57142857142867
        selected: false
        sourcePosition: right
        targetPosition: left
        type: custom
        width: 243
    • data:
      desc: ''
      outputs:

      • value_selector:

        • '1741079850797'
        • text
          variable: text
          selected: false
          title: 结束
          type: end
          height: 89
          id: '1741079855710'
          position:
          x: 2171.5603164922986
          y: 512.7142857142858
          positionAbsolute:
          x: 2171.5603164922986
          y: 512.7142857142858
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      desc: ''
      output_type: string
      selected: false
      title: 变量聚合器
      type: variable-aggregator
      variables:

        • '1741178777224'
        • result
        • '1741178841840'
        • result
          height: 128
          id: '1741093509560'
          position:
          x: 1306
          y: 475.57142857142867
          positionAbsolute:
          x: 1306
          y: 475.57142857142867
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: 3a674dba-945a-48f1-8c49-0c2858f5d742
          value: test1
          varType: string
          variable_selector:

          • '1740992702922'
          • query
            id: 'true'
            logical_operator: and
      • case_id: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
        conditions:

        • comparison_operator: contains
          id: dd227bb2-5a0f-4567-945d-9777eee34a87
          value: test2
          varType: string
          variable_selector:

          • '1740992702922'
          • query
            id: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支
            type: if-else
            height: 173
            id: '1741178641430'
            position:
            x: 334
            y: 287
            positionAbsolute:
            x: 334
            y: 287
            selected: false
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
    • data:
      code: "\ndef main(arg1: str) -> dict:\n return {\n "result": arg1
      \ + "是一个测试用例,测试用例的编写规范是啥,推荐一些常用的规范",\n }\n"
      code_language: python3
      desc: 代码执行
      outputs:
      result:
      children: null
      type: string
      selected: false
      title: code1
      type: code
      variables:

      • value_selector:

        • '1740992702922'
        • query
          variable: arg1
          height: 81
          id: '1741178777224'
          position:
          x: 629.4285714285714
          y: 194.42857142857136
          positionAbsolute:
          x: 629.4285714285714
          y: 194.42857142857136
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      code: "\ndef main(arg1: str) -> dict:\n return {\n "result": arg1
      \ + "是一个linux 命令,linux 常用命令有哪些",\n }\n"
      code_language: python3
      desc: ''
      outputs:
      result:
      children: null
      type: string
      selected: false
      title: code2
      type: code
      variables:

      • value_selector:

        • '1740992702922'
        • query
          variable: arg1
          height: 53
          id: '1741178841840'
          position:
          x: 603.7142857142857
          y: 756.7142857142858
          positionAbsolute:
          x: 603.7142857142857
          y: 756.7142857142858
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: bb7f6b2d-a8b5-4675-be8c-b192b49bf90e
          value: 命令
          varType: string
          variable_selector:

          • '1741178841840'
          • result
            id: 'true'
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支 2
            type: if-else
            height: 125
            id: '1741251811883'
            position:
            x: 957.7142857142856
            y: 715.5714285714287
            positionAbsolute:
            x: 957.7142857142856
            y: 715.5714285714287
            selected: true
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: 708308cc-3d5e-4695-8c71-22c3ab00068d
          value: 规范
          varType: string
          variable_selector:

          • '1741178777224'
          • result
            id: 'true'
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支 4
            type: if-else
            height: 125
            id: '1741251865690'
            position:
            x: 946.2857142857142
            y: 186.99999999999997
            positionAbsolute:
            x: 946.2857142857142
            y: 186.99999999999997
            selected: false
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
            viewport:
            x: 118.85777845539099
            y: 37.45000000000002
            zoom: 0.7

`

I could get the stream output successfully.

Image

@yunzhuqing
Copy link
Author

here is my workflow yaml, maybe can help reporduce it, i try import it into https://cloud.dify.ai, i does not work yet
Can you fix it on 0.15.x, 1.x now has so many bugs ` app: description: '' icon: 🤖 icon_background: '#FFEAD5' mode: workflow name: 复杂IF-ELSE工作流 use_icon_as_answer_icon: false dependencies:

  • current_identifier: null
    type: marketplace
    value:
    marketplace_plugin_unique_identifier: langgenius/openai:0.0.7@11ec0b1909200f62b6ebf2cec1da981a9071d11c1ee0e2ef332ce89bcffa2544
    kind: app
    version: 0.1.5
    workflow:
    conversation_variables: []
    environment_variables: []
    features:
    file_upload:
    allowed_file_extensions:

    • .JPG

    • .JPEG

    • .PNG

    • .GIF

    • .WEBP

    • .SVG
      allowed_file_types:

    • image
      allowed_file_upload_methods:

    • local_file

    • remote_url
      enabled: false
      fileUploadConfig:
      audio_file_size_limit: 50
      batch_count_limit: 5
      file_size_limit: 15
      image_file_size_limit: 5
      video_file_size_limit: 100
      workflow_file_upload_limit: 10
      image:
      enabled: false
      number_limits: 3
      transfer_methods:

    • local_file

    • remote_url
      number_limits: 3
      opening_statement: ''
      retriever_resource:
      enabled: true
      sensitive_word_avoidance:
      enabled: false
      speech_to_text:
      enabled: false
      suggested_questions: []
      suggested_questions_after_answer:
      enabled: false
      text_to_speech:
      enabled: false
      language: ''
      voice: ''
      graph:
      edges:

    • data:
      isInIteration: false
      sourceType: llm
      targetType: end
      id: 1741079850797-source-1741079855710-target
      source: '1741079850797'
      sourceHandle: source
      target: '1741079855710'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: variable-aggregator
      targetType: llm
      id: 1741093509560-source-1741079850797-target
      source: '1741093509560'
      sourceHandle: source
      target: '1741079850797'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: start
      targetType: if-else
      id: 1740992702922-source-1741178641430-target
      source: '1740992702922'
      sourceHandle: source
      target: '1741178641430'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: code
      id: 1741178641430-true-1741178777224-target
      source: '1741178641430'
      sourceHandle: 'true'
      target: '1741178777224'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: code
      targetType: if-else
      id: 1741178841840-source-1741251811883-target
      source: '1741178841840'
      sourceHandle: source
      target: '1741251811883'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: variable-aggregator
      id: 1741251811883-true-1741093509560-target
      selected: false
      source: '1741251811883'
      sourceHandle: 'true'
      target: '1741093509560'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: code
      targetType: if-else
      id: 1741178777224-source-1741251865690-target
      source: '1741178777224'
      sourceHandle: source
      target: '1741251865690'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: variable-aggregator
      id: 1741251865690-true-1741093509560-target
      selected: false
      source: '1741251865690'
      sourceHandle: 'true'
      target: '1741093509560'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: code
      id: 1741178641430-2320a209-47cc-4779-9aca-6c9c7ca3da8a-1741178841840-target
      source: '1741178641430'
      sourceHandle: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
      target: '1741178841840'
      targetHandle: target
      type: custom
      zIndex: 0
      nodes:

    • data:
      desc: ''
      selected: false
      title: 开始
      type: start
      variables:

      • label: query
        max_length: 48
        options: []
        required: true
        type: text-input
        variable: query
        height: 89
        id: '1740992702922'
        position:
        x: 30
        y: 287
        positionAbsolute:
        x: 30
        y: 287
        selected: false
        sourcePosition: right
        targetPosition: left
        type: custom
        width: 243
    • data:
      context:
      enabled: false
      variable_selector: []
      desc: ''
      model:
      completion_params:
      temperature: 0.7
      mode: chat
      name: gpt-4o-mini
      provider: langgenius/openai/openai
      prompt_template:

      • id: 2fbc7ba7-c14d-4fd7-b951-705db4341cee
        role: system
        text: 你是一个小助手, 协助用户解答问题。
      • id: 86073a3b-bb02-48d2-90e6-272af7fda3f0
        role: user
        text: '{{#1741093509560.output#}}'
        selected: false
        title: LLM
        type: llm
        variables: []
        vision:
        enabled: false
        height: 89
        id: '1741079850797'
        position:
        x: 1762.8571428571422
        y: 495.57142857142867
        positionAbsolute:
        x: 1762.8571428571422
        y: 495.57142857142867
        selected: false
        sourcePosition: right
        targetPosition: left
        type: custom
        width: 243
    • data:
      desc: ''
      outputs:

      • value_selector:

        • '1741079850797'
        • text
          variable: text
          selected: false
          title: 结束
          type: end
          height: 89
          id: '1741079855710'
          position:
          x: 2171.5603164922986
          y: 512.7142857142858
          positionAbsolute:
          x: 2171.5603164922986
          y: 512.7142857142858
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      desc: ''
      output_type: string
      selected: false
      title: 变量聚合器
      type: variable-aggregator
      variables:

        • '1741178777224'
        • result
        • '1741178841840'
        • result
          height: 128
          id: '1741093509560'
          position:
          x: 1306
          y: 475.57142857142867
          positionAbsolute:
          x: 1306
          y: 475.57142857142867
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: 3a674dba-945a-48f1-8c49-0c2858f5d742
          value: test1
          varType: string
          variable_selector:

          • '1740992702922'
          • query
            id: 'true'
            logical_operator: and
      • case_id: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
        conditions:

        • comparison_operator: contains
          id: dd227bb2-5a0f-4567-945d-9777eee34a87
          value: test2
          varType: string
          variable_selector:

          • '1740992702922'
          • query
            id: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支
            type: if-else
            height: 173
            id: '1741178641430'
            position:
            x: 334
            y: 287
            positionAbsolute:
            x: 334
            y: 287
            selected: false
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
    • data:
      code: "\ndef main(arg1: str) -> dict:\n return {\n "result": arg1
      \ + "是一个测试用例,测试用例的编写规范是啥,推荐一些常用的规范",\n }\n"
      code_language: python3
      desc: 代码执行
      outputs:
      result:
      children: null
      type: string
      selected: false
      title: code1
      type: code
      variables:

      • value_selector:

        • '1740992702922'
        • query
          variable: arg1
          height: 81
          id: '1741178777224'
          position:
          x: 629.4285714285714
          y: 194.42857142857136
          positionAbsolute:
          x: 629.4285714285714
          y: 194.42857142857136
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      code: "\ndef main(arg1: str) -> dict:\n return {\n "result": arg1
      \ + "是一个linux 命令,linux 常用命令有哪些",\n }\n"
      code_language: python3
      desc: ''
      outputs:
      result:
      children: null
      type: string
      selected: false
      title: code2
      type: code
      variables:

      • value_selector:

        • '1740992702922'
        • query
          variable: arg1
          height: 53
          id: '1741178841840'
          position:
          x: 603.7142857142857
          y: 756.7142857142858
          positionAbsolute:
          x: 603.7142857142857
          y: 756.7142857142858
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: bb7f6b2d-a8b5-4675-be8c-b192b49bf90e
          value: 命令
          varType: string
          variable_selector:

          • '1741178841840'
          • result
            id: 'true'
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支 2
            type: if-else
            height: 125
            id: '1741251811883'
            position:
            x: 957.7142857142856
            y: 715.5714285714287
            positionAbsolute:
            x: 957.7142857142856
            y: 715.5714285714287
            selected: true
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: 708308cc-3d5e-4695-8c71-22c3ab00068d
          value: 规范
          varType: string
          variable_selector:

          • '1741178777224'
          • result
            id: 'true'
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支 4
            type: if-else
            height: 125
            id: '1741251865690'
            position:
            x: 946.2857142857142
            y: 186.99999999999997
            positionAbsolute:
            x: 946.2857142857142
            y: 186.99999999999997
            selected: false
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
            viewport:
            x: 118.85777845539099
            y: 37.45000000000002
            zoom: 0.7

`

I could get the stream output successfully.

Image

here is my workflow yaml, maybe can help reporduce it, i try import it into https://cloud.dify.ai, i does not work yet
Can you fix it on 0.15.x, 1.x now has so many bugs ` app: description: '' icon: 🤖 icon_background: '#FFEAD5' mode: workflow name: 复杂IF-ELSE工作流 use_icon_as_answer_icon: false dependencies:

  • current_identifier: null
    type: marketplace
    value:
    marketplace_plugin_unique_identifier: langgenius/openai:0.0.7@11ec0b1909200f62b6ebf2cec1da981a9071d11c1ee0e2ef332ce89bcffa2544
    kind: app
    version: 0.1.5
    workflow:
    conversation_variables: []
    environment_variables: []
    features:
    file_upload:
    allowed_file_extensions:

    • .JPG

    • .JPEG

    • .PNG

    • .GIF

    • .WEBP

    • .SVG
      allowed_file_types:

    • image
      allowed_file_upload_methods:

    • local_file

    • remote_url
      enabled: false
      fileUploadConfig:
      audio_file_size_limit: 50
      batch_count_limit: 5
      file_size_limit: 15
      image_file_size_limit: 5
      video_file_size_limit: 100
      workflow_file_upload_limit: 10
      image:
      enabled: false
      number_limits: 3
      transfer_methods:

    • local_file

    • remote_url
      number_limits: 3
      opening_statement: ''
      retriever_resource:
      enabled: true
      sensitive_word_avoidance:
      enabled: false
      speech_to_text:
      enabled: false
      suggested_questions: []
      suggested_questions_after_answer:
      enabled: false
      text_to_speech:
      enabled: false
      language: ''
      voice: ''
      graph:
      edges:

    • data:
      isInIteration: false
      sourceType: llm
      targetType: end
      id: 1741079850797-source-1741079855710-target
      source: '1741079850797'
      sourceHandle: source
      target: '1741079855710'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: variable-aggregator
      targetType: llm
      id: 1741093509560-source-1741079850797-target
      source: '1741093509560'
      sourceHandle: source
      target: '1741079850797'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: start
      targetType: if-else
      id: 1740992702922-source-1741178641430-target
      source: '1740992702922'
      sourceHandle: source
      target: '1741178641430'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: code
      id: 1741178641430-true-1741178777224-target
      source: '1741178641430'
      sourceHandle: 'true'
      target: '1741178777224'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: code
      targetType: if-else
      id: 1741178841840-source-1741251811883-target
      source: '1741178841840'
      sourceHandle: source
      target: '1741251811883'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: variable-aggregator
      id: 1741251811883-true-1741093509560-target
      selected: false
      source: '1741251811883'
      sourceHandle: 'true'
      target: '1741093509560'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: code
      targetType: if-else
      id: 1741178777224-source-1741251865690-target
      source: '1741178777224'
      sourceHandle: source
      target: '1741251865690'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: variable-aggregator
      id: 1741251865690-true-1741093509560-target
      selected: false
      source: '1741251865690'
      sourceHandle: 'true'
      target: '1741093509560'
      targetHandle: target
      type: custom
      zIndex: 0

    • data:
      isInIteration: false
      sourceType: if-else
      targetType: code
      id: 1741178641430-2320a209-47cc-4779-9aca-6c9c7ca3da8a-1741178841840-target
      source: '1741178641430'
      sourceHandle: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
      target: '1741178841840'
      targetHandle: target
      type: custom
      zIndex: 0
      nodes:

    • data:
      desc: ''
      selected: false
      title: 开始
      type: start
      variables:

      • label: query
        max_length: 48
        options: []
        required: true
        type: text-input
        variable: query
        height: 89
        id: '1740992702922'
        position:
        x: 30
        y: 287
        positionAbsolute:
        x: 30
        y: 287
        selected: false
        sourcePosition: right
        targetPosition: left
        type: custom
        width: 243
    • data:
      context:
      enabled: false
      variable_selector: []
      desc: ''
      model:
      completion_params:
      temperature: 0.7
      mode: chat
      name: gpt-4o-mini
      provider: langgenius/openai/openai
      prompt_template:

      • id: 2fbc7ba7-c14d-4fd7-b951-705db4341cee
        role: system
        text: 你是一个小助手, 协助用户解答问题。
      • id: 86073a3b-bb02-48d2-90e6-272af7fda3f0
        role: user
        text: '{{#1741093509560.output#}}'
        selected: false
        title: LLM
        type: llm
        variables: []
        vision:
        enabled: false
        height: 89
        id: '1741079850797'
        position:
        x: 1762.8571428571422
        y: 495.57142857142867
        positionAbsolute:
        x: 1762.8571428571422
        y: 495.57142857142867
        selected: false
        sourcePosition: right
        targetPosition: left
        type: custom
        width: 243
    • data:
      desc: ''
      outputs:

      • value_selector:

        • '1741079850797'
        • text
          variable: text
          selected: false
          title: 结束
          type: end
          height: 89
          id: '1741079855710'
          position:
          x: 2171.5603164922986
          y: 512.7142857142858
          positionAbsolute:
          x: 2171.5603164922986
          y: 512.7142857142858
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      desc: ''
      output_type: string
      selected: false
      title: 变量聚合器
      type: variable-aggregator
      variables:

        • '1741178777224'
        • result
        • '1741178841840'
        • result
          height: 128
          id: '1741093509560'
          position:
          x: 1306
          y: 475.57142857142867
          positionAbsolute:
          x: 1306
          y: 475.57142857142867
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: 3a674dba-945a-48f1-8c49-0c2858f5d742
          value: test1
          varType: string
          variable_selector:

          • '1740992702922'
          • query
            id: 'true'
            logical_operator: and
      • case_id: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
        conditions:

        • comparison_operator: contains
          id: dd227bb2-5a0f-4567-945d-9777eee34a87
          value: test2
          varType: string
          variable_selector:

          • '1740992702922'
          • query
            id: 2320a209-47cc-4779-9aca-6c9c7ca3da8a
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支
            type: if-else
            height: 173
            id: '1741178641430'
            position:
            x: 334
            y: 287
            positionAbsolute:
            x: 334
            y: 287
            selected: false
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
    • data:
      code: "\ndef main(arg1: str) -> dict:\n return {\n "result": arg1
      \ + "是一个测试用例,测试用例的编写规范是啥,推荐一些常用的规范",\n }\n"
      code_language: python3
      desc: 代码执行
      outputs:
      result:
      children: null
      type: string
      selected: false
      title: code1
      type: code
      variables:

      • value_selector:

        • '1740992702922'
        • query
          variable: arg1
          height: 81
          id: '1741178777224'
          position:
          x: 629.4285714285714
          y: 194.42857142857136
          positionAbsolute:
          x: 629.4285714285714
          y: 194.42857142857136
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      code: "\ndef main(arg1: str) -> dict:\n return {\n "result": arg1
      \ + "是一个linux 命令,linux 常用命令有哪些",\n }\n"
      code_language: python3
      desc: ''
      outputs:
      result:
      children: null
      type: string
      selected: false
      title: code2
      type: code
      variables:

      • value_selector:

        • '1740992702922'
        • query
          variable: arg1
          height: 53
          id: '1741178841840'
          position:
          x: 603.7142857142857
          y: 756.7142857142858
          positionAbsolute:
          x: 603.7142857142857
          y: 756.7142857142858
          selected: false
          sourcePosition: right
          targetPosition: left
          type: custom
          width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: bb7f6b2d-a8b5-4675-be8c-b192b49bf90e
          value: 命令
          varType: string
          variable_selector:

          • '1741178841840'
          • result
            id: 'true'
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支 2
            type: if-else
            height: 125
            id: '1741251811883'
            position:
            x: 957.7142857142856
            y: 715.5714285714287
            positionAbsolute:
            x: 957.7142857142856
            y: 715.5714285714287
            selected: true
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
    • data:
      cases:

      • case_id: 'true'
        conditions:

        • comparison_operator: contains
          id: 708308cc-3d5e-4695-8c71-22c3ab00068d
          value: 规范
          varType: string
          variable_selector:

          • '1741178777224'
          • result
            id: 'true'
            logical_operator: and
            desc: ''
            selected: false
            title: 条件分支 4
            type: if-else
            height: 125
            id: '1741251865690'
            position:
            x: 946.2857142857142
            y: 186.99999999999997
            positionAbsolute:
            x: 946.2857142857142
            y: 186.99999999999997
            selected: false
            sourcePosition: right
            targetPosition: left
            type: custom
            width: 243
            viewport:
            x: 118.85777845539099
            y: 37.45000000000002
            zoom: 0.7

`

I could get the stream output successfully.

Image

you should define two branch as below
Image
single IF-ELSE works, because branch_identify is always true;

second branch only product one text stream

@Nov1c444
Copy link
Collaborator

Nov1c444 commented Mar 7, 2025

#14065 I understand now. There was a missing edge when exporting the DSL. You can try this PR, which has fixed this issue.

@yunzhuqing
Copy link
Author

#14065 I understand now. There was a missing edge when exporting the DSL. You can try this PR, which has fixed this issue.

i try it , but it also does not work

Image

Image

@Nov1c444
Copy link
Collaborator

#14065我现在明白了。导出 DSL 时缺少一个边缘。您可以尝试此 PR,它已修复此问题。

我试过了,但还是不行

Image

Image

It seems there's missing code in the previous if block. You can copy and replace the entire file directly.

@yunzhuqing
Copy link
Author

#14065我现在明白了。导出 DSL 时缺少一个边缘。您可以尝试此 PR,它已修复此问题。

我试过了,但还是不行
Image
Image

It seems there's missing code in the previous if block. You can copy and replace the entire file directly.

i copied it, but the bug alse exists, it seems they are two different questions

@Nov1c444
Copy link
Collaborator

#14065我现在明白了。导出 DSL 时缺少一个边缘。您可以尝试此 PR,它已修复此问题。

我试过了,但还是不行
Image
Image

It seems there's missing code in the previous if block. You can copy and replace the entire file directly.

i copied it, but the bug alse exists, it seems they are two different questions

Uhh, this is indeed another issue. I misunderstood your meaning. I'll fix it as soon as possible.

@Kain-90
Copy link

Kain-90 commented Mar 10, 2025

same to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 cant-reproduce We can not reproduce it or the information is limited 🌊 feat:workflow Workflow related stuff.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants