Conditions#
Conditions are one of the most important components of the dialog graph. They determine the possibility of transition from one node of the graph to another. The conditions are used to specify when a particular transition should occur, based on certain criteria. This module contains a standard set of scripting conditions that can be used to control the flow of a conversation. These conditions can be used to check the current context, the user’s input, or other factors that may affect the conversation flow.
- exact_match(match, skip_none=True)[source]#
Return function handler. This handler returns True only if the last user phrase is the same Message as the
match
. Ifskip_none
the handler will not compare None fields ofmatch
.
- regexp(pattern, flags=0)[source]#
Return function handler. This handler returns True only if the last user phrase contains
pattern
withflags
.
- check_cond_seq(cond_seq)[source]#
Check if the list consists only of Callables.
- Parameters:
cond_seq (
list
) – List of conditions to check.
- _any(iterable, /)#
_any is an alias for any.
- _all(iterable, /)#
_all is an alias for all.
- aggregate(cond_seq, aggregate_func=<built-in function any>)[source]#
Aggregate multiple functions into one by using aggregating function.
- any(cond_seq)[source]#
Return function handler. This handler returns True if any function from the list is True.
- all(cond_seq)[source]#
Return function handler. This handler returns True only if all functions from the list are True.
- negation(condition)[source]#
Return function handler. This handler returns negation of the
condition()
: False ifcondition()
holds True and returns True otherwise.
- has_last_labels(flow_labels=None, labels=None, last_n_indices=1)[source]#
Return condition handler. This handler returns True if any label from last
last_n_indices
context labels is in theflow_labels
list or in theNodeLabel2Type
list.- Parameters:
flow_labels (
Optional
[List
[str
]]) – List of labels to check. Every label has type str. Empty if not set.labels (
Optional
[List
[Tuple
[str
,str
]]]) – List of labels corresponding to the nodes. Empty if not set.last_n_indices (
int
) – Number of last utterances to check.
- Return type:
- agg(cond_seq, aggregate_func=<built-in function any>)#
agg()
is an alias foraggregate()
.
- neg(condition)#
neg()
is an alias fornegation()
.