def test_concerts_online_example(): from rasa_core import utils # simulates cmdline input / detailed explanation above utils.input = lambda _=None: "2" input_channel = FileInputChannel('examples/concerts/data/stories.md', message_line_pattern='^\s*\*\s(.*)$', max_messages=3) agent = run_concertbot_online(input_channel, RegexInterpreter()) responses = agent.handle_message("_greet") assert responses[-1] in { "hey there!", "how can I help you?", "default message" }
def test_fake_user_online_example(): from rasa_core import utils # simulates cmdline input / detailed explanation above utils.input = lambda _=None: "2" input_channel = FileInputChannel( 'examples/babi/data/babi_task5_fu_rasa_fewer_actions.md', message_line_pattern='^\s*\*\s(.*)$', max_messages=3) agent = run_fake_user(input_channel, serve_forever=False) responses = agent.handle_message("_greet") assert responses[-1] in { "how can I help you?", "hey there!", "default message" }
def train_model_online(): agent = Agent(RASA_CORE_DOMAIN_PATH, policies=[MemoizationPolicy(), StatusPolicy()], interpreter=RegexInterpreter()) agent.train_online(RASA_CORE_TRAINING_DATA_PATH, input_channel=FileInputChannel( RASA_CORE_TRAINING_DATA_PATH, message_line_pattern='^\s*\*\s(.*)$', max_messages=10), epochs=RASA_CORE_EPOCHS) agent.interpreter = RasaNLUInterpreter(RASA_NLU_MODEL_PATH) return agent
def run_babi_online(max_messages=10): training_data = 'examples/babi/data/babi_task5_dev_rasa_even_smaller.md' logger.info("Starting to train policy") agent = Agent("examples/restaurant_domain.yml", policies=[MemoizationPolicy(), RestaurantPolicy()], interpreter=RegexInterpreter()) input_c = FileInputChannel(training_data, message_line_pattern='^\s*\*\s(.*)$', max_messages=max_messages) agent.train_online(training_data, input_channel=input_c, epochs=10) agent.interpreter = RasaNLUInterpreter(nlu_model_path) return agent
def run_babi_online(max_messages=10): training_data = 'stories.md' logger.info("Starting to train policy") agent = Agent("domain.yml", policies=[MemoizationPolicy(), MusicPlayerPolicy()], interpreter=RegexInterpreter()) input_c = FileInputChannel(training_data, message_line_pattern='^\s*\*\s(.*)$', max_messages=max_messages) agent.train_online(training_data, input_channel=input_c, epochs=10) agent.interpreter = RasaNLUInterpreter(nlu_model_path) return agent
def run_babi_online(): training_data = 'data/weather.md' logger.info("Starting to train policy") agent = Agent("../weather_domain.yml", policies=[MemoizationPolicy(), WeatherPolicy()], interpreter=RegexInterpreter()) input_c = FileInputChannel(training_data, message_line_pattern='^\s*\*\s(.*)$', max_messages=10) agent.train_online(training_data, input_channel=input_c, epochs=10) agent.interpreter = RasaNLUHttpInterpreter( model_name='model_20171013-084449', token=None, server='http://localhost:7000') return agent
def test_concerts_online_example(): sys.path.append("examples/concertbot/") from train_online import run_concertbot_online from rasa_core import utils # simulates cmdline input / detailed explanation above utils.input = lambda _=None: "2" input_channel = FileInputChannel('examples/concertbot/data/stories.md', message_line_pattern='^\s*\*\s(.*)$', max_messages=3) domain_file = os.path.join("examples", "concertbot", "concert_domain.yml") training_file = os.path.join("examples", "concertbot", "data", "stories.md") agent = run_concertbot_online(input_channel, RegexInterpreter(), domain_file, training_file) responses = agent.handle_message("_greet") assert responses[-1] in { "hey there!", "how can I help you?", "default message" }