-
Notifications
You must be signed in to change notification settings - Fork 19
/
bot.py
38 lines (28 loc) · 1.02 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from rasa_core.agent import Agent
from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUModelConfig
from rasa_nlu.model import Trainer
from rasa_nlu import config
# loading the nlu training samples
training_data = load_data("./data/nlu")
# trainer to educate our pipeline
trainer = Trainer(config.load("./config.yml"))
# train the model!
interpreter = trainer.train(training_data)
# store it for future use
model_directory = trainer.persist("./models/nlu", fixed_model_name="chat")
agent = Agent.load('models/dialogue', interpreter=model_directory)
print("Your bot is ready to talk! Type your messages here or send 'stop'")
print("\n\n")
print("Bot: ","Yo!!! Hey there....")
while True:
a = input("User: ")
if a == 'stop':
break
responses = agent.handle_message(a)
for response in responses:
print("BOT: ",response["text"])