transition_builder#
- class besser.agent.core.transition.transition_builder.TransitionBuilder(source, event=None, condition=None)[source]#
Bases:
object
A transition builder.
This class is used to build agent transitions, allowing for a “fluent api” syntax where consecutive calls can be made on the same object.
- Parameters:
- go_to(dest)[source]#
Set the destination state of the transition.
Completes the transition builder and effectively adds the source state.
- Parameters:
dest (State) – the destination state
- with_condition(function, params=None)[source]#
Adds a condition to the transition builder.
- Parameters:
function (Union[Callable[[Session], bool], Callable[[Session, dict], bool]]) – the condition function to add to the transition. Allowed function arguments are (
Session
) or (Session
, dict) to add parameters within the dict argument. The function must return a boolean valueparams (dict, optional) – the parameters for the condition function, necessary if the function has (
Session
, dict) arguments
- Returns:
the transition builder with the new condition added
- Return type: