transitions = {
'state': 'start',
'`Hi there, how are you doing today?`': {
'[{good, fantastic}]': {
'state': 'good',
'`Glad to hear that.` #WHAT_ELSE': {
'[#LEM(movie)]': 'movie',
'[music]': 'music',
'error': {
'state': 'goodbye',
'`Goodbye!`': 'end'
}
}
},
'error': 'goodbye'
}
}
music_transitions = {
'state': 'music',
'`My favorite song is "Raining Tacos"! What\'s yours?`': {
'error': 'good'
}
}
movie_transitions = {
'state': 'movie',
'`My favorite movie is "Spider-Man: Homecoming"! What\'s yours?`': {
'error': 'good'
}
}
macros = {
'WHAT_ELSE': MacroWhatElse()
}
class MacroWhatElse(Macro):
def run(self, ngrams: Ngrams, vars: Dict[str, Any], args: List[Any]):
vn = 'HAVE_TALK'
if vn in vars and vars[vn]:
return 'What else do you want to talk about?'
else:
vars[vn] = True
return 'What do you want to talk about?'
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
df.load_transitions(music_transitions)
df.load_transitions(movie_transitions)
df.add_macros(macros)S: Hi there, how are you doing today?
U: Fantastic!
S: Glad to hear that. What do you want to talk about?
U: Let's talk about movies
S: My favorite movie is "Spider-Man: Homecoming"! What's yours?
U: The Sound of Music
S: Glad to hear that. What else do you want to talk about?
U: How about music?
S: My favorite song is "Raining Tacos"! What's yours?
U: Amazing Grace
S: Glad to hear that. What else do you want to talk about?
U: That's it..
S: Goodbye!gloabl_transitions = {
'[{covid, corona, virus}]': {
'`I hope you are OK.`': 'good'
},
'[{birthday}]': {
'`Happy birthday to you!`': 'good'
}
}
df.load_global_nlu(gloabl_transitions)S: Hi there, how are you doing today?
U: Good
S: Glad to hear that. What do you want to talk about?
U: Music
S: My favorite song is "Raining Tacos"! What's yours?
U: I got vaccinated for COVID
S: I hope you are OK. Glad to hear that. What else do you want to talk about?
U: It's my birthday
S: Happy birthday to you! Glad to hear that. What else do you want to talk about?
U: I'm done
S: Goodbye!S: Hi there, how are you doing today?
U: Good
S: Glad to hear that. What do you want to talk about?
U: Let's talk about virus movies
S: My favorite movie is "Spider-Man: Homecoming"! What's yours?S: Hi there, how are you doing today?
U: Good!
S: Glad to hear that. What do you want to talk about?
U: Let's talk about virus movies
S: I hope you are OK. Glad to hear that. What else do you want to talk about?gloabl_transitions = {
'[{covid, corona, virus}]': {
'score': 0.5,
'`I hope you are OK.`': 'good'
},
'[{birthday}]': {
'score': 0.5,
'`Happy birthday to you!`': 'good'
}
}