langflow icon indicating copy to clipboard operation
langflow copied to clipboard

Conditional Flow

Open puyuanOT opened this issue 9 months ago • 5 comments

Is it possible to create a block that determines which flow to execute based on conditions? For example, execute different flows based on the user's intent.

Screenshot 2024-05-07 at 7 31 46 PM

puyuanOT avatar May 08 '24 01:05 puyuanOT

It seems similar to the contents of this proposal: https://github.com/langflow-ai/langflow/issues/1731

It would be better to implement the function for an LLM to judge and select prompts directly using Langchain's prompt routing. Here is the relevant documentation: https://python.langchain.com/docs/expression_language/how_to/routing/

Implementing prompt routing directly within Langflow could enhance the block coding environment. However, due to the difficulty of fine-tuning, it might be better to utilize Langchain's techniques.

YamonBot avatar May 08 '24 05:05 YamonBot

It seems similar to the contents of this proposal: #1731

It would be better to implement the function for an LLM to judge and select prompts directly using Langchain's prompt routing. Here is the relevant documentation: https://python.langchain.com/docs/expression_language/how_to/routing/

Implementing prompt routing directly within Langflow could enhance the block coding environment. However, due to the difficulty of fine-tuning, it might be better to utilize Langchain's techniques.

Thank you for your response. Is it possible to perform different actions based on various LLM outputs with native langflow? For example, call vector db if the LLM output is vector db and call calendar if the LLM output is calendar. It would be fantastic if there were a way to explicitly execute a specific sequence of actions based on user inputs, like following a decision tree path. This would be especially helpful in scenarios where the action/decision tree is extensive and complex.

image

puyuanOT avatar May 08 '24 05:05 puyuanOT

image

In my opinion, such a division could be adequately replaced by using Langflow's Flow as Tool component.

YamonBot avatar May 08 '24 11:05 YamonBot

Hey all

We have added a feature in the CustomComponent that can fulfill that role even if not ideal yet.

Disclaimer: This is still experimental

The CustomComponent now has a stop method. We have added the TextOperator component that allows you to make a certain branch of your flow stop on its tracks.

The general gist of it is you'll create two branches in your flow one for each class and define the rest of the process for each one. The TextOperator (or whatever other component you define that calls stop) will test the condition and stop or let the flow run.

ogabrielluiz avatar May 08 '24 12:05 ogabrielluiz

Hey all

We have added a feature in the CustomComponent that can fulfill that role even if not ideal yet.

Disclaimer: This is still experimental

The CustomComponent now has a stop method. We have added the TextOperator component that allows you to make a certain branch of your flow stop on its tracks.

The general gist of it is you'll create two branches in your flow one for each class and define the rest of the process for each one. The TextOperator (or whatever other component you define that calls stop) will test the condition and stop or let the flow run.

Wow this is great! I will try it out.

puyuanOT avatar May 08 '24 14:05 puyuanOT

Implementing prompt routing directly within Langflow could enhance the block coding environment. However, due to the difficulty of fine-tuning, it might be better to utilize Langchain's techniques.

Consider that there may be sophisticated but non-dev users of the platform who neither know of or care about LangChain. Specifically, in our product we want to offer a constrained version of LangFlow (with curated and custom task-specific components) to minimize cognitive load.

For instance in a call center environment, the user may want to construct a dialog-tree like flow depending on Entity Recognition (did the agent mention a competitor ?), Sentiment Analysis (does the client think we suck ?).

There should be a component specialized to this scenario (choice among options) . LangFlow, stripped to its basics is really a workflow execution engine, and a branching node would seem fundamental.

ccollie avatar May 23 '24 16:05 ccollie

Prior art: https://rivet.ironcladapp.com/docs/node-reference/if-else

ccollie avatar May 23 '24 16:05 ccollie

Hello there,

This feature is now available in the current version. Please try updating to the latest version.

anovazzi1 avatar Jul 01 '24 17:07 anovazzi1

@anovazzi which component is it called exactly? I went through all of them and couldn't find it

Alex-Poon avatar Jul 01 '24 21:07 Alex-Poon

Hey @Alex-Poon, There is a conditional router component, but you can also adapt any component you have. Now that you can create components with multiple outputs, you can set up conditional paths with them. image

anovazzi1 avatar Jul 02 '24 15:07 anovazzi1

Hi, I am using the conditional router. I want to pass a message for only one of the flows. Is that possible? The next components are Prompt templates, the input is empty on the input message, but it does not prevent the flow to run

httplups avatar Aug 29 '24 18:08 httplups

Hi @httplups, I've had the same problem. Do you have a solution?

MarceloNunesAlves avatar Sep 24 '24 19:09 MarceloNunesAlves

@MarceloNunesAlves I did not :(

httplups avatar Oct 01 '24 14:10 httplups