Node - #condition#script
- For Xmind ChatTree, the first line of the node content must be "#condition#script", and then the content of the second line is a Python expression script that returns a bool value (it can also be divided into multiple lines for beautiful writing / the system will automatically splice it into one line / the InfoItem can be accessed based on
ctxin the script), such as:#condition#script
...
...ctx["{...}"]...
... - For Python ChatTree, the first parameter of chattree.create_node() must be "#condition#script", the key in the second parameter dict is "function", and the value is the Python function name or lambda expression that returns a bool value (the function definition or lambda must have a
ctxparameter and can access the InfoItem based onctx), such as:def xxxx_func(ctx):
...
ctx["{...}"] = "..."
...
return ... # return bool value
xxx_node = chattree.create_node("#condition#script", {"function": xxxx_func})xxx_node = chattree.create_node("#condition#script", {"function": lambda ctx : ...ctx["{...}"]...}) - This Python expression script or Python function that returns a bool value can realize conditional judgment of complex logic.
- The descendant nodes of the "#condition#script" node will be executed only when the result is True after the script or function is executed.
- For more information, see "Python Script/Function"
- "TMC_book_flights" and "911" ChatTree examples in "ChatTree Examples" have this node