コード例 #1
0
def test_training_script(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH, DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         policy_config='data/test_config/max_hist_config.yml',
                         interpreter=RegexInterpreter(),
                         kwargs={})
    assert True
コード例 #2
0
ファイル: test_examples.py プロジェクト: viktara/rasa_core
def test_remote_example():
    from rasa_core import train, run

    train.train_dialogue_model("examples/remotebot/concert_domain_remote.yml",
                               "examples/remotebot/data/stories.md",
                               "examples/remotebot/models/dialogue", False,
                               None, {})
    agent = run.main("examples/remotebot/models/dialogue")

    response = agent.start_message_handling("_search_venues")
    assert response.get("next_action") == 'search_venues'
    assert response.get("tracker") == {
        'slots': {
            'concerts': None,
            'venues': None
        },
        'sender_id': 'default',
        'paused': False,
        'latest_message': {
            'text': '_search_venues',
            'intent_ranking': [{
                'confidence': 1.0,
                'name': 'search_venues'
            }],
            'intent': {
                'confidence': 1.0,
                'name': 'search_venues'
            },
            'entities': []
        }
    }

    next_response = agent.continue_message_handling("default", "search_venues",
                                                    [])
    assert next_response.get("next_action") == "action_listen"
コード例 #3
0
ファイル: test_training.py プロジェクト: githubclj/rasa_core
def test_training_script(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH, DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         use_online_learning=False,
                         nlu_model_path=None,
                         kwargs={})
    assert True
コード例 #4
0
def test_training_script(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH,
                         DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         interpreter=RegexInterpreter(),
                         kwargs={})
    assert True
コード例 #5
0
def test_training_script_with_restart_stories(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH,
                         "data/test_stories/stories_restart.md",
                         tmpdir.strpath,
                         interpreter=RegexInterpreter(),
                         kwargs={})
    assert True
コード例 #6
0
def test_training_script(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH,
                         DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         use_online_learning=False,
                         nlu_model_path=None,
                         kwargs={})
コード例 #7
0
ファイル: conftest.py プロジェクト: wangchong/rasa_core
def trained_moodbot_path():
    train.train_dialogue_model(domain_file="examples/moodbot/domain.yml",
                               stories_file="examples/moodbot/data/stories.md",
                               output_path=MOODBOT_MODEL_PATH,
                               interpreter=RegexInterpreter(),
                               max_history=None,
                               kwargs=None)

    return MOODBOT_MODEL_PATH
コード例 #8
0
ファイル: conftest.py プロジェクト: prenigma/testfou
def trained_moodbot_path():
    train.train_dialogue_model(domain_file="examples/moodbot/domain.yml",
                               stories_file="examples/moodbot/data/stories.md",
                               output_path=MOODBOT_MODEL_PATH,
                               interpreter=RegexInterpreter(),
                               policy_config='rasa_core/default_config.yml',
                               kwargs=None)

    return MOODBOT_MODEL_PATH
コード例 #9
0
ファイル: test_remote.py プロジェクト: wangqh10/rasa_wechat
def test_remote_training(tmpdir):
    train_dialogue_model("examples/remote/concert_domain_remote.yml",
                         "examples/remote/data/stories.md",
                         tmpdir.strpath, {})

    agent = Agent.load(tmpdir.strpath)
    assert agent.domain._factory_name == "remote"

    action_types = [type(a) for a in agent.domain.actions]
    assert action_types[:3] == [ActionListen, ActionRestart, RemoteAction]
コード例 #10
0
def test_training_script_with_max_history_set(tmpdir):
    max_history = 3
    train_dialogue_model(DEFAULT_DOMAIN_PATH, DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         nlu_model_path=None,
                         max_history=max_history,
                         kwargs={})
    agent = Agent.load(tmpdir.strpath)
    for policy in agent.policy_ensemble.policies:
        if hasattr(policy.featurizer, 'max_history'):
            assert policy.featurizer.max_history == max_history
コード例 #11
0
def test_training_script_without_max_history_set(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH, DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         interpreter=RegexInterpreter(),
                         max_history=None,
                         kwargs={})
    agent = Agent.load(tmpdir.strpath)
    for policy in agent.policy_ensemble.policies:
        if hasattr(policy.featurizer, 'max_history'):
            assert policy.featurizer.max_history == \
                   policy.featurizer.MAX_HISTORY_DEFAULT
コード例 #12
0
def train_dialogue(domain_file="config/domain.yml",
                   model_path="models/dialogue",
                   stories_file="config/stories.md",
                   policy_config="config/policy_config.yml"):
    #endpoints_file="config/endpoints.yml"):

    train_dialogue_model(domain_file=domain_file,
                         stories_file=stories_file,
                         output_path=model_path,
                         policy_config=policy_config,
                         kwargs=_additional_arguments())
コード例 #13
0
ファイル: conftest.py プロジェクト: srikanthkalvakota/myHR
def trained_moodbot_path():
    model_path = "examples/moodbot/models/dialogue"
    train.train_dialogue_model(
            domain_file="examples/moodbot/domain.yml",
            stories_file="examples/moodbot/data/stories.md",
            output_path=model_path,
            use_online_learning=False,
            nlu_model_path=None,
            max_history=None,
            kwargs=None
    )
    return model_path
コード例 #14
0
ファイル: conftest.py プロジェクト: githubclj/rasa_core
def trained_moodbot_path():
    model_path = "examples/moodbot/models/dialogue"
    train.train_dialogue_model(
            domain_file="examples/moodbot/domain.yml",
            stories_file="examples/moodbot/data/stories.md",
            output_path=model_path,
            use_online_learning=False,
            nlu_model_path=None,
            max_history=None,
            kwargs=None
    )
    return model_path
コード例 #15
0
ファイル: test_training.py プロジェクト: githubclj/rasa_core
def test_training_script_without_max_history_set(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH, DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         use_online_learning=False,
                         nlu_model_path=None,
                         max_history=None,
                         kwargs={})
    agent = Agent.load(tmpdir.strpath)
    for policy in agent.policy_ensemble.policies:
        if hasattr(policy.featurizer, 'max_history'):
            assert policy.featurizer.max_history == \
                   policy.featurizer.MAX_HISTORY_DEFAULT
コード例 #16
0
def test_training_script_with_max_history_set(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH, DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         interpreter=RegexInterpreter(),
                         policy_config='data/test_config/max_hist_config.yml',
                         kwargs={})
    agent = Agent.load(tmpdir.strpath)
    for policy in agent.policy_ensemble.policies:
        if hasattr(policy.featurizer, 'max_history'):
            if type(policy) == FormPolicy:
                assert policy.featurizer.max_history == 2
            else:
                assert policy.featurizer.max_history == 5
コード例 #17
0
def test_remote_example():
    from rasa_core import train, run
    from rasa_core.events import SlotSet

    train.train_dialogue_model(
        domain_file="examples/remotebot/concert_domain_remote.yml",
        stories_file="examples/remotebot/data/stories.md",
        output_path="examples/remotebot/models/dialogue",
        use_online_learning=False,
        nlu_model_path=None,
        max_history=None,
        kwargs=None)
    agent = run.main("examples/remotebot/models/dialogue")

    response = agent.start_message_handling("/search_venues")
    assert response.get("next_action") == 'search_venues'

    reference = {
        'slots': {
            'concerts': None,
            'venues': None
        },
        'events': None,
        'sender_id': 'default',
        'paused': False,
        'latest_event_time': 1513023382.101372,
        'latest_message': {
            'text': '/search_venues',
            'intent_ranking': [{
                'confidence': 1.0,
                'name': 'search_venues'
            }],
            'intent': {
                'confidence': 1.0,
                'name': 'search_venues'
            },
            'entities': []
        }
    }
    result = response.get("tracker")

    assert reference.keys() == result.keys()
    del reference['latest_event_time']
    del result['latest_event_time']
    assert reference == result

    venues = [{"name": "Big Arena", "reviews": 4.5}]
    next_response = agent.continue_message_handling(
        "default", "search_venues", [SlotSet("venues", venues)])
    assert next_response.get("next_action") == "action_listen"
コード例 #18
0
ファイル: test_remote.py プロジェクト: githubclj/rasa_core
def test_remote_training(tmpdir):
    train_dialogue_model("examples/remotebot/concert_domain_remote.yml",
                         "examples/remotebot/data/stories.md",
                         tmpdir.strpath,
                         use_online_learning=False,
                         nlu_model_path=None,
                         kwargs={})

    agent = Agent.load(tmpdir.strpath)
    assert agent.domain._factory_name == "remote"

    action_types = [type(a) for a in agent.domain.actions]
    assert action_types[:4] == [ActionListen, ActionRestart,
                                ActionDefaultFallback, RemoteAction]
コード例 #19
0
def test_remote_training(tmpdir):
    train_dialogue_model("examples/remotebot/concert_domain_remote.yml",
                         "examples/remotebot/data/stories.md",
                         tmpdir.strpath,
                         use_online_learning=False,
                         nlu_model_path=None,
                         kwargs={})

    agent = Agent.load(tmpdir.strpath)
    assert agent.domain._factory_name == "remote"

    action_types = [type(a) for a in agent.domain.actions]
    assert action_types[:4] == [
        ActionListen, ActionRestart, ActionDefaultFallback, RemoteAction
    ]
コード例 #20
0
ファイル: test_examples.py プロジェクト: viktara/rasa_core
def test_moodbot_example():
    from rasa_core import train, run

    train.train_dialogue_model("examples/moodbot/domain.yml",
                               "examples/moodbot/data/stories.md",
                               "examples/moodbot/models/dialogue", False, None,
                               {})
    agent = run.main("examples/moodbot/models/dialogue")

    responses = agent.handle_message("_greet")
    assert responses[0] == 'Hey! How are you?'

    responses.extend(agent.handle_message("_mood_unhappy"))
    assert responses[-1] in {"Did that help you?"}

    # (there is a 'I am on it' message in the middle we are not checking)
    assert len(responses) == 6
コード例 #21
0
ファイル: train_interactive.py プロジェクト: prenigma/testfou
def train_agent():
    return train.train_dialogue_model(domain_file="domain.yml",
                                      stories_file="data/stories.md",
                                      output_path="models/dialogue",
                                      kwargs={"batch_size": 50,
                                              "epochs": 200,
                                              "max_training_samples": 300
                                              })
コード例 #22
0
 def train_dialogue(self,
                    domain_file='domain.yml',
                    stories_file='data/stories.md',
                    model_path='model/dialogue',
                    policy_config='config/config.yml'):
     return train.train_dialogue_model(domain_file=domain_file,
                                       stories_file=stories_file,
                                       output_path=model_path,
                                       policy_config=policy_config)
コード例 #23
0
ファイル: train.py プロジェクト: Karyyelf/2019.1-Ludum
def train_dialogue(domain_file, model_path, training_folder, policy_config):
    return train.train_dialogue_model(domain_file=domain_file,
                                      stories_file=training_folder,
                                      output_path=model_path,
                                      policy_config=policy_config,
                                      kwargs={
                                          'augmentation_factor': 20,
                                          'validation_split': 0.2,
                                      })
コード例 #24
0
def test_formbot_example():
    sys.path.append("examples/formbot/")

    p = "examples/formbot/"
    stories = os.path.join(p, "data", "stories.md")
    endpoint = EndpointConfig("https://abc.defg/webhooks/actions")
    endpoints = AvailableEndpoints(action=endpoint)
    agent = train_dialogue_model(os.path.join(p, "domain.yml"),
                                 stories,
                                 os.path.join(p, "models", "dialogue"),
                                 endpoints=endpoints,
                                 policy_config="rasa_core/default_config.yml")
    response = {
        'events': [{
            'event': 'form',
            'name': 'restaurant_form',
            'timestamp': None
        }, {
            'event': 'slot',
            'timestamp': None,
            'name': 'requested_slot',
            'value': 'cuisine'
        }],
        'responses': [{
            'template': 'utter_ask_cuisine'
        }]
    }

    httpretty.register_uri(httpretty.POST,
                           'https://abc.defg/webhooks/actions',
                           body=json.dumps(response))

    httpretty.enable()

    responses = agent.handle_text("/request_restaurant")

    httpretty.disable()

    assert responses[0]['text'] == 'what cuisine?'

    response = {
        "error": "Failed to validate slot cuisine with action restaurant_form",
        "action_name": "restaurant_form"
    }

    httpretty.register_uri(httpretty.POST,
                           'https://abc.defg/webhooks/actions',
                           status=400,
                           body=json.dumps(response))

    httpretty.enable()

    responses = agent.handle_text("/chitchat")

    httpretty.disable()

    assert responses[0]['text'] == 'chitchat'
コード例 #25
0
ファイル: train_online.py プロジェクト: rohitjun08/rasa_core
def train_agent():
    return train.train_dialogue_model(domain_file="domain.yml",
                                      stories_file="data/stories.md",
                                      output_path="models/dialogue",
                                      endpoints="endpoints.yml",
                                      max_history=2,
                                      kwargs={"batch_size": 50,
                                              "epochs": 200,
                                              "max_training_samples": 300
                                              })
コード例 #26
0
def train_agent(interpreter):
    return train.train_dialogue_model(domain_file="horoscope_domain.yml",
                                      stories_file="data/stories.md",
                                      output_path="models/dialog",
                                      nlu_model_path=interpreter,
                                      endpoints="endpoints.yml",
                                      max_history=2,
                                      kwargs={"batch_size": 50,
                                              "epochs": 200,
                                              "max_training_samples": 300
                                              })
コード例 #27
0
ファイル: test_examples.py プロジェクト: githubclj/rasa_core
def test_remote_example():
    from rasa_core import train, run
    from rasa_core.events import SlotSet

    train.train_dialogue_model(
            domain_file="examples/remotebot/concert_domain_remote.yml",
            stories_file="examples/remotebot/data/stories.md",
            output_path="examples/remotebot/models/dialogue",
            use_online_learning=False,
            nlu_model_path=None,
            max_history=None,
            kwargs=None
    )
    agent = run.main("examples/remotebot/models/dialogue")

    response = agent.start_message_handling("/search_venues")
    assert response.get("next_action") == 'search_venues'

    reference = {
        'slots': {'concerts': None, 'venues': None},
        'events': None,
        'sender_id': 'default',
        'paused': False,
        'latest_event_time': 1513023382.101372,
        'latest_message': {
            'text': '/search_venues',
            'intent_ranking': [{'confidence': 1.0, 'name': 'search_venues'}],
            'intent': {'confidence': 1.0, 'name': 'search_venues'},
            'entities': []}}
    result = response.get("tracker")

    assert reference.keys() == result.keys()
    del reference['latest_event_time']
    del result['latest_event_time']
    assert reference == result

    venues = [{"name": "Big Arena", "reviews": 4.5}]
    next_response = agent.continue_message_handling(
        "default", "search_venues", [SlotSet("venues", venues)]
    )
    assert next_response.get("next_action") == "action_listen"
コード例 #28
0
def train_dialogue(domain_file='domain.yml',
                   stories_file='data/stories.md',
                   model_path='models/dialogue',
                   policy_config='policy_config.yml'):
    return train.train_dialogue_model(domain_file=domain_file,
                                      stories_file=stories_file,
                                      output_path=model_path,
                                      policy_config=policy_config,
                                      kwargs={
                                          'augmentation_factor': 50,
                                          'validation_split': 0.2
                                      })
コード例 #29
0
def run_online(domain_file="config/domain.yml", stories_file="config/stories.md", output_path="models/dialogue",
                      max_history=3, kwargs={"batch_size": 50, "epochs": 800, "max_training_samples": 300}):
    interpreter = RasaNLUInterpreter("models/ticket/nlu_bot")
    agent = train.train_dialogue_model(domain_file=domain_file,
                                       interpreter=interpreter,
                                       stories_file=stories_file,
                                       output_path=output_path,
                                       max_history=max_history,
                                       endpoints=AvailableEndpoints.read_endpoints("config/endpoints.yml"),
                                       kwargs=kwargs)

    online.run_online_learning(agent)
コード例 #30
0
ファイル: test_training.py プロジェクト: yunushaik/rasa_core
def test_random_seed(tmpdir, config_file):
    # set random seed in config file to
    # generate a reproducible training result
    agent_1 = train_dialogue_model(DEFAULT_DOMAIN_PATH,
                                   DEFAULT_STORIES_FILE,
                                   tmpdir.strpath + "1",
                                   interpreter=RegexInterpreter(),
                                   policy_config=config_file,
                                   kwargs={})

    agent_2 = train_dialogue_model(DEFAULT_DOMAIN_PATH,
                                   DEFAULT_STORIES_FILE,
                                   tmpdir.strpath + "2",
                                   interpreter=RegexInterpreter(),
                                   policy_config=config_file,
                                   kwargs={})

    processor_1 = agent_1.create_processor()
    processor_2 = agent_2.create_processor()

    probs_1 = processor_1.predict_next("1")
    probs_2 = processor_2.predict_next("2")
    assert probs_1["confidence"] == probs_2["confidence"]
コード例 #31
0
def test_formbot_example():
    sys.path.append("examples/formbot/")

    p = "examples/formbot/"
    stories = os.path.join(p, "data", "stories.md")
    endpoint = EndpointConfig("http://localhost:5055/webhook")
    endpoints = AvailableEndpoints(action=endpoint)
    agent = train_dialogue_model(os.path.join(p, "domain.yml"),
                                 stories,
                                 os.path.join(p, "models", "dialogue"),
                                 endpoints=endpoints,
                                 policy_config="rasa_core/default_config.yml")
    # response = {
    #     'events': [
    #         {'event': 'form', 'name': 'restaurant_form', 'timestamp': None},
    #         {'event': 'slot', 'timestamp': None,
    #          'name': 'requested_slot', 'value': 'cuisine'}
    #     ],
    #     'responses': [
    #         {'template': 'utter_ask_cuisine'}
    #     ]
    # }    
    print(type(agent.policy_ensemble))

    responses = agent.handle_text("/request_restaurant")
    # assert responses[0]['text'] == 'what cuisine?'
    print(responses)

    # response = {
    #     "error": "Failed to validate slot cuisine with action restaurant_form",
    #     "action_name": "restaurant_form"
    # }

    responses = agent.handle_text("/chitchat")
    # assert responses[0]['text'] == 'chitchat'
    print(responses[0])
コード例 #32
0
def test_training_script(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH, DEFAULT_STORIES_FILE,
                         tmpdir.strpath, {})
コード例 #33
0
def train_dialog():
    conf = Config()
    train_dialogue_model(conf.get_value('domain-file'), conf.get_value('stories-file'),
                         conf.get_value('dialog-model-path'))
コード例 #34
0
def test_training_script(tmpdir):
    train_dialogue_model(DEFAULT_DOMAIN_PATH, DEFAULT_STORIES_FILE,
                         tmpdir.strpath,
                         nlu_model_path=None,
                         kwargs={})
    assert True
コード例 #35
0
def trained_moodbot_path():
    model_path = "examples/moodbot/models/dialogue"
    train.train_dialogue_model("examples/moodbot/domain.yml",
                               "examples/moodbot/data/stories.md", model_path,
                               False, None, {})
    return model_path
コード例 #36
0
ファイル: train.py プロジェクト: ciwin/twde-chatbot
def train_dialog():
    train_dialogue_model(CONF.get_value('domain-file'),
                         CONF.get_value('stories-file'),
                         CONF.get_value('dialog-model-path'))