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
37.74k stars 5.12k forks source link

Tools inside Iteration node gives false error on iteration items. #4766

Closed AndyMik90 closed 1 day ago

AndyMik90 commented 1 month ago

Self Checks

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.

dosubot[bot] commented 1 month ago

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.