Esempio n. 1
0
 def add_user_messages(self, messages):
     if not self.current_step_builder:
         raise StoryParseError("User message '{}' at invalid location. "
                               "Expected story start.".format(messages))
     parsed_messages = []
     for m in messages:
         parse_data = self.interpreter.parse(m)
         utterance = UserUttered.from_parse_data(m, parse_data)
         if utterance.intent.get("name") not in self.domain.intents:
             logger.warn("Found unknown intent '{}'. Please, make sure "
                         "that all intents are listed in your domain "
                         "yaml.".format(utterance.intent.get("name")))
         parsed_messages.append(utterance)
     self.current_step_builder.add_user_messages(parsed_messages)
Esempio n. 2
0
 def add_user_messages(self, messages, line_num):
     if not self.current_step_builder:
         raise StoryParseError("User message '{}' at invalid location. "
                               "Expected story start.".format(messages))
     parsed_messages = []
     for m in messages:
         parse_data = self.interpreter.parse(m)
         utterance = UserUttered.from_parse_data(m, parse_data)
         if m.startswith("_"):
             c = utterance.as_story_string()
             logger.warn("Stating user intents with a leading '_' is "
                         "deprecated. The new format is "
                         "'* {}'. Please update "
                         "your example '{}' to the new format.".format(c, m))
         intent_name = utterance.intent.get("name")
         if intent_name not in self.domain.intents:
             logger.warn("Found unknown intent '{}' on line {}. Please, "
                         "make sure that all intents are listed in your "
                         "domain yaml.".format(intent_name, line_num))
         parsed_messages.append(utterance)
     self.current_step_builder.add_user_messages(parsed_messages)
Esempio n. 3
0
import pytest
from treq.testing import StubTreq

import rasa_core
from rasa_core.agent import Agent
from rasa_core.events import UserUttered, BotUttered, SlotSet, TopicSet
from rasa_core.interpreter import RegexInterpreter
from rasa_core.policies.scoring_policy import ScoringPolicy
from rasa_core.server import RasaCoreServer
from tests.conftest import DEFAULT_STORIES_FILE

# a couple of event instances that we can use for testing
test_events = [
    UserUttered.from_parse_data("/goodbye", {
        "intent": {"confidence": 1.0, "name": "greet"},
        "entities": []}),
    BotUttered("Welcome!", {"test": True}),
    TopicSet("question"),
    SlotSet("cuisine", 34),
    SlotSet("cuisine", "34"),
    SlotSet("location", None),
    SlotSet("location", [34, "34", None]),
]


@pytest.fixture(scope="module")
def app(core_server):
    """This fixture makes use of the IResource interface of the
    Klein application to mock Rasa Core server."""
    return StubTreq(core_server.app.resource())