langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
51.76k stars 7.5k forks source link

The chatbot workflow returns answers containing other branches #10564

Open LarchLiu opened 4 days ago

LarchLiu commented 4 days ago

Self Checks

Dify version

v0.11.1

Cloud or Self Hosted

Cloud, Self Hosted (Docker)

Steps to reproduce

dify-bug As shown in the diagram above, when input class b is entered, it outputs Class AClass B. The answers from other branches are also outputted together. Based on my tests, the output is correct if there is no Variable Aggregator node.

P.S v0.10.1 is ok even with Variable Aggregator node.

Test

Workflow DSL ``` app: description: '' icon: 🤖 icon_background: '#FFEAD5' mode: advanced-chat name: test use_icon_as_answer_icon: false kind: app version: 0.1.3 workflow: conversation_variables: - description: '' id: 603c742e-24c3-4081-aed5-bb8d1ce36a7a name: str value: '' value_type: string 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: 10 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: false 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: start targetType: if-else id: 1731334661852-source-1731334672471-target source: '1731334661852' sourceHandle: source target: '1731334672471' targetHandle: target type: custom zIndex: 0 - data: isInIteration: false sourceType: if-else targetType: question-classifier id: 1731334672471-false-1731335916748-target source: '1731334672471' sourceHandle: 'false' target: '1731335916748' targetHandle: target type: custom zIndex: 0 - data: isInIteration: false sourceType: question-classifier targetType: answer id: 1731335916748-2-1731334706164-target source: '1731335916748' sourceHandle: '2' target: '1731334706164' targetHandle: target type: custom zIndex: 0 - data: isInIteration: false sourceType: question-classifier targetType: assigner id: 1731335916748-1-1731336197596-target source: '1731335916748' sourceHandle: '1' target: '1731336197596' targetHandle: target type: custom zIndex: 0 - data: isInIteration: false sourceType: assigner targetType: answer id: 1731336197596-source-answer-target source: '1731336197596' sourceHandle: source target: answer targetHandle: target type: custom zIndex: 0 - data: isInIteration: false sourceType: if-else targetType: assigner id: 1731334672471-true-1731336197596-target source: '1731334672471' sourceHandle: 'true' target: '1731336197596' targetHandle: target type: custom zIndex: 0 nodes: - data: desc: '' selected: false title: Start type: start variables: [] height: 54 id: '1731334661852' position: x: 144.69474430647074 y: 278.27494676871834 positionAbsolute: x: 144.69474430647074 y: 278.27494676871834 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: answer: Class A desc: '' selected: false title: Answer type: answer variables: [] height: 100 id: answer position: x: 790.6938164621216 y: 370.68627082784076 positionAbsolute: x: 790.6938164621216 y: 370.68627082784076 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: cases: - case_id: 'true' conditions: - comparison_operator: contains id: 8bad7a47-1ea2-4eb0-8dd4-83da2228aefe value: class a varType: string variable_selector: - sys - query id: 'true' logical_operator: and desc: '' selected: false title: 'IF/ELSE ' type: if-else height: 126 id: '1731334672471' position: x: 144.69474430647074 y: 424.79370719913084 positionAbsolute: x: 144.69474430647074 y: 424.79370719913084 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: answer: Class B desc: '' selected: false title: Answer 2 type: answer variables: [] height: 100 id: '1731334706164' position: x: 543.5986187871038 y: 739.7625740921067 positionAbsolute: x: 543.5986187871038 y: 739.7625740921067 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: classes: - id: '1' name: class A - id: '2' name: class B desc: '' instructions: '' model: completion_params: temperature: 0.7 mode: chat name: gpt-3.5-turbo provider: openai query_variable_selector: - '1731334661852' - sys.query selected: false title: 'Question Classifier ' topics: [] type: question-classifier vision: enabled: false height: 176 id: '1731335916748' position: x: 144.69474430647074 y: 656.5697185934825 positionAbsolute: x: 144.69474430647074 y: 656.5697185934825 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: assigned_variable_selector: - conversation - str desc: '' input_variable_selector: - sys - query selected: true title: Variable Aggregator type: assigner write_mode: over-write height: 132 id: '1731336197596' position: x: 511.314824115996 y: 347.09426702972354 positionAbsolute: x: 511.314824115996 y: 347.09426702972354 selected: true sourcePosition: right targetPosition: left type: custom width: 244 viewport: x: -68.04491865859256 y: -74.0413060355445 zoom: 0.8053576187333558 ```

✔️ Expected Behavior

Just return Class B

❌ Actual Behavior

The output is Class AClass B

dosubot[bot] commented 4 days ago

@LarchLiu Hello there! I'm here to help you with bug fixes, answer your questions, and assist you in becoming a contributor. Let me know how I can assist you today!

The issue you're experiencing seems to be related to the behavior of the Variable Aggregator node in Dify version v0.11.1. In this version, the Variable Aggregator node might be concatenating outputs from different branches, which is why you're seeing Class AClass B instead of just Class B. This behavior differs from version v0.10.1, where the output was correct even with the Variable Aggregator node.

The Variable Aggregator node is designed to aggregate variables from multiple branches into a single variable for unified configuration in downstream nodes. However, it can only aggregate variables of the same data type, and it seems that in your case, it is concatenating string outputs from different branches [1].

To resolve this, you might need to adjust the configuration of the Variable Aggregator node or consider an alternative approach to handle the outputs from different branches to ensure only the desired output is returned.

To continue talking to Dosu, mention @dosu.