예제 #1
0
def run(core_dir, nlu_dir):
    pika_broker = None

    if ENABLE_ANALYTICS:
        pika_broker = PikaProducer(url, username, password, queue=queue)

    configs = {
        'user': os.getenv('ROCKETCHAT_BOT_USERNAME'),
        'password': os.getenv('ROCKETCHAT_BOT_PASSWORD'),
        'server_url': os.getenv('ROCKETCHAT_URL'),
    }

    input_channel = RocketChatInput(user=configs['user'],
                                    password=configs['password'],
                                    server_url=configs['server_url'])

    _tracker_store = InMemoryTrackerStore(domain=None,
                                          event_broker=pika_broker)

    _endpoints = AvailableEndpoints.read_endpoints(None)
    _interpreter = NaturalLanguageInterpreter.create(nlu_dir)

    _agent = load_agent(core_dir,
                        interpreter=_interpreter,
                        tracker_store=_tracker_store,
                        endpoints=_endpoints)

    http_server = start_server([input_channel], "", "", 5005, _agent)

    try:
        http_server.serve_forever()
    except Exception as exc:
        logger.exception(exc)
예제 #2
0
def test_broker_from_config():
    cfg = utils.read_endpoint_config(EVENT_BROKER_ENDPOINT_FILE,
                                     "event_broker")
    actual = PikaProducer.from_endpoint_config(cfg)

    expected = PikaProducer("localhost", "username", "password", "queue")

    assert actual.host == expected.host
    assert actual.credentials.username == expected.credentials.username
    assert actual.queue == expected.queue