transition#

class besser.agent.core.transition.transition.Transition(name, source, dest, event, condition)[source]#

Bases: object

An agent transition from one state (source) to another (destination).

A transition can have an event and/or a condition, and will be triggered when the target event (if any) was received and the condition (if any) is satisfied.

Parameters:
  • name (str) – the transition name

  • source (State) – the source state of the transition (from where it is triggered)

  • dest (State) – the destination state of the transition (where the agent moves to)

  • event (Event) – the event that triggers the transition

  • condition (Condition) – the condition that triggers the transition

name#

The transition name

Type:

str

source#

The source state of the transition (from where it is triggered)

Type:

State

event#

The event that triggers the transition

Type:

Event

condition#

The condition that triggers the transition

Type:

Condition

evaluate(session, target_event)[source]#

Evaluate the transition, i.e., check if the transition’s event was received and the transition condition is satisfied.

Parameters:
  • session (Session) – the current user session

  • target_event (Event) – the event to evaluate

Returns:

true if the target event matches the transition event and the transition condition is satisfied, false otherwise

Return type:

bool

is_auto()[source]#

Check if the transition is auto (i.e. no event nor condition linked to it).

Returns:

true if the transition is auto, false otherwise

Return type:

bool

is_condition_true(session)[source]#

Evaluate the transition’s condition.

Parameters:

session (Session) – the current user session

Returns:

true if the transition’s condition is satisfied, false otherwise

Return type:

bool

is_event()[source]#

Check if the transition waits for an event.

Returns:

true if the transition’s event is not None

Return type:

bool

log()[source]#

Create a log message for the transition. Useful when transitioning from one state to another to track the agent state.

Example: receive_message_text (Intent Matching - hello_intent): [initial_state] –> [hello_state]

Returns:

the log message

Return type:

str