Created
          September 30, 2018 05:19 
        
      - 
      
 - 
        
Save nahidalam/9a8c1c2d6ed784d83673c313d607aa34 to your computer and use it in GitHub Desktop.  
    Training and running dialogue model
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def train_dialogue(domain_file = 'customer_domain.yml', | |
| model_path = './models/dialogue', | |
| training_data_file = './data/stories.md'): | |
| agent = Agent(domain_file, policies = [MemoizationPolicy(), KerasPolicy()]) | |
| agent.train( | |
| training_data_file, | |
| epochs = 300, | |
| batch_size = 50, | |
| validation_split = 0.2) | |
| agent.persist(model_path) | |
| return agent | |
| def run_customer_bot(serve_forever=True): | |
| interpreter = RasaNLUInterpreter('./models/nlu/default/customernlu') | |
| agent = Agent.load('./models/dialogue', interpreter = interpreter) | |
| if serve_forever: | |
| agent.handle_channel(ConsoleInputChannel()) | |
| return agent | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment