-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainBot.py
More file actions
34 lines (28 loc) · 792 Bytes
/
mainBot.py
File metadata and controls
34 lines (28 loc) · 792 Bytes
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
# -*- coding: utf-8 -*-
"""
Created on Mon May 20 17:13:01 2019
@author: Krzysztof Pasiewicz
"""
from nlu import NLU
import warnings
import json
def convertResponse(response):
response_dict = json.loads(response)
return response_dict["respond"]
"""
# Main loop of chatbot - do while intent is not 'goodbye'
"""
def main():
warnings.filterwarnings("ignore")
rasa_nlu = NLU()
rasa_nlu.training()
while True:
message = input("User: ")
#print('User: {}'.format(message))
response = rasa_nlu.get_response(message)
response = convertResponse(response)
print('Chatbot: {}'.format(response))
if rasa_nlu.parse_msg(message)['intent']['name'] == 'goodbye':
break
if __name__ == "__main__":
main()