4.4. Global Transition
Exercise
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)Global Transitions
Last updated
Was this helpful?