-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai.py
More file actions
53 lines (50 loc) · 1.78 KB
/
ai.py
File metadata and controls
53 lines (50 loc) · 1.78 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from chatbot import Chatbot
class AI:
def __init__(self):
self.sentiment = "def"
self.conversations = [
{
0: {
"lit": ["Fuck you."],
"resp": {"def": "Ok."},
"act": {"update": {"sentiment": "neg"}}
},
2: {
"lit": ["Who are you?", "What is your name?"],
"resp": {"def": "I am the AI"}
},
3: {
"lit": ["Where am I?", "What is this place?", "What is this room?"],
"resp": {"def": "Where you have always been"}
}
},
{
1: {
"lit": ["How do I leave?", "Where is the exit?"],
"resp": {"def": "The exit is before you", "neg": "Fuck you"}
},
4: {
"lit": ["I don't want to leave.", "I want to stay.", "I'm not leaving"],
"resp": {"def": "You cannot stay"}
}
},
{
1: {
"lit": ["How do I leave?", "Where is the exit?"],
"resp": {"def": "The door."}
},
4: {
"lit": ["I don't want to leave.", "I want to stay.", "I'm not leaving"],
"resp": {"def": "You must leave."}
}
}
]
self.conversation = self.conversations[0]
self.conversation.update(self.conversations[1])
self.chatbot = Chatbot(self.conversation)
def processText(self, text):
resp, isDict = self.chatbot.processText(text)
if isDict:
return resp[self.sentiment]
else:
return resp