def export_stories(self): from rasa_core.training.structures import StoryStep, Story story_step = StoryStep() for event in self._applied_events(): story_step.add_event(event) story = Story([story_step]) return story.as_story_string(flat=True)
def export_stories(self): # type: () -> Text """Dump the tracker as a story in the Rasa Core story format. Returns the dumped tracker as a string.""" from rasa_core.training.structures import StoryStep, Story story_step = StoryStep() for event in self._applied_events(): story_step.add_event(event) story = Story([story_step]) return story.as_story_string(flat=True)
def _next_story_steps(self): start_checkpoints = self._prev_end_checkpoints() if not start_checkpoints: start_checkpoints = [Checkpoint(STORY_START)] current_turns = [StoryStep(block_name=self.name, start_checkpoint=s) for s in start_checkpoints] return current_turns
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)) 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.update(event) # end trackers should be returned separately # to avoid using them for augmentation return trackers, end_trackers