def run_core(): endpoints = yaml.load(open(directory + "/endpoints.yml").read()) action_endpoint_url = endpoints['action_endpoint']['url'] action_endpoint = EndpointConfig(url=action_endpoint_url) nlu_interpreter = RasaNLUInterpreter(directory + "/models/nlu") agent = Agent.load(directory + "/models/core", interpreter=nlu_interpreter, action_endpoint=action_endpoint) #input_channel = SimpleWebBot() #input_channel = HttpInputChannel(5004,"/",RasaChatInput(urlparse.urljoin("http://localhost/","api"))) input_channel = RestInput() agent.handle_channels([input_channel], 5004, serve_forever=True)
def start_server_local(dialogue_model_path, server_endpoints): """Start a server which serve a local model. Environment variables: ---------- SOCKET_PORT: int Set the port, the server should listen on (default: 5005) Parameters: ---------- dialogue_model_path: str Path to the local model directiory server_endpoints: AvailableEndpoints tuple with the endpoints nlg, nlu, action and model """ # Check SOCKET_PORT socket_port = int( os.environ['SOCKET_PORT']) if "SOCKET_PORT" in os.environ else 5005 # define nlu-server rasaNLU = RasaNLUHttpInterpreter(project_name="damage_report_1.0.0", endpoint=server_endpoints.nlu) # initialize the agent agent = Agent.load(dialogue_model_path, interpreter=rasaNLU, action_endpoint=server_endpoints.action) # define all channels the server should listen to. # SocketIOInput - socketIO for the webchat # RestInput - Rest-Api for other services channels = [ SocketIOInput( # event name for messages sent from the user user_message_evt="user_uttered", # event name for messages sent from the bot bot_message_evt="bot_uttered", # socket.io namespace to use for the messages namespace=None), RestInput() ] # Start the server agent.handle_channels(channels, socket_port)
def url_prefix(self): return RestInput.name()