Beispiel #1
0
def serve(data_dir, default):
    """Starts the server.
    """
    agents_factory = FromFile(data_dir, default)

    # Let's load the configuration and load the skills
    CONFIG.load_from_file(agents_factory._default_conf_path)  # pylint: disable=protected-access
    import_skills(CONFIG.getpath(SKILLS_DIR, os.path.join(data_dir, 'skills')),
                  CONFIG.getbool(WATCH))

    server = Server(agents_factory)

    with MQTTChannel() as mqtt:
        mqtt.attach(server)
        input('Press any key, anytime to stop the broker')
Beispiel #2
0
def instantiate_and_fit_interpreter(training_file=None):  # pragma: no cover
    if not training_file:
        import_skills(CONFIG.getpath(SKILLS_DIR), CONFIG.getbool(WATCH))

    try:
        from pytlas.understanding.snips import SnipsInterpreter  # pylint: disable=import-outside-toplevel

        interpreter = SnipsInterpreter(CONFIG.get(LANGUAGE),
                                       CONFIG.getpath(CACHE_DIR))

        if training_file:
            interpreter.fit_from_file(training_file)
        else:
            interpreter.fit_from_skill_data()

        return interpreter
    except ImportError:
        logging.critical(
            'Could not import the "snips" interpreter, is "snips-nlu" installed?'
        )
Beispiel #3
0
from pytlas.settings import CONFIG

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Read the configuration file
CONFIG.load_from_file(os.path.join(BASE_DIR, 'pytlas.ini'))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = CONFIG.get('secret', section='web')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = CONFIG.getbool(DEBUG, section='web') # Must be set to an empty string to turn it off

ALLOWED_HOSTS = [CONFIG.get('allowed_host', '*', section='web')]

CORS_ORIGIN_ALLOW_ALL = True # Since the API is exposed to anyone

# Application definition

INSTALLED_APPS = [
    'corsheaders',
    'assistant.apps.AssistantConfig',
    'rest_framework',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
Beispiel #4
0
 def ready(self):
     install_logs(CONFIG.getbool(VERBOSE),
                  CONFIG.getbool(DEBUG, section='web'))
     import_skills(CONFIG.getpath(SKILLS_DIR))