dify icon indicating copy to clipboard operation
dify copied to clipboard

Tools inside Iteration node gives false error on iteration items.

Open AndyMik90 opened this issue 1 year ago • 1 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [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] Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.9

Cloud or Self Hosted

Cloud, Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

When adding tools to the iteration node, the input variable is string (item) and gives a red tooltip that there is an error, but the workflow works as expected.

CleanShot 2024-05-29 at 09 19 20

If you want a workflow to debug on, I can send a DSL file on Discord (username: andremik)

✔️ Expected Behavior

Show that the input from the iteration node is correct.

❌ Actual Behavior

Gives error on string item.

AndyMik90 avatar May 29 '24 07:05 AndyMik90

The Iteration node in Dify version 0.6.9 shows a red tooltip indicating an error when the input variable is a string because it is designed to work with list types. The filterInputVar function only accepts array types, such as VarType.array, VarType.arrayString, VarType.arrayNumber, and VarType.arrayObject. Since a string is not one of these types, it triggers the error tooltip [1].

Additionally, the _run method in the IterationNode class checks if the input variable is a list and raises a ValueError if it is not:

class IterationNode(BaseIterationNode):
    def _run(self, variable_pool: VariablePool) -> BaseIterationState:
        iterator = variable_pool.get_variable_value(cast(IterationNodeData, self.node_data).iterator_selector)

        if not isinstance(iterator, list):
            raise ValueError(f"Invalid iterator value: {iterator}, please provide a list.")
        
        # Additional logic...

To avoid the error tooltip, ensure that the input variable is an array type [2].

Details

About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

dosubot[bot] avatar May 29 '24 07:05 dosubot[bot]