rasa.shared.core.events
deserialise_events
Convert a list of dictionaries to a list of corresponding events.
Example format: [{"event": "slot", "value": 5, "name": "my_slot"}]
format_message
Uses NLU parser information to generate a message with inline entity annotations.
Arguments:
text
- text of the messageintent
- intent of the messageentities
- entities of the message
Returns:
Message with entities annotated inline, e.g.
I am from [Berlin]{
"entity
":
"city
"}
.
split_events
Splits events according to an event type and condition.
Examples:
Splitting events according to the event type ActionExecuted
and the
action_name
'action_session_start' would look as follows:
>> _events = split_events( events, ActionExecuted,
{"action_name"
- "action_session_start"}, True )
Arguments:
events
- Events to split.event_type_to_split_on
- The event type to split on.additional_splitting_conditions
- Additional event attributes to split on.include_splitting_event
- Whether the events of the type on which the split is based should be included in the returned events.
Returns:
The split events.
do_events_begin_with_session_start
Determines whether events
begins with a session start sequence.
A session start sequence is a sequence of two events: an executed
action_session_start
as well as a logged session_started
.
Arguments:
events
- The events to inspect.
Returns:
Whether events
begins with a session start sequence.
remove_parse_data
Reduce event details to the minimum necessary to be structlogged.
Deletes the parse_data key from the event if it exists.
Arguments:
event
- The event to be reduced.
Returns:
A reduced copy of the event.
Event Objects
Describes events in conversation and how the affect the conversation state.
Immutable representation of everything which happened during a conversation of the
user with the assistant. Tells the rasa.shared.core.trackers.DialogueStateTracker
how to update its state as the events occur.
as_story_string
Returns the event as story string.
Returns:
textual representation of the event or None.
fingerprint
Returns a unique hash for the event which is stable across python runs.
Returns:
fingerprint of the event
resolve_by_type
Returns a slots class by its type name.
apply_to
Applies event to current conversation state.
Arguments:
tracker
- The current conversation state.
__eq__
Compares object with other object.
__str__
Returns text representation of event.
AlwaysEqualEventMixin Objects
Class to deduplicate common behavior for events without additional attributes.
__eq__
Compares object with other object.
SkipEventInMDStoryMixin Objects
Skips the visualization of an event in Markdown stories.
as_story_string
Returns the event as story string.
Returns:
None, as this event should not appear inside the story.
UserUttered Objects
The user has said something to the bot.
As a side effect a new Turn
will be created in the Tracker
.
__init__
Creates event for incoming user message.
Arguments:
text
- Text of user message.intent
- Intent prediction of user message.entities
- Extracted entities.parse_data
- Detailed NLU parsing result for message.timestamp
- When the event was created.metadata
- Additional event metadata.input_channel
- Which channel the user used to send message.message_id
- Unique ID for message.use_text_for_featurization
-True
if the message's text was used to predict next action.intent
0 if the message's intent was used.
__hash__
Returns unique hash of object.
intent_name
Returns intent name or None
if no intent.
full_retrieval_intent_name
Returns full retrieval intent name or None
if no retrieval intent.
__eq__
Compares object with other object.
__str__
Returns text representation of event.
__repr__
Returns text representation of event for debugging.
as_sub_state
Turns a UserUttered event into features.
The substate contains information about entities, intent and text of the
UserUttered
event.
Returns:
a dictionary with intent name, text and entities
as_story_string
Return event as string for Markdown training format.
Arguments:
e2e
-True
if the the event should be printed in the format for end-to-end conversation tests.
Returns:
Event as string.
apply_to
Applies event to tracker. See docstring of Event
.
DefinePrevUserUtteredFeaturization Objects
Stores information whether action was predicted based on text or intent.
__init__
Creates event.
Arguments:
use_text_for_featurization
-True
if message text was used to predict action.False
if intent was used.timestamp
- When the event was created.metadata
- Additional event metadata.
__str__
Returns text representation of event.
__hash__
Returns unique hash for event.
as_dict
Returns serialized event.
apply_to
Applies event to current conversation state.
Arguments:
tracker
- The current conversation state.
__eq__
Compares object with other object.
EntitiesAdded Objects
Event that is used to add extracted entities to the tracker state.
__init__
Initializes event.
Arguments:
entities
- Entities extracted from previous user message. This can either be done by NLU components or end-to-end policy predictions.timestamp
- the timestampmetadata
- some optional metadata
__str__
Returns the string representation of the event.
__hash__
Returns the hash value of the event.
__eq__
Compares this event with another event.
as_dict
Converts the event into a dict.
Returns:
A dict that represents this event.
apply_to
Applies event to current conversation state.
Arguments:
tracker
- The current conversation state.
BotUttered Objects
The bot has said something to the user.
This class is not used in the story training as it is contained in the
ActionExecuted
class. An entry is made in the Tracker
.
__init__
Creates event for a bot response.
Arguments:
text
- Plain text which bot responded with.data
- Additional data for more complex utterances (e.g. buttons).timestamp
- When the event was created.metadata
- Additional event metadata.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
__str__
Returns text representation of event.
__repr__
Returns text representation of event for debugging.
apply_to
Applies event to current conversation state.
message
Return the complete message as a dictionary.
empty
Creates an empty bot utterance.
as_dict
Returns serialized event.
SlotSet Objects
The user has specified their preference for the value of a slot
.
Every slot has a name and a value. This event can be used to set a value for a slot on a conversation.
As a side effect the Tracker
's slots will be updated so
that tracker.slots[key]=value
.
__init__
Creates event to set slot.
Arguments:
key
- Name of the slot which is set.value
- Value to which slot is set.timestamp
- When the event was created.metadata
- Additional event metadata.
__repr__
Returns text representation of event.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
as_story_string
Returns text representation of event.
as_dict
Returns serialized event.
apply_to
Applies event to current conversation state.
Restarted Objects
Conversation should start over & history wiped.
Instead of deleting all events, this event can be used to reset the trackers state (e.g. ignoring any past user messages & resetting all the slots).
__hash__
Returns unique hash for event.
as_story_string
Returns text representation of event.
apply_to
Resets the tracker and triggers a followup ActionSessionStart
.
UserUtteranceReverted Objects
Bot reverts everything until before the most recent user message.
The bot will revert all events after the latest UserUttered
, this
also means that the last event on the tracker is usually action_listen
and the bot is waiting for a new user message.
__hash__
Returns unique hash for event.
as_story_string
Returns text representation of event.
apply_to
Applies event to current conversation state.
AllSlotsReset Objects
All Slots are reset to their initial values.
If you want to keep the dialogue history and only want to reset the slots, you can use this event to set all the slots to their initial values.
__hash__
Returns unique hash for event.
as_story_string
Returns text representation of event.
apply_to
Applies event to current conversation state.
ReminderScheduled Objects
Schedules the asynchronous triggering of a user intent at a given time.
The triggered intent can include entities if needed.
__init__
Creates the reminder.
Arguments:
intent
- Name of the intent to be triggered.trigger_date_time
- Date at which the execution of the action should be triggered (either utc or with tz).name
- ID of the reminder. If there are multiple reminders with the same id only the last will be run.entities
- Entities that should be supplied together with the triggered intent.kill_on_user_message
-True
means a user message before the trigger date will abort the reminder.timestamp
- Creation date of the event.metadata
- Optional event metadata.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
__str__
Returns text representation of event.
as_story_string
Returns text representation of event.
as_dict
Returns serialized event.
ReminderCancelled Objects
Cancel certain jobs.
__init__
Creates a ReminderCancelled event.
If all arguments are None
, this will cancel all reminders.
are to be cancelled. If no arguments are supplied, this will cancel all
reminders.
Arguments:
name
- Name of the reminder to be cancelled.intent
- Intent name that is to be used to identify the reminders to be cancelled.entities
- Entities that are to be used to identify the reminders to be cancelled.timestamp
- Optional timestamp.metadata
- Optional event metadata.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
__str__
Returns text representation of event.
cancels_job_with_name
Determines if this event should cancel the job with the given name.
Arguments:
job_name
- Name of the job to be tested.sender_id
- Thesender_id
of the tracker.
Returns:
True
, if this ReminderCancelled
event should cancel the job with the
given name, and False
otherwise.
as_story_string
Returns text representation of event.
ActionReverted Objects
Bot undoes its last action.
The bot reverts everything until before the most recent action. This includes the action itself, as well as any events that action created, like set slot events - the bot will now predict a new action using the state before the most recent action.
__hash__
Returns unique hash for event.
as_story_string
Returns text representation of event.
apply_to
Applies event to current conversation state.
StoryExported Objects
Story should get dumped to a file.
__init__
Creates event about story exporting.
Arguments:
path
- Path to which story was exported to.timestamp
- When the event was created.metadata
- Additional event metadata.
__hash__
Returns unique hash for event.
as_story_string
Returns text representation of event.
apply_to
Applies event to current conversation state.
__eq__
Compares object with other object.
FollowupAction Objects
Enqueue a followup action.
__init__
Creates an event which forces the model to run a certain action next.
Arguments:
name
- Name of the action to run.timestamp
- When the event was created.metadata
- Additional event metadata.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
__str__
Returns text representation of event.
as_story_string
Returns text representation of event.
as_dict
Returns serialized event.
apply_to
Applies event to current conversation state.
ConversationPaused Objects
Ignore messages from the user to let a human take over.
As a side effect the Tracker
's paused
attribute will
be set to True
.
__hash__
Returns unique hash for event.
as_story_string
Returns text representation of event.
apply_to
Applies event to current conversation state.
ConversationResumed Objects
Bot takes over conversation.
Inverse of PauseConversation
. As a side effect the Tracker
's
paused
attribute will be set to False
.
__hash__
Returns unique hash for event.
as_story_string
Returns text representation of event.
apply_to
Applies event to current conversation state.
ActionExecuted Objects
An operation describes an action taken + its result.
It comprises an action and a list of events. operations will be appended
to the latest Turn`` in
Tracker.turns`.
__init__
Creates event for a successful event execution.
Arguments:
action_name
- Name of the action which was executed.None
if it was an end-to-end prediction.policy
- Policy which predicted action.confidence
- Confidence with which policy predicted action.timestamp
- When the event was created.metadata
- Additional event metadata.action_text
- In case it's an end-to-end action prediction, the text which was predicted.hide_rule_turn
- IfTrue
, this action should be hidden in the dialogue history created for ML-based policies.
__repr__
Returns event as string for debugging.
__str__
Returns event as human readable string.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
as_story_string
Returns event in Markdown format.
as_dict
Returns serialized event.
as_sub_state
Turns ActionExecuted into a dictionary containing action name or action text.
One action cannot have both set at the same time
Returns:
a dictionary containing action name or action text with the corresponding key.
apply_to
Applies event to current conversation state.
AgentUttered Objects
The agent has said something to the user.
This class is not used in the story training as it is contained in the
ActionExecuted
class. An entry is made in the Tracker
.
__init__
See docstring of BotUttered
.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
__str__
Returns text representation of event.
as_dict
Returns serialized event.
ActiveLoop Objects
If name
is given: activates a loop with name
else deactivates active loop.
__init__
Creates event for active loop.
Arguments:
name
- Name of activated loop orNone
if current loop is deactivated.timestamp
- When the event was created.metadata
- Additional event metadata.
__str__
Returns text representation of event.
__repr__
Returns event as string for debugging.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
as_story_string
Returns text representation of event.
as_dict
Returns serialized event.
apply_to
Applies event to current conversation state.
LegacyForm Objects
Legacy handler of old Form
events.
The ActiveLoop
event used to be called Form
. This class is there to handle old
legacy events which were stored with the old type name form
.
as_dict
Returns serialized event.
fingerprint
Returns the hash of the event.
LoopInterrupted Objects
Event added by FormPolicy and RulePolicy.
Notifies form action whether or not to validate the user input.
__init__
Event to notify that loop was interrupted.
This e.g. happens when a user is within a form, and is de-railing the form-filling by asking FAQs.
Arguments:
is_interrupted
-True
if the loop execution was interrupted, and ML policies had to take over the last prediction.timestamp
- When the event was created.metadata
- Additional event metadata.
__str__
Returns text representation of event.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
as_dict
Returns serialized event.
apply_to
Applies event to current conversation state.
LegacyFormValidation Objects
Legacy handler of old FormValidation
events.
The LoopInterrupted
event used to be called FormValidation
. This class is there
to handle old legacy events which were stored with the old type name
form_validation
.
__init__
See parent class docstring.
as_dict
Returns serialized event.
fingerprint
Returns hash of the event.
ActionExecutionRejected Objects
Notify Core that the execution of the action has been rejected.
__init__
Creates event.
Arguments:
action_name
- Action which was rejected.policy
- Policy which predicted the rejected action.confidence
- Confidence with which the reject action was predicted.timestamp
- When the event was created.metadata
- Additional event metadata.
__str__
Returns text representation of event.
__hash__
Returns unique hash for event.
__eq__
Compares object with other object.
as_dict
Returns serialized event.
apply_to
Applies event to current conversation state.
SessionStarted Objects
Mark the beginning of a new conversation session.
__hash__
Returns unique hash for event.
as_story_string
Skips representing event in stories.
apply_to
Applies event to current conversation state.