Beispiel #1
0
async def test_agent_handle_message_only_core(trained_core_model: Text):
    agent = await load_agent(model_path=trained_core_model)
    model_id = agent.model_id
    sender_id = uuid.uuid4().hex
    message = UserMessage("/greet", sender_id=sender_id)
    await agent.handle_message(message)
    tracker = agent.tracker_store.get_or_create_tracker(sender_id)
    expected_events = with_model_ids(
        [
            ActionExecuted(action_name="action_session_start"),
            SessionStarted(),
            ActionExecuted(action_name="action_listen"),
            UserUttered(text="/greet", intent={"name": "greet"},),
            DefinePrevUserUtteredFeaturization(False),
            ActionExecuted(action_name="utter_greet"),
            BotUttered(
                "hey there None!",
                {
                    "elements": None,
                    "quick_replies": None,
                    "buttons": None,
                    "attachment": None,
                    "image": None,
                    "custom": None,
                },
                {"utter_action": "utter_greet"},
            ),
            ActionExecuted(action_name="action_listen"),
        ],
        model_id,
    )
    assert len(tracker.events) == len(expected_events)
    for e1, e2 in zip(tracker.events, expected_events):
        assert e1 == e2
Beispiel #2
0
async def test_agent_handle_message_only_nlu(trained_nlu_model: Text):
    agent = await load_agent(model_path=trained_nlu_model)
    model_id = agent.model_id
    sender_id = uuid.uuid4().hex
    message = UserMessage("hello", sender_id=sender_id)
    await agent.handle_message(message)
    tracker = agent.tracker_store.get_or_create_tracker(sender_id)
    expected_events = with_model_ids(
        [
            ActionExecuted(action_name="action_session_start"),
            SessionStarted(),
            ActionExecuted(action_name="action_listen"),
            UserUttered(text="hello", intent={"name": "greet"},),
        ],
        model_id,
    )
    assert len(tracker.events) == len(expected_events)
    for e1, e2 in zip(tracker.events, expected_events):
        assert e1 == e2