def _process_step( self, step: StoryStep, incoming_trackers: List[TrackerWithCachedStates] ) -> TrackersTuple: """Processes a steps events with all trackers. The trackers that reached the steps starting checkpoint will be used to process the events. Collects and returns training data while processing the story step.""" events = step.explicit_events(self.domain) trackers = [] if events: # small optimization # need to copy the tracker as multiple story steps # might start with the same checkpoint and all of them # will use the same set of incoming trackers for tracker in incoming_trackers: # sender id is used to be able for a human to see where the # messages and events for this tracker came from - to do this # we concatenate the story block names of the blocks that # contribute to the trackers events if tracker.sender_id: if step.block_name not in tracker.sender_id.split(" > "): new_sender = tracker.sender_id + " > " + step.block_name else: new_sender = tracker.sender_id else: new_sender = step.block_name trackers.append(tracker.copy(new_sender, step.source_name)) end_trackers = [] for event in events: for tracker in trackers: if isinstance( event, (ActionReverted, UserUtteranceReverted, Restarted) ): end_trackers.append(tracker.copy(tracker.sender_id)) if step.is_rule: # The rules can specify that a form or a slot shouldn't be set, # therefore we need to distinguish between not set # and explicitly set to None if isinstance(event, ActiveLoop) and event.name is None: event.name = SHOULD_NOT_BE_SET if isinstance(event, SlotSet) and event.value is None: event.value = SHOULD_NOT_BE_SET tracker.update(event) # end trackers should be returned separately # to avoid using them for augmentation return trackers, end_trackers
def _process_step( self, step: StoryStep, incoming_trackers: List[TrackerWithCachedStates]) -> TrackersTuple: """Processes a steps events with all trackers. The trackers that reached the steps starting checkpoint will be used to process the events. Collects and returns training data while processing the story step.""" events = step.explicit_events(self.domain) trackers = [] if events: # small optimization # need to copy the tracker as multiple story steps # might start with the same checkpoint and all of them # will use the same set of incoming trackers for tracker in incoming_trackers: # sender id is used to be able for a human to see where the # messages and events for this tracker came from - to do this # we concatenate the story block names of the blocks that # contribute to the trackers events if tracker.sender_id: if step.block_name not in tracker.sender_id.split(" > "): new_sender = tracker.sender_id + " > " + step.block_name else: new_sender = tracker.sender_id else: new_sender = step.block_name trackers.append( tracker.copy(new_sender, tracker.request_id, tracker.user_id)) end_trackers = [] for event in events: for tracker in trackers: if isinstance( event, (ActionReverted, UserUtteranceReverted, Restarted)): end_trackers.append( tracker.copy(tracker.sender_id, tracker.request_id, tracker.user_id)) tracker.update(event) # end trackers should be returned separately # to avoid using them for augmentation return trackers, end_trackers