dify icon indicating copy to clipboard operation
dify copied to clipboard

Enhance `if_else_node` to Support Jinja for the `Add Condition` Operation

Open hu9029 opened this issue 1 year ago • 3 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.

Currently, conditional expressions do not support extracting and evaluating specific fields from a JSON object, especially when the value is in Chinese. If you need to evaluate a particular field within a JSON object returned from a previous step, this cannot be done with the existing functionality. It would be helpful if Jinja syntax could be supported when adding conditions, allowing for direct extraction and evaluation of fields within a JSON object using Jinja expressions.

2. Additional context or comments

No response

3. Can you help us with this feature?

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

hu9029 avatar Aug 19 '24 03:08 hu9029

Please refer to:

  1. https://docs.dify.ai/guides/workflow/node/template
  2. https://jinja.palletsprojects.com/en/3.1.x/

These resources should help you with the current capabilities and how to use them.

alterxyz avatar Aug 27 '24 00:08 alterxyz

Also can you provide more info regarding your title "Enhance if_else_node to Support Jinja for the Add Condition Operation"?

alterxyz avatar Aug 27 '24 00:08 alterxyz

The conditional branch node currently supports selecting variables for conditional evaluation, but only allows simple comparisons for dict structures. By enabling Jinja syntax in the conditional branch node, users can easily access and compare fields within dict structures. This functionality is similar to the Jinja toggle in LLM nodes, allowing both plain input and Jinja syntax for more flexible conditional logic.

hu9029 avatar Sep 06 '24 10:09 hu9029