rasa.core.trackers
EventVerbosity Objects
Filter on which events to include in tracker dumps.
AnySlotDict Objects
A slot dictionary that pretends every slot exists, by creating slots on demand.
This only uses the generic slot type! This means certain functionality wont work, e.g. properly featurizing the slot.
DialogueStateTracker Objects
Maintains the state of a conversation.
The field max_event_history will only give you these last events, it can be set in the tracker_store
from_dict
Create a tracker from dump.
The dump should be an array of dumped events. When restoring the tracker, these events will be replayed to recreate the state.
__init__
Initialize the tracker.
A set of events can be stored externally, and we will run through all of them to get the current state. The tracker will represent all the information we captured while processing messages of the dialogue.
current_state
Return the current tracker state as an object.
past_states
Generate the past states of this tracker based on the history.
Arguments:
domain
- a :class:rasa.core.domain.Domain
Returns:
a list of states
change_loop_to
Set the currently active loop.
Arguments:
loop_name
- The name of loop which should be marked as active.
set_form_validation
Toggle form validation
reject_action
Notify active loop that it was rejected
set_latest_action
Set latest action name and reset form validation and rejection parameters
current_slot_values
Return the currently set values of the slots
get_slot
Retrieves the value of a slot.
get_latest_entity_values
Get entity values found for the passed entity type and optional role and group in latest message.
If you are only interested in the first entity of a given type use
next(tracker.get_latest_entity_values("my_entity_name"), None)
.
If no entity is found None
is the default result.
Arguments:
entity_type
- the entity type of interestentity_role
- optional entity role of interestentity_group
- optional entity group of interest
Returns:
Entity values.
get_latest_input_channel
Get the name of the input_channel of the latest UserUttered event
is_paused
State whether the tracker is currently paused.
idx_after_latest_restart
Return the idx of the most recent restart in the list of events.
If the conversation has not been restarted, 0
is returned.
events_after_latest_restart
Return a list of events after the most recent restart.
init_copy
Creates a new state tracker with the same initial values.
generate_all_prior_trackers
Returns a generator of the previous trackers of this tracker.
The resulting array is representing the trackers before each action.
applied_events
Returns all actions that should be applied - w/o reverted events.
replay_events
Update the tracker based on a list of events.
recreate_from_dialogue
Use a serialised Dialogue
to update the trackers state.
This uses the state as is persisted in a TrackerStore
. If the
tracker is blank before calling this method, the final state will be
identical to the tracker from which the dialogue was created.
copy
Creates a duplicate of this tracker
travel_back_in_time
Creates a new tracker with a state at a specific timestamp.
A new tracker will be created and all events previous to the passed time stamp will be replayed. Events that occur exactly at the target time will be included.
as_dialogue
Return a Dialogue
object containing all of the turns.
This can be serialised and later used to recover the state of this tracker exactly.
update
Modify the state of the tracker according to an Event
.
as_story
Dump the tracker as a story in the Rasa Core story format.
Returns the dumped tracker as a string.
export_stories
Dump the tracker as a story in the Rasa Core story format.
Returns:
The dumped tracker as a string.
export_stories_to_file
Dump the tracker as a story to a file.
get_last_event_for
Gets the last event of a given type which was actually applied.
Arguments:
event_type
- The type of event you want to find.action_names_to_exclude
- Events of typeActionExecuted
which should be excluded from the results. Can be used to skipaction_listen
events.skip
- Skips n possible results before return an event.event_verbosity
- WhichEventVerbosity
should be used to search for events.
Returns:
event which matched the query or None
if no event matched.
last_executed_action_has
Returns whether last ActionExecuted
event had a specific name.
Arguments:
name
- Name of the event which should be matched.skip
- Skips n possible results in between.
Returns:
True
if last executed action had name name
, otherwise False
.
trigger_followup_action
Triggers another action following the execution of the current.
clear_followup_action
Clears follow up action when it was executed.
active_loop_name
Get the name of the currently active loop.
Returns: None
if no active loop or the name of the currently active loop.
latest_action_name
Get the name of the previously executed action or text of e2e action.
Returns: name of the previously executed action or text of e2e action
get_active_loop_name
Get the name of current active loop.
Arguments:
state
- The state from which the name of active loop should be extracted
Returns:
the name of active loop or None
is_prev_action_listen_in_state
Check if action_listen is the previous executed action.
Arguments:
state
- The state for which the check should be performed
Returns:
boolean value indicating whether action_listen is previous action