Пример #1
0
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"
Пример #2
0
def test_moodbot_example(trained_moodbot_path):
    from rasa_core import run

    agent = run.main(trained_moodbot_path)

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

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

    # (there is a 'I am on it' message in the middle we are not checking)
    assert len(responses) == 4
Пример #3
0
def test_moodbot_example(trained_moodbot_path):
    from rasa_core import run

    agent = run.main(trained_moodbot_path)

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

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

    # (there is a 'I am on it' message in the middle we are not checking)
    assert len(responses) == 4
Пример #4
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"
Пример #5
0
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
Пример #6
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"
Пример #7
0
def run():
    from rasa_core.run import main
    main("models\dialog",
         nlu_model="models/infosys_cui/current",
         channel="cmdline")