Conditions#

The conditions module contains functions that can be used to determine whether the pipeline component to which they are attached should be executed or not. The standard set of them allows user to setup dependencies between pipeline components.

always_start_condition(_, __)[source]#

Condition that always allows service execution. It’s the default condition for all services.

Parameters:
  • _ – Current dialog context.

  • __ – Pipeline.

Return type:

bool

service_successful_condition(path=None)[source]#

Condition that allows service execution, only if the other service was executed successfully. Returns StartConditionCheckerFunction.

Parameters:

path (Optional[str]) – The path of the condition pipeline component.

Return type:

Callable[[Context, Pipeline], bool]

not_condition(func)[source]#

Condition that returns opposite boolean value to the one returned by incoming function. Returns StartConditionCheckerFunction.

Parameters:

func (Callable[[Context, Pipeline], bool]) – The function to return opposite of.

Return type:

Callable[[Context, Pipeline], bool]

aggregate_condition(aggregator, *functions)[source]#

Condition that returns aggregated boolean value from all booleans returned by incoming functions. Returns StartConditionCheckerFunction.

Parameters:
  • aggregator (Callable[[Iterable[bool]], bool]) – The function that accepts list of booleans and returns a single boolean.

  • functions (Callable[[Context, Pipeline], bool]) – Functions to aggregate.

Return type:

Callable[[Context, Pipeline], bool]

all_condition(*functions)[source]#

Condition that returns True only if all incoming functions return True. Returns StartConditionCheckerFunction.

Parameters:

functions (Callable[[Context, Pipeline], bool]) – Functions to aggregate.

Return type:

Callable[[Context, Pipeline], bool]

any_condition(*functions)[source]#

Condition that returns True if any of incoming functions returns True. Returns StartConditionCheckerFunction.

Parameters:

functions (Callable[[Context, Pipeline], bool]) – Functions to aggregate.

Return type:

Callable[[Context, Pipeline], bool]