Dialogue State Tracker¶
The tracker stores and maintains the state of the dialogue with a single user. It is stored in a tracker store, retrieved when incoming messages for the conversation are received and updated after actions have been executed
Here we go:
- 
class 
rasa_core.trackers.DialogueStateTracker(sender_id, slots, max_event_history=None)[source]¶ Bases:
objectMaintains 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
- 
applied_events() → List[rasa_core.events.Event][source]¶ Returns all actions that should be applied - w/o reverted events.
- 
as_dialogue()[source]¶ Return a
Dialogueobject containing all of the turns.This can be serialised and later used to recover the state of this tracker exactly.
- 
current_state(event_verbosity: rasa_core.trackers.EventVerbosity = <EventVerbosity.NONE: 1>) → Dict[str, Any][source]¶ Return the current tracker state as an object.
- 
export_stories(e2e=False) → str[source]¶ Dump the tracker as a story in the Rasa Core story format.
Returns the dumped tracker as a string.
- 
export_stories_to_file(export_path: str = 'debug.md') → None[source]¶ Dump the tracker as a story to a file.
- 
classmethod 
from_dict(sender_id: str, events_as_dict: List[Dict[str, Any]], slots: List[rasa_core.slots.Slot], max_event_history: Optional[int] = None) → rasa_core.trackers.DialogueStateTracker[source]¶ 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.
- 
classmethod 
from_events(sender_id: str, evts: List[rasa_core.events.Event], slots: List[rasa_core.slots.Slot], max_event_history: Optional[int] = None)[source]¶ 
- 
generate_all_prior_trackers()[source]¶ Returns a generator of the previous trackers of this tracker.
The resulting array is representing the trackers before each action.
- 
get_last_event_for(event_type: Type[rasa_core.events.Event], action_names_to_exclude: List[str] = None, skip: int = 0) → Optional[rasa_core.events.Event][source]¶ Gets the last event of a given type which was actually applied.
- Args:
 event_type: The type of event you want to find. action_names_to_exclude: Events of type ActionExecuted which
should be excluded from the results. Can be used to skip action_listen events.skip: Skips n possible results before return an event.
- Returns:
 - event which matched the query or None if no event matched.
 
- 
get_latest_entity_values(entity_type: str) → Iterator[str][source]¶ Get entity values found for the passed entity name in latest msg.
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.
- 
get_latest_input_channel() → Optional[str][source]¶ Get the name of the input_channel of the latest UserUttered event
- 
idx_after_latest_restart()[source]¶ Return the idx of the most recent restart in the list of events.
If the conversation has not been restarted,
0is returned.
- 
last_executed_action_has(name: str, skip=0) → bool[source]¶ Returns whether last ActionExecuted event had a specific name.
- Args:
 - 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.
 
- 
past_states(domain: Domain) → collections.deque[source]¶ Generate the past states of this tracker based on the history.
- 
recreate_from_dialogue(dialogue: rasa_core.conversation.Dialogue) → None[source]¶ 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.
- 
set_latest_action_name(action_name: str) → None[source]¶ Set latest action name and reset form validation and rejection parameters
- 
travel_back_in_time(target_time: float) → rasa_core.trackers.DialogueStateTracker[source]¶ 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.
-