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
[Feature Request] Achieve dynamic flow connections with logic conditions #386
Comments
Hi @zhanghanduo , with the latest version of vscode and pip package, you can use "activate" feature to support if-else, if "activate" is set, the node will be executed only when activate condition is met. We are preparing a document to show the usage, but not ready yet. |
Thanks for the information 👍. I will check it out. |
Hi @zhanghanduo , you can review the sample flow conditional-flow-for-if-else to understand how to use the |
Hi @PeiwenGaoMS, nice work about adding "activate" and "skip". A comment on the example. In practice, it's more likely to use "activate" when output is NOT None (instead of True/False). This is because if the output value is True/False, then the next component, who takes this output as input, is not getting much information to start with. I think "skip" could be more practical. Another question. If a flow is skipped in the middle, what to do about these flow output that have no value assigned, because part of the flow is not run? |
@PeiwenGaoMS "activate" does not always work. It worked in your example flow, but was not effective in my flow for a LLM node. It runs regardless the target value in activate config is "true" or "false" and always generates output. |
Hi @dunalduck0, Can you create a separate bug issue for the above problem? |
Hi @dunalduck0, {
"is_activate": true,
"valid_info": "...",
} The node's activation config is then set to activate:
when: ${node.output.is_activate}
is: true For your second question, if an input to a node using a python tool references a bypassed node, you should give that input a default value. Btw, we are preparing the doc about activate config. You can take a look, it may solve some of your issues. Thanks. |
@dunalduck0 , Please take a screenshot containing the output of |
Thank you @PeiwenGaoMS on the tip of using dictionary output. I saw it in the document as well and it worked. That's a great feature. Thus, I no longer have the "non_empty_property" node. I didn't know I could set default value for node input too (I know I can for ${inputs}. Will give it a try later. Two feedback:
|
@dunalduck0 Thank you for your feedback. One thing I want to clarify is, the default value refers to the default value of the parameter in the python code. You can check the |
@PeiwenGaoMS This might be related to the original comment, so posting it here. Let's say I want to loop a llm tool over an array of questions, with a separate request for each of them. How do I do that? Or in a more general manner, how do I implement any kind of looping in promptflow? If I try to create a cycle of tools with an activate condition to break out of the loop, I get this error- |
I did loop of embedding inside a python component. I copied the PF code for embedding but changed it to loop. Alternatively, I guess you can wire code to generate flow.diag.yaml programmatically to simulate loop. |
@dunalduck0 Sorry, I didn't mention it earlier, but I'm using VS code extension. How do I copy the equivalent PF code for any tool? |
Yes, I am using VsCode extension too, but I don't know if it matters. In a flow, you can use different tools, such as built-in "LLM" or "Python". They are all based on Python code in this repo. The built-in LLM tool takes in only one prompt. If you want it to take in a list of prompts, you can go to https://github.com/microsoft/promptflow/blob/main/src/promptflow-tools/promptflow/tools/aoai.py, copy the function "chat()", and create a new Python tool with a loop on chat(). But I don't know your question on circle. I've never seen a circle of tools in my life. |
Thanks @dunalduck0, this works 🙇 |
Any updates on this? |
Hi @jaskhalsa, it looks like all the previously mentioned issues have been resolved. Do you have any other questions? If not, can I close this question? |
I've got the same requirements. Indeed, we can add loop/iteration logic to python code. But once we move to us Prompt Flow, we want take advantages of the capabilites.. Looking forward Prompt Flow can provide such functionality. |
@NishitHada Can you share a bit about your solution and use case here? If you loop within a single Python code, then seems like you lose out on being able to control/track the intermediate steps. I'm interested in using planners (e.g., Semantic Kernel's
@nikawang Exactly. If we loop within the Python node we lose most of what Prompt Flow provides (see the article I linked above). But it seems like loops go against the design principles of Prompt Flow--a DAG with loops is no longer a DAG... |
What are your “intermediate steps”? As far as I can see, there is an HTTP call between a textual prompt and an GPT output and there is no intermediate steps. Well, unless I misunderstood the question. |
The LLM nodes are just an HTTP call between a text prompt and LLM output with no intermediate steps, agreed. But here we are talking about a Python node that performs multiple LLM calls via a |
Hi, we're sending this friendly reminder because we haven't heard back from you in 30 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 7 days of this comment, the issue will be automatically closed. Thank you! |
Currently the node construction operates on a rudimentary fixed DAG. Is it possible to incorporate functionalities such as "if-else" and "for-loop" logics and branches (or even directed graph with cycles), to introduce dynamism into the workflow, thereby opening the door to boundless creative possibilities?
The text was updated successfully, but these errors were encountered: