) df.set_error_successor(State.WHY_Y, State.WHY_Y_ERROR) df.set_error_successor(State.WHY_N, State.WHY_N_ERROR) df.add_system_transition( State.WHY_Y_ERROR, State.WHY_Y, '"I did not understand that...\nS: What kind of mobile phone do you have?"' ) df.add_system_transition( State.WHY_N_ERROR, State.WHY_N, '"I did not understand that...\nS: What kind of mobile phone do you have?"' ) df.set_error_successor(State.PART_3_OS, State.PART_3_OS_ERROR) df.add_system_transition( State.PART_3_OS_ERROR, State.PART_3_OS, '"I did not understand that...\nS: You said that you have used"$system_a"OS before, right?"' ) df.set_error_successor(State.HEAR_MORE, State.HEAR_MORE_ERROR) df.add_system_transition( State.HEAR_MORE_ERROR, State.HEAR_MORE, '"I did not understand that...\nS: Do you want to hear more about mobile operating systems?"' ) df.set_error_successor(State.TRAP, State.TRAP_ERROR) df.add_system_transition(State.TRAP_ERROR, State.TRAP, '"Goodbye!!!"') df.run(debugging=False)
from emora_stdm import DialogueFlow system = DialogueFlow("start", end_state="end", initial_speaker=DialogueFlow.Speaker.USER) system.load_transitions({ "state": "start", "[{hi, hello}]": { "`Hi!`": { "score": 3.0, "error": { "`Bye.`": "end" } } }, "error": { "`Bye`": "end" }, }) system.load_update_rules({ "[news]": "`Coronavirus, argh!` (4.0)", "[{movie, movies}]": "`Avengers is a good one.` (4.0)", "/.*/ (0.1)": "`I'm not sure I understand.` (2.0)", }) if __name__ == "__main__": system.run(debugging=True)
'error': 'root' } } } }, '[how, you]': { 'good': { 'error': 'root' } } } } df.load_transitions(flow, DialogueFlow.Speaker.SYSTEM) df.state_settings('root').update(system_multi_hop=True) df.add_state('recovery_question', global_nlu='[!{do, who, what, when, where, why, how, is, can, should}, /.*/]') df.add_system_transition('recovery_question', 'root', '"Hmm.. I\'m not sure."') df.add_user_transition('x', 'y', '#ANY($myvar=something, $other=somethingelse) [hello]') while True: df.system_turn() v = input() var, val = v.split('=') df.vars().update({var: val}) df.user_turn(input()) if __name__ == '__main__': df.run(debugging=True)
} } }, '#INT(Tell me the weather.)': { '"It is sunny out!"': { 'error': { '"Bye!"': 'end' } } } } } chatbot.load_transitions(transitions) chatbot = DialogueFlow('start') transitions = { 'state': 'start', '"Hello!"': { '#INT(Hi! How are you?)': { '"Good! Bye bye!"': 'end' }, '#INT(Tell me about the weather.)': { '"It is sunny!"': 'end' } } } chatbot.load_transitions(transitions) if __name__ == '__main__': chatbot.run()
from emora_stdm import DialogueFlow system = DialogueFlow("start", initial_speaker=DialogueFlow.Speaker.USER) system.load_transitions({ "state": "start", "error": { "` `": { "score": -1, "state": "start" } } }) system.load_update_rules({ "[news]": "`Coronavirus, argh!` (1)", "[{movie, movies}]": "`Avengers is a good one.` (1)", "/.*/ (0.1)": "`I'm not sure I understand.` (1)", }) if __name__ == "__main__": system.run()
from emora_stdm import DialogueFlow import json df = DialogueFlow('start') df.knowledge_base().load_json_file('ontology_example.json') df.load_transitions({ 'state': 'start', '`What is your favorite animal?`': { '[#ONT(mammal)]': { '`I think mammals are cool too!`': 'start' }, '[#ONT(reptile)]': { '`Reptiles are cool.`': 'start' }, '[$animal=#ONT(animal)]': { 'score': 0.5, '`I like` $animal `too.`': 'start' }, 'error': { '`I\'ve never heard of that animal.`': 'start' } } }) if __name__ == '__main__': df.run()