def test_train_selector(pipeline, component_builder, tmpdir): # use data that include some responses training_data = load_data("data/examples/rasa/demo-rasa.md") training_data_responses = load_data( "data/examples/rasa/demo-rasa-responses.md") training_data = training_data.merge(training_data_responses) nlu_config = RasaNLUModelConfig({"language": "en", "pipeline": pipeline}) trainer = Trainer(nlu_config) trainer.train(training_data) persisted_path = trainer.persist(tmpdir) assert trainer.pipeline loaded = Interpreter.load(persisted_path, component_builder) parsed = loaded.parse("hello") assert loaded.pipeline assert parsed is not None assert (parsed.get("response_selector").get("all_retrieval_intents")) == [ "chitchat" ] assert (parsed.get("response_selector").get("default").get("response").get( "intent_response_key")) is not None assert (parsed.get("response_selector").get("default").get("response").get( "response_templates")) is not None ranking = parsed.get("response_selector").get("default").get("ranking") assert ranking is not None for rank in ranking: assert rank.get("confidence") is not None assert rank.get("intent_response_key") is not None
def test_train_selector(pipeline, component_builder, tmpdir): # use data that include some responses td = load_data("data/examples/rasa/demo-rasa.md") td_responses = load_data("data/examples/rasa/demo-rasa-responses.md") td = td.merge(td_responses) nlu_config = RasaNLUModelConfig({"language": "en", "pipeline": pipeline}) trainer = Trainer(nlu_config) trainer.train(td) persisted_path = trainer.persist(tmpdir) assert trainer.pipeline loaded = Interpreter.load(persisted_path, component_builder) parsed = loaded.parse("hello") assert loaded.pipeline assert parsed is not None assert (parsed.get(RESPONSE_SELECTOR_PROPERTY_NAME).get("default").get( "full_retrieval_intent")) is not None ranking = parsed.get(RESPONSE_SELECTOR_PROPERTY_NAME).get("default").get( "ranking") assert ranking is not None for rank in ranking: assert rank.get("name") is not None assert rank.get("confidence") is not None assert rank.get("full_retrieval_intent") is not None
def test_train_response_selector(component_builder, tmpdir): td = load_data("data/examples/rasa/demo-rasa.md") td_responses = load_data("data/examples/rasa/demo-rasa-responses.md") td = td.merge(td_responses) td.fill_response_phrases() nlu_config = config.load( "sample_configs/config_embedding_intent_response_selector.yml" ) trainer = Trainer(nlu_config) trainer.train(td) persisted_path = trainer.persist(tmpdir) assert trainer.pipeline loaded = Interpreter.load(persisted_path, component_builder) assert loaded.pipeline assert loaded.parse("hello") is not None assert loaded.parse("Hello today is Monday, again!") is not None
def test_train_selector(pipeline, component_builder, tmpdir): # use data that include some responses td = load_data("data/examples/rasa/demo-rasa.md") td_responses = load_data("data/examples/rasa/demo-rasa-responses.md") td = td.merge(td_responses) td.fill_response_phrases() nlu_config = RasaNLUModelConfig({"language": "en", "pipeline": pipeline}) trainer = Trainer(nlu_config) trainer.train(td) persisted_path = trainer.persist(tmpdir) assert trainer.pipeline loaded = Interpreter.load(persisted_path, component_builder) assert loaded.pipeline assert loaded.parse("hello") is not None