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

[Component Bug] Conditional Router(If-Else in 1.1.0) Cannot Stop Correctly #4590

Open
ChunJen opened this issue Nov 14, 2024 · 4 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@ChunJen
Copy link

ChunJen commented Nov 14, 2024

Bug Description

I change the conditional Router with self.stop('method_name'), but the components of the subsequent process will still be executed.
It happened in both of version 1.0.17 and 1.1.0

    def true_response(self) -> Message:
        result = self.evaluate_condition(self.input_text, self.match_text, self.operator, self.case_sensitive)
        if result:
            return self.message
        else:
            self.stop('true_response')

With the workflow:

[python 3.12.3, langflow 1.0.17]

20241114_debug_conditional_router.json
20241114_debug_conditional_router_v2.json

Test Case

1.input=A, expected_output=A, real_output=A None None

image

2.input=B, expected_output=B, real_output=None B None

  • in this situation will cause 2 user messages to be generated

image

[python 3.12.3, langflow 1.1.0]

Still not work in this version:
20241114_debug_conditional_router_v2_使用langflow1.1.0版本.json

Reproduction

  1. upload the json
  2. try the input with playground

Expected behavior

Just like in Bug Description

Who can help?

No response

Operating System

Windows 11

Langflow Version

1.0.17

Python Version

3.12

Screenshot

No response

Flow File

20241114_debug_conditional_router_v2.json
20241114_debug_conditional_router.json
20241114_debug_conditional_router_v2_使用langflow1.1.0版本.json

@ChunJen ChunJen added the bug Something isn't working label Nov 14, 2024
Copy link

dosubot bot commented Nov 14, 2024

The issue you're experiencing with the Conditional Router component not stopping correctly when using self.stop('method_name') might be related to how the stop function is implemented and how it interacts with the workflow execution. The stop function is supposed to halt a specific branch of the workflow by marking it as "INACTIVE" in the graph. However, if subsequent components are still being executed, it suggests that the stop command might not be effectively preventing further execution in the workflow.

Here are a few things you might want to check or try:

  1. Ensure Correct Output Name: Make sure that the output_name you are passing to self.stop() matches the actual output name in your workflow. If the name is incorrect, the stop command might not be applied to the intended branch.

  2. Check Workflow Configuration: Verify that the workflow configuration correctly reflects the intended logic and that there are no additional paths or conditions that might lead to the execution of subsequent components.

  3. Debugging: Add logging or print statements before and after the self.stop() call to ensure that the function is being executed and to check the state of the workflow at that point.

  4. Review Changes Between Versions: Since the issue persists across versions 1.0.17 and 1.1.0, review any changes in the implementation of the Conditional Router or related components that might affect the stop functionality.

If these steps do not resolve the issue, it might require a deeper investigation into the codebase to understand how the stop command is processed and why it might not be affecting the workflow as expected.

To continue talking to Dosu, mention @dosu.

@irshadmb
Copy link
Contributor

Following changes will help you.
def true_response(self) -> Message: result = self.evaluate_condition(self.input_text, self.match_text, self.operator, self.case_sensitive) if result: return self.message else: self.stop('true_response') return ""

image
20241114_debug_conditional_router_v3.json

@ChunJen
Copy link
Author

ChunJen commented Nov 14, 2024

@irshadmb Hi thanks for respones!
It is kinda a way to make it return nothing with "".

However, it is just a simplified flow here, so i still need one solution to make this happend.
Because the prompt here, it represented a whole SubFlow.

image

Is it possible in Langflow?

20241114_debug_conditional_router_v4_needsolution.json

@edwinjosechittilappilly
Copy link
Collaborator

PR #3904
#3904

Please review this PR and test the multi-conditional router, see if it fits your scenario.

Let us know if it resolves the issue. If it does, we will consider adding an enhanced version of the multi-conditional router to the components in the upcoming release.

cc. @carlosrcoelho @jordanrfrazier ref: Multiconditional router

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants