def test_different_story_order_doesnt_change_nlu_training_data( default_importer: E2EImporter, ): stories = [ StoryStep(events=[ UserUttered(intent={"name": "greet"}), ActionExecuted("utter_greet_from_stories"), ActionExecuted("hi", action_text="hi"), ]), StoryStep(events=[ UserUttered("bye", {"name": "bye"}), ActionExecuted("utter_greet"), ActionExecuted("hi", action_text="hi"), ActionExecuted("bye", action_text="bye"), ]), ] def mocked_stories(*_: Any, **__: Any) -> StoryGraph: return StoryGraph(stories) # Patch to return our test stories default_importer.importer.get_stories = mocked_stories training_data = default_importer.get_nlu_data() # Pretend the order of the stories changed. This should have no # effect on the NLU training data stories = list(reversed(stories)) # Make sure importer doesn't cache stories default_importer._cached_stories = None training_data2 = default_importer.get_nlu_data() assert hash(training_data) == hash(training_data2)
async def test_adding_e2e_actions_to_domain(project: Text): config_path = os.path.join(project, DEFAULT_CONFIG_PATH) domain_path = os.path.join(project, DEFAULT_DOMAIN_PATH) default_data_path = os.path.join(project, DEFAULT_DATA_PATH) existing = TrainingDataImporter.load_from_dict({}, config_path, domain_path, [default_data_path]) additional_actions = ["Hi Joey.", "it's sunny outside."] stories = StoryGraph([ StoryStep(events=[ UserUttered("greet_from_stories", {"name": "greet_from_stories"}), ActionExecuted("utter_greet_from_stories"), ]), StoryStep(events=[ UserUttered("how are you doing?", {"name": "greet_from_stories"}), ActionExecuted(additional_actions[0], action_text=additional_actions[0]), ActionExecuted(additional_actions[1], action_text=additional_actions[1]), ActionExecuted(additional_actions[1], action_text=additional_actions[1]), ]), ]) # Patch to return our test stories existing.get_stories = asyncio.coroutine(lambda *args: stories) importer = E2EImporter(existing) domain = await importer.get_domain() assert all(action_name in domain.action_names for action_name in additional_actions)
def test_adding_e2e_actions_to_domain(default_importer: E2EImporter): additional_actions = ["Hi Joey.", "it's sunny outside."] stories = StoryGraph([ StoryStep(events=[ UserUttered("greet_from_stories", {"name": "greet_from_stories"}), ActionExecuted("utter_greet_from_stories"), ]), StoryStep(events=[ UserUttered("how are you doing?", {"name": "greet_from_stories"}), ActionExecuted(additional_actions[0], action_text=additional_actions[0]), ActionExecuted(additional_actions[1], action_text=additional_actions[1]), ActionExecuted(additional_actions[1], action_text=additional_actions[1]), ]), ]) def mocked_stories(*_: Any, **__: Any) -> StoryGraph: return stories # Patch to return our test stories default_importer.importer.get_stories = mocked_stories domain = default_importer.get_domain() assert all(action_name in domain.action_names_or_texts for action_name in additional_actions)
async def test_without_additional_e2e_examples(tmp_path: Path): domain_path = tmp_path / "domain.yml" domain_path.write_text(Domain.empty().as_yaml()) config_path = tmp_path / "config.yml" config_path.touch() existing = TrainingDataImporter.load_from_dict( {}, str(config_path), str(domain_path), [] ) stories = StoryGraph( [ StoryStep( events=[ UserUttered(None, {"name": "greet_from_stories"}), ActionExecuted("utter_greet_from_stories"), ] ) ] ) # Patch to return our test stories existing.get_stories = asyncio.coroutine(lambda *args: stories) importer = E2EImporter(existing) training_data = await importer.get_nlu_data() assert training_data.training_examples assert not training_data.is_empty() assert len(training_data.nlu_examples) == 0