def run_health_bot(serve_forever=True): interpreter = RasaNLUInterpreter('./models/default/healthbot') action_endpoint = EndpointConfig(url='http://localhost:5055/webhook') agent = Agent.load('./models/dialogue', interpreter=interpreter, action_endpoint=action_endpoint) channel = BotServerInputChannel(agent, port=5002) input_channel = FacebookInput( fb_verify=os.environ['FB_VERIFY'], fb_secret=os.environ['FB_BOT_SECRET'], fb_access_token=os.environ['FB_PAGE_ACCESS_TOKEN'] ) agent.handle_channels([channel, input_channel], http_port=5002, serve_forever=True)
def run_health_bot(serve_forever=True): interpreter = RasaNLUInterpreter('./models/current/healthbot') action_endpoint = EndpointConfig(url='http://localhost:5055/webhook') agent = Agent.load('./models/dialogue', interpreter=interpreter, action_endpoint=action_endpoint) #return agent #channel = BotServerInputChannel(agent, port=5002) #input_channel = FacebookInput( #fb_verify=os.environ['FB_VERIFY'], #fb_secret=os.environ['FB_BOT_SECRET'], #fb_access_token=os.environ['FB_PAGE_ACCESS_TOKEN'] #) #agent.handle_channels([channel, ], http_port=5002, serve_forever=True) # rasa_core.run.serve_application(agent, channel=s, credentials_file='./credentials.yml') #agent = load_agent() channel = BotServerInputChannel(agent, port=5005) agent.handle_channels([channel], http_port=5005)
class FileMessageStore: DEFAULT_FILENAME = "message_store.json" def __init__(self, filename=DEFAULT_FILENAME): self._store = defaultdict(list) self._filename = filename try: for k, v in json.load(open(self._filename, "r")).items(): self._store[k] = v except IOError: pass def log(self, cid, username, message, uuid=None): if uuid is None: uuid = str(uuid4()) self._store[cid].append( { "time": datetime.utcnow().isoformat(), "username": username, "message": message, "uuid": uuid, } ) self.save() def clear(self, cid): self._store[cid] = [] self.save() def save(self): json.dump(self._store, open(self._filename, "w")) # Creating the Interpreter and Agent def load_agent(): ... # Creating the server def main_server(): agent = load_agent() channel = BotServerInputChannel(agent, port=5005) agent.handle_channels([channel], http_port=5005)
text = message_text.strip() return text if __name__ == '__main__': # Running as standalone python application arg_parser = create_argument_parser() cmdline_args = arg_parser.parse_args() logging.getLogger('werkzeug').setLevel(logging.WARN) logging.getLogger('matplotlib').setLevel(logging.WARN) utils.configure_colored_logging(cmdline_args.loglevel) utils.configure_file_logging(cmdline_args.loglevel, cmdline_args.log_file) logger.info("Rasa process starting") _endpoints = EndpointConfig(url="http://localhost:5055/webhook") _interpreter = RasaNLUInterpreter("./models/current/default/nlu") _tracker_store = None _agent = load_agent(cmdline_args.core, interpreter=_interpreter, action_endpoint=_endpoints, tracker_store=_tracker_store) channel = BotServerInputChannel(_agent, preprocessor=preprocessor, port=cmdline_args.port) _agent.handle_channels([channel], http_port=cmdline_args.port)
def main_server(): agent = load_agent() channel = BotServerInputChannel(agent, port=5005) agent.handle_channels([channel], http_port=5005)
def main_server(): agent = load_agent() channel = BotServerInputChannel(agent) agent.handle_channel(channel)
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import argparse from bot_server_channel import BotServerInputChannel from rasa_core.agent import Agent from rasa_core import utils from rasa_core.interpreter import RasaNLUInterpreter interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu') agent = Agent.load('models/dialogue', interpreter=interpreter) channel = BotServerInputChannel(agent) agent.handle_channel(channel)
default=5002, type=int, help="port to run the server at") parser.add_argument('-o', '--log_file', type=str, default="rasa_core.log", help="store log file in specified file") utils.add_logging_option_arguments(parser) return parser def preprocessor(message_text): text = message_text.strip() return text if __name__ == "__main__": parser = create_argparser() cmdline_args = parser.parse_args() utils.configure_colored_logging(cmdline_args.loglevel) utils.configure_file_logging(cmdline_args.loglevel, cmdline_args.log_file) agent = Agent.load(cmdline_args.core, interpreter=cmdline_args.nlu) channel = BotServerInputChannel(agent, port=cmdline_args.port) agent.handle_channel(channel, message_preprocessor=preprocessor)