def run_bank_bot(serve_forever=True): from rasa_core.agent import Agent from rasa_core.interpreter import RasaNLUInterpreter from rasa_core.channels.console import CmdlineInput interpreter = RasaNLUInterpreter('models/nlu/default/bank_nlu') agent = Agent.load('models/dialogue', interpreter=interpreter) if serve_forever: agent.handle_channels([CmdlineInput()]) return agent
def run_bot(serve_forever=True): interpreter = RasaNLUInterpreter('./models/current/nlu/') agent = Agent.load('./models/dialogue/', interpreter=interpreter) if serve_forever: agent.handle_channels([CmdlineInput()]) return agent
policies=[MemoizationPolicy(), KerasPolicy()], interpreter=interpreter, generator=None) agent.train(training_data_file, input_channel=input_channel, max_history=2, batch_size=50, epochs=200, max_training_samples=300, validation_split=0.2) return agent if __name__ == '__main__': logging.basicConfig(level="INFO") directory = './models' for filename in os.listdir(directory): if filename.endswith(".tar.gz"): #print('FILE NAME== ',filename) tar = tarfile.open(os.path.join(directory, filename)) tar.extractall() tar.close() continue else: continue nlu_interpreter = RasaNLUInterpreter('./nlu') run_restaurant_online(CmdlineInput(), nlu_interpreter)
from rasa_core.agent import Agent from rasa_core.channels.console import CmdlineInput from rasa_core.interpreter import RegexInterpreter from rasa_core.policies.keras_policy import KerasPolicy from rasa_core.policies.memoization import MemoizationPolicy from rasa_core.interpreter import RasaNLUInterpreter from rasa_core.training import interactive from rasa_core.utils import EndpointConfig def train_agent(input_channel, nlu_interpreter, domain_file="domain.yml", training_data_file='./data/dialogue/stories.md'): #endpoints = "endpoints.yml" agent = Agent(domain_file, policies=[MemoizationPolicy(max_history=2), KerasPolicy()], interpreter=nlu_interpreter) data = agent.load_data(training_data_file) agent.train(data, input_channel=input_channel, batch_size=50, epochs=200, max_training_samples=300) agent = Agent.load('models/dialogue/default/dialogue_model', interpreter = nlu_interpreter, action_endpoint=EndpointConfig(url = "http://localhost:5055/webhook")) interactive.run_interactive_learning(agent, training_data_file) return agent if __name__ == '__main__': nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/nlu_model') train_agent(CmdlineInput(), nlu_interpreter)
from rasa_core.utils import EndpointConfig logger = logging.getLogger(__name__) def run_weather_online(input_channel, interpreter, domain_file="weather_domain.yml", training_data_file='data/stories.md'): #policies2 = policy_config.load("config.yml") action_endpoints = EndpointConfig(url="http://localhost:5055/webhook") agent = Agent( "weather_domain.yml", interpreter=interpreter, policies=[MemoizationPolicy(), KerasPolicy(epochs=200, batch_size=50)], action_endpoint=action_endpoints) #data = asyncio.run(agent.load_data(training_data_file)) data = agent.load_data(training_data_file) agent.train(data) interactive.run_interactive_learning(agent, training_data_file) return agent if __name__ == '__main__': logging.basicConfig(level="INFO") nlu_interpreter = NaturalLanguageInterpreter.create( './models/nlu/default/weathernlu') run_weather_online(CmdlineInput(), nlu_interpreter)
import logging from rasa_core.agent import Agent from rasa_core.channels.console import CmdlineInput from rasa_core.interpreter import RegexInterpreter from rasa_core.policies.keras_policy import KerasPolicy from rasa_core.policies.memoization import MemoizationPolicy from rasa_core.interpreter import RasaNLUInterpreter logger = logging.getLogger(__name__) def train_online(input_channel , interpreter, domain_file = 'domain.yml', training_data = './data/stories.md'): agent = Agent(domain_file, policies = [MemoizationPolicy(max_history=2), KerasPolicy(epochs = 500, batch_size=10)], interpreter = interpreter) data = agent.load_data(training_data) agent.continue_training(data, input_channel = input_channel, augmentation_factor = 50, validation_split = 0.2) agent.persist(model_path) return agent if __name__ =="__main__": logging.basicConfig(level = 'INFO') nlu_interpreter = RasaNLUInterpreter('./models/current/nlu/') train_online(CmdlineInput(),nlu_interpreter)
from rasa_core.agent import Agent from rasa_core.interpreter import RasaNLUInterpreter from rasa_core.channels.slack import SlackInput from rasa_core.channels.console import CmdlineInput; nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/restaurantnlu') agent = Agent.load('./models/dialogue', interpreter = nlu_interpreter) input_channel = SlackInput('xoxp-359418684578-360311923670-373479391381-faf4e29bddac4cd131221b8cf0ffa627', #app verification token #'xoxb-359418684578-372796513233-gHxeV6CHQFl8MPkZVrPHBsnQ', # bot verification token #'7uAoXNmNANaqCa9WpALV9EhR', # slack verification token True) cmd_channel = CmdlineInput() agent.handle_channels(channels=[input_channel, cmd_channel], http_port=5004, serve_forever=True)