def serve_application(model_directory: Text, nlu_model: Optional[Text] = None, tracker_dump: Optional[Text] = None, port: int = constants.DEFAULT_SERVER_PORT, endpoints: Optional[Text] = None, enable_api: bool = True): from rasa_core import run _endpoints = AvailableEndpoints.read_endpoints(endpoints) nlu = NaturalLanguageInterpreter.create(nlu_model, _endpoints.nlu) input_channels = run.create_http_input_channels("cmdline", None) agent = load_agent(model_directory, interpreter=nlu, endpoints=_endpoints) http_server = run.start_server(input_channels, None, None, port=port, initial_agent=agent, enable_api=enable_api) tracker = load_tracker_from_json(tracker_dump, agent.domain) run.start_cmdline_io(constants.DEFAULT_SERVER_FORMAT.format(port), http_server.stop, sender_id=tracker.sender_id) replay_events(tracker, agent) try: http_server.serve_forever() except Exception as exc: logger.exception(exc)
def run(core_dir, nlu_dir, endpoints_file): 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']) _endpoints = AvailableEndpoints.read_endpoints(endpoints_file) _interpreter = NaturalLanguageInterpreter.create(nlu_dir, _endpoints.nlu) _tracker_store = ElasticTrackerStore() _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)
def run(core_dir, nlu_dir): input_channel = SocketIOInput(user_message_evt="user_uttered", bot_message_evt="bot_uttered", session_persistence=True, namespace=None) _endpoints = AvailableEndpoints.read_endpoints('endpoints.yml') _interpreter = NaturalLanguageInterpreter.create(nlu_dir) elastic_user = os.getenv('ELASTICSEARCH_USER') if elastic_user is None: _tracker_store = ElasticTrackerStore( domain=os.getenv('ELASTICSEARCH_URL', 'elasticsearch:9200')) else: _tracker_store = ElasticTrackerStore( domain=os.getenv('ELASTICSEARCH_URL', 'elasticsearch:9200'), user=os.getenv('ELASTICSEARCH_USER', 'user'), password=os.getenv('ELASTICSEARCH_PASSWORD', 'password'), scheme=os.getenv('ELASTICSEARCH_HTTP_SCHEME', 'http'), scheme_port=os.getenv('ELASTICSEARCH_PORT', '80')) _agent = load_agent(core_dir, interpreter=_interpreter, tracker_store=_tracker_store, endpoints=_endpoints) WEBCHAT_PORT = os.getenv('WEBCHAT_PORT', 3000) http_server = start_server([input_channel], "", "", int(WEBCHAT_PORT), _agent) try: http_server.serve_forever() except Exception as exc: logger.exception(exc)
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)
def run(core_dir, nlu_dir): 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'] ) _endpoints = AvailableEndpoints.read_endpoints(None) _interpreter = NaturalLanguageInterpreter.create(nlu_dir) elastic_user = os.getenv('ELASTICSEARCH_USER') if elastic_user is None: _tracker_store = ElasticTrackerStore( domain = os.getenv('ELASTICSEARCH_URL', 'elasticsearch:9200') ) else: _tracker_store = ElasticTrackerStore( domain = os.getenv('ELASTICSEARCH_URL', 'elasticsearch:9200'), user = os.getenv('ELASTICSEARCH_USER', 'user'), password = os.getenv('ELASTICSEARCH_PASSWORD', 'password'), scheme = os.getenv('ELASTICSEARCH_HTTP_SCHEME', 'http'), scheme_port = os.getenv('ELASTICSEARCH_PORT', '80') ) _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)
def serve_application(model_directory, # type: Text nlu_model=None, # type: Optional[Text] tracker_dump=None, # type: Optional[Text] port=constants.DEFAULT_SERVER_PORT, # type: int endpoints=None, # type: Optional[Text] enable_api=True # type: bool ): from rasa_core import run _endpoints = run.read_endpoints(endpoints) nlu = NaturalLanguageInterpreter.create(nlu_model, _endpoints.nlu) input_channels = run.create_http_input_channels("cmdline", None) agent = load_agent(model_directory, interpreter=nlu, endpoints=_endpoints) http_server = run.start_server(input_channels, None, None, port=port, initial_agent=agent, enable_api=enable_api) tracker = load_tracker_from_json(tracker_dump, agent.domain) run.start_cmdline_io(constants.DEFAULT_SERVER_URL, http_server.stop, sender_id=tracker.sender_id) replay_events(tracker, agent) try: http_server.serve_forever() except Exception as exc: logger.exception(exc)