'sorry to hear that':{
                        '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)
Beispiel #2
0
import os
from emora_stdm import DialogueFlow

print(os.getcwd())

df = DialogueFlow("start")
df.add_user_transition("start", "success", "/.*/")
df.set_error_successor("start", "fail")
df.add_system_transition("success", "start", "success")
df.add_system_transition("fail", "start", "fail")

df.knowledge_base().load_json_file("_common.json")

if __name__ == "__main__":
    while True:
        i = input(">> ")
        if "natex " in i[:len("natex ")]:
            df.set_transition_natex("start", "success",
                                    DialogueFlow.Speaker.USER,
                                    i[len("natex "):])
        else:
            df.set_speaker(DialogueFlow.Speaker.USER)
            df.user_turn(i, debugging=True)
            df.set_speaker(DialogueFlow.Speaker.SYSTEM)
            print(df.system_turn(debugging=False))