Beispiel #1
0
    def __init__(self,
                 mqtt_hostname='mosquitto',
                 mqtt_port=1883,
                 training_mqtt_hostname=None,
                 training_mqtt_port=None):
        """ Initialisation.

        :param config: a YAML configuration.
        :param assistant: the client assistant class, holding the
                          intent handler and intents registry.
        """
        self.thread_handler = ThreadHandler()
        self.client = mqtt.Client()
        self.training_client = mqtt.Client()
        self.client.on_connect = self.on_connect
        self.client.on_disconnect = self.on_disconnect
        self.client.on_message = self.on_message
        self.training_client.on_message = self.on_training_message
        self.mqtt_hostname = mqtt_hostname
        self.mqtt_port = mqtt_port
        self.training_mqtt_hostname = training_mqtt_hostname if training_mqtt_hostname is not None else os.environ.get(
            'training_mqtt_hostname', None),
        self.training_mqtt_port = training_mqtt_port if training_mqtt_port is not None else os.environ.get(
            'training_mqtt_port', None),
        self.thread_targets = [
            self.startMqtt
        ]  # don't activate training by default, rely on subclasses to add startTrainingMqtt to thread targets as required
        self.subscribe_to = '#'
        self.training_mqtt_hostname = training_mqtt_hostname
        self.training_mqtt_port = training_mqtt_port
Beispiel #2
0
    def __init__(
        self,
        disable_nlu=os.environ.get('rasa_disable_nlu', 'no'),
        disable_core=os.environ.get('rasa_disable_core', 'no'),
        mqtt_hostname=os.environ.get('mqtt_hostname', 'mosquitto'),
        mqtt_port=os.environ.get('mqtt_port', 1883),
        nlu_model_path=os.environ.get('rasa_nlu_model_path', 'models/nlu'),
        snips_assistant_path=os.environ.get('rasa_snips_assistant_path',
                                            'models/snips'),
        snips_user_id=os.environ.get('rasa_snips_user_id', 'user_Kr5A7b4OD'),
        core_model_path=os.environ.get('rasa_core_model_path', 'models/core'),
        config_file=os.environ.get('rasa_config_file',
                                   'rasa_config/config.json'),
        domain_file=os.environ.get('rasa_domain_file',
                                   'rasa_config/domain.yml'),
        nlu_training_file=os.environ.get('rasa_nlu_training_file',
                                         'rasa_config/nlu.md'),
        core_training_file=os.environ.get('rasa_core_training_file',
                                          'rasa_config/stories.md'),
        lang=os.environ.get('rasa_lang', 'en-GB')):
        """ Initialisation.
        :param config: a YAML configuration.
        :param assistant: the client assistant class, holding the
                          intent handler and intents registry.
        """

        self.thread_handler = ThreadHandler()
        self.client = mqtt.Client()
        self.client.on_connect = self.on_connect
        self.client.on_disconnect = self.on_disconnect
        self.client.on_message = self.on_message
        self.mqtt_hostname = mqtt_hostname
        self.mqtt_port = mqtt_port
        self.lang = lang
        # RASA config
        self.disable_nlu = disable_nlu
        self.disable_core = disable_core
        self.interpreter = None
        self.nlu_model_path = nlu_model_path
        self.core_model_path = core_model_path
        # to generate stub assistant
        self.snips_assistant_path = snips_assistant_path
        self.snips_user_id = snips_user_id
        self.config_file = config_file
        # RASA training config
        self.domain_file = domain_file
        self.nlu_training_file = nlu_training_file
        self.core_training_file = core_training_file

        self.isNluTraining = False
        self.isCoreTraining = False

        # save modified times on source files
        self.nlu_modified = self.getNluModified()
        self.core_modified = self.getCoreModified()
        self.core_domain_modified = self.getCoreDomainModified()
        self.nlu_model_modified = self.getNluModelModified()
        self.core_model_modified = self.getCoreModelModified()

        self.loadModels(True)
Beispiel #3
0
    def __init__(
        self,
        mqtt_hostname=os.environ.get('rasa_nlu_mqtt_hostname', 'mosquitto'),
        mqtt_port=os.environ.get('rasa_nlu_mqtt_port', 1883),
        training_mqtt_hostname=None,
        training_mqtt_port=None,
        nlu_model_path=os.environ.get('rasa_nlu_model_path', 'models/nlu'),
        nlu_models=os.environ.get('rasa_nlu_models', 'default'),
        nlu_training_path=os.environ.get('rasa_nlu_training_path',
                                         'training_data/nlu/'),
        config_file=os.environ.get('rasa_nlu_default_config_file',
                                   'training_data/nlu/config.json'),
        config_file_slots=os.environ.get(
            'rasa_nlu_default_config_file_slots',
            'training_data/nlu/config-slots.json'),
        lang=os.environ.get('rasa_nlu_lang', 'en-GB'),
        snips_user_id=os.environ.get('rasa_nlu_snips_user_id',
                                     'user_Kr5A7b4OD'),
    ):
        """ Initialisation.
        :param config: a YAML configuration.
        :param assistant: the client assistant class, holding the
                          intent handler and intents registry.
        """
        SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port,
                                 training_mqtt_hostname, training_mqtt_port)
        # RASA config
        self.trainingIds = {}
        self.training_request_models = {}
        self.interpreter = {}
        self.interpreter_slots = {}
        self.nlu_model_path = nlu_model_path
        self.nlu_training_path = nlu_training_path
        self.default_config_file = config_file
        self.default_config_file_slots = config_file_slots
        # for matching snips intents
        self.snips_user_id = snips_user_id

        self.models = nlu_models.split(",")

        self.thread_handler = ThreadHandler()
        self.thread_targets.append(self.startTrainingMqtt)
        self.training_client.on_message = self.on_training_message

        self.thread_targets.append(self.watchModels)

        self.lang = lang
        self.subscribe_to = 'hermes/nlu/query,hermes/nlu/partialQuery'
        self.nlu_modified = {}
        self.nlu_model_modified = {}

        self.loadModels(True)
        self.nlu_modified = self.getNluModifiedAll()
        self.nlu_model_modified = self.getNluModelModifiedAll()
    def __init__(self):
        self.thread_handler = ThreadHandler()

        config = SnipsConfigParser.read_configuration_file('config.ini')
        if config.get('configuration') is not None:
            customConfig = config['configuration']
            self.respeaker = SnipsRespeaker(customConfig)
        else:
            self.respeaker = SnipsRespeaker()

        self.thread_handler.run(target=self.start_blocking)
        self.thread_handler.start_run_loop()
Beispiel #5
0
    def __init__(self,
                 mqtt_hostname=os.environ.get('rasa_core_mqtt_hostname',
                                              'mosquitto'),
                 mqtt_port=os.environ.get('rasa_core_mqtt_port', 1883),
                 training_mqtt_hostname=None,
                 training_mqtt_port=None,
                 core_model_path=os.environ.get('rasa_core_model_path',
                                                'models/dialogue'),
                 domain_file=os.environ.get('rasa_core_domain_file', None),
                 core_training_file=os.environ.get('rasa_core_training_file',
                                                   None),
                 lang=os.environ.get('rasa_core_lang', 'en-GB')):
        """ Initialisation.
        :param config: a YAML configuration.
        :param assistant: the client assistant class, holding the
                          intent handler and intents registry.
        """
        SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port,
                                 training_mqtt_hostname, training_mqtt_port)
        self.thread_handler = ThreadHandler()
        self.thread_targets.append(self.startTrainingMqtt)
        self.thread_targets.append(self.watchModels)

        #self.client = mqtt.Client()
        #self.client.on_connect = self.on_connect
        #self.client.on_disconnect = self.on_disconnect
        #self.client.on_message = self.on_message
        #self.mqtt_hostname = mqtt_hostname
        #self.mqtt_port = mqtt_port
        #self.training_client.on_message = self.on_message
        self.lang = lang
        self.subscribe_to = 'hermes/intent/+'
        # RASA config
        self.core_model_path = core_model_path
        # RASA training config
        self.domain_file = domain_file
        self.core_training_file = core_training_file
        self.core_model_path = core_model_path
        #self.agentLoaded = SnipsMqttAgent(self.domain_file,policies=[MemoizationPolicy(), KerasPolicy()],core_server = self)
        self.agentLoaded = None
        self.trainingId = None
        self.siteId = None
        self.sessionId = None
        self.core_modified = self.getCoreModified()
        self.core_domain_modified = self.getCoreDomainModified()
        self.core_model_modified = self.getCoreModelModified()
        self.loadModels()
Beispiel #6
0
    def __init__(self,
                 mqtt_hostname='mosquitto',
                 mqtt_port=1883,
                 ):
        """ Initialisation.

        :param config: a YAML configuration.
        :param assistant: the client assistant class, holding the
                          intent handler and intents registry.
        """
        self.thread_handler = ThreadHandler()
        self.client = mqtt.Client()
        self.client.on_connect = self.on_connect
        self.client.on_disconnect = self.on_disconnect
        self.client.on_message = self.on_message
        self.mqtt_hostname = mqtt_hostname
        self.mqtt_port = mqtt_port
Beispiel #7
0
    def __init__(self, mqtt_hostname, mqtt_port, logger=None):
        """ Initialisation.

        :param config: a YAML configuration.
        :param assistant: the client assistant class, holding the
                          intent handler and intents registry.
        """
        self.logger = logger
        self.thread_handler = ThreadHandler()
        self.state_handler = StateHandler(self.thread_handler, logger)

        self.client = mqtt.Client()
        self.client.on_connect = self.on_connect
        self.client.on_disconnect = self.on_disconnect
        self.client.on_message = self.on_message
        self.mqtt_hostname = mqtt_hostname
        self.mqtt_port = mqtt_port

        self.first_hotword_detected = False
Beispiel #8
0
    def __init__(self, mqtt_hostname, mqtt_port, nlu_model_path, config_path):
        """ Initialisation.

        :param config: a YAML configuration.
        :param assistant: the client assistant class, holding the
                          intent handler and intents registry.
        """
        self.thread_handler = ThreadHandler()

        self.client = mqtt.Client()
        self.client.on_connect = self.on_connect
        self.client.on_disconnect = self.on_disconnect
        self.client.on_message = self.on_message
        self.mqtt_hostname = mqtt_hostname
        self.mqtt_port = mqtt_port
        self.nlu_model_path = nlu_model_path
        self.config_path = config_path
        # create an NLU interpreter based on trained NLU model
        self.interpreter = Interpreter.load(self.nlu_model_path,
                                            RasaNLUConfig(self.config_path))
Beispiel #9
0
import pytest_capturelog
import logging


def logAssert(test, msg):
    if not test:
        logging.error(msg)
        assert test, msg


def test_log(log_info):
    logging.info("testing foo")
    logAssert(log_info == 'foo', "foo is not foo")


t = ThreadHandler()
username = '******'
config_file = 'data_test/iris_config.ini'
port = '5000'
target = 'class'
file = 'data_test/iris.csv'
config_test_file = 'data_test/iris_config_test.ini'
df = pd.read_csv('data_test/iris.csv')
fs = FeatureSelection(df)

categories = [
    'numerical', 'numerical', 'numerical', 'numerical', 'categorical'
]
unique_values = [-1, -1, -1, -1, 3]
default_list = {
    'sepal_length': 5.8,