base_events#

class besser.agent.library.transition.events.base_events.DummyEvent[source]#

Bases: Event

Represents a placeholder event.

_abc_impl = <_abc._abc_data object>#
class besser.agent.library.transition.events.base_events.ReceiveFileEvent(file=None, session_id=None, human=True)[source]#

Bases: Event

Event for receiving files.

Parameters:
  • file (File) – the received file

  • session_id (str) – the id of the session the event was sent to (can be none)

  • human (bool) – indicates if the sender is human. Defaults to True

file#

the received file

Type:

File

human#

indicates if the sender is human. Defaults to True

Type:

bool

_abc_impl = <_abc._abc_data object>#
class besser.agent.library.transition.events.base_events.ReceiveJSONEvent(payload=None, session_id=None, human=False)[source]#

Bases: ReceiveMessageEvent

Event for receiving JSON messages.

Parameters:
  • payload (dict) – the received message content

  • session_id (str) – the id of the session the event was sent to (can be none)

  • human (bool) – indicates if the sender is human. Defaults to False

_name#

the name of the event

Type:

str

_abc_impl = <_abc._abc_data object>#
class besser.agent.library.transition.events.base_events.ReceiveMessageEvent(message=None, session_id=None, human=True)[source]#

Bases: Event

Base event for receiving messages.

Parameters:
  • message (str) – the received message content

  • session_id (str) – the id of the session the event was sent to (can be none)

  • human (bool) – indicates if the sender is human. Defaults to True

message#

the received message content

Type:

str

human#

indicates if the sender is human. Defaults to True

Type:

bool

_abc_impl = <_abc._abc_data object>#
static create_event_from(message=None, session=None, human=True)[source]#

Creates an event from a received message, determining if it’s JSON or text.

Parameters:
  • message (str) – the received message content

  • session (Session) – the current session

  • human (bool) – indicates if the sender is human. Defaults to True

Returns:

a specific event instance based on message type.

Return type:

ReceiveMessageEvent

is_matching(event)[source]#

Check whether an event matches another one.

This function can be overridden. Default behavior only checks if the event names are equal.

Parameters:

event (Event) – the target event to compare

Returns:

true if both events match, false otherwise

Return type:

bool

class besser.agent.library.transition.events.base_events.ReceiveTextEvent(text=None, session_id=None, human=False)[source]#

Bases: ReceiveMessageEvent

Event for receiving text messages. Supports intent prediction.

Parameters:
  • text (str) – the received message content

  • session_id (str) – the id of the session the event was sent to (can be none)

  • human (bool) – indicates if the sender is human. Defaults to True

_name#

the name of the event

Type:

str

predicted_intent#

the predicted intent for the event message

Type:

IntentClassifierPrediction

_abc_impl = <_abc._abc_data object>#
log()[source]#

Create a log message for the event.

This function can be overridden. Default message is the event name

Returns:

the log message

Return type:

str

predict_intent(session)[source]#

Predict the intent of the event message, only if it has not been done yet or if the session moved to another agent state.

Parameters:

session (Session) – the user session

class besser.agent.library.transition.events.base_events.WildcardEvent[source]#

Bases: Event

Wildcard event. Can be used to match any event in a transition.

_abc_impl = <_abc._abc_data object>#
is_matching(event)[source]#

Check whether an event matches another one.

Parameters:

event (Event) – the target event to compare

Returns:

always true

Return type:

bool