-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated stop flow action for multiflow stories * Added and Updated Test Cases
- Loading branch information
1 parent
27f819d
commit cbf8303
Showing
23 changed files
with
1,576 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from typing import List, Text, Any, Union | ||
from collections import OrderedDict | ||
|
||
from rasa.shared.core.training_data.story_writer.yaml_story_writer import YAMLStoryWriter | ||
from rasa.shared.core.training_data.structures import StoryStep | ||
from rasa.shared.core.events import Event | ||
|
||
|
||
from rasa.shared.core.training_data.story_reader.yaml_story_reader import KEY_STORY_NAME, KEY_STEPS | ||
|
||
|
||
class kaironYAMLStoryWriter(YAMLStoryWriter): | ||
"""Custom YAML Story Writer with overridden _filter_event function.""" | ||
|
||
def process_story_step(self, story_step: StoryStep) -> OrderedDict: | ||
"""Converts a single story step into an ordered dict with a custom filter.""" | ||
result: OrderedDict[Text, Any] = OrderedDict() | ||
result[KEY_STORY_NAME] = story_step.block_name | ||
steps = self.process_checkpoints(story_step.start_checkpoints) | ||
for event in story_step.events: | ||
if not self._filter_event(event): | ||
continue | ||
processed = self.process_event(event) | ||
if processed: | ||
steps.append(processed) | ||
|
||
steps.extend(self.process_checkpoints(story_step.end_checkpoints)) | ||
|
||
result[KEY_STEPS] = steps | ||
|
||
return result | ||
|
||
@staticmethod | ||
def _filter_event(event: Union["Event", List["Event"]]) -> bool: | ||
"""Identifies if the event should be converted/written. | ||
Args: | ||
event: target event to check. | ||
Returns: | ||
`True` if the event should be converted/written, `False` otherwise. | ||
""" | ||
if isinstance(event, list): | ||
return True | ||
|
||
return ( | ||
not StoryStep.is_action_unlikely_intent(event) | ||
and not StoryStep.is_action_session_start(event) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.