RESPONSE: "", TRANSITIONS: { "choose_story_node": cnd.all( [ loc_cnd.is_tell_me_a_story, loc_cnd.has_story_type, loc_cnd.has_story_left, ] ), "which_story_node": cnd.all([loc_cnd.is_tell_me_a_story, cnd.neg(loc_cnd.has_story_type)]), }, }, "choose_story_node": { RESPONSE: loc_rsp.choose_story, TRANSITIONS: { "tell_punchline_node": cnd.any([int_cnd.is_yes_vars, int_cnd.is_do_not_know_vars]), "which_story_node": int_cnd.is_no_vars, }, }, "which_story_node": { RESPONSE: loc_rsp.which_story, TRANSITIONS: {"choose_story_node": cnd.all([loc_cnd.has_story_type, loc_cnd.has_story_left])}, }, "tell_punchline_node": { RESPONSE: loc_rsp.tell_punchline, }, "fallback_node": { RESPONSE: loc_rsp.fallback, TRANSITIONS: {"which_story_node": cnd.all([loc_cnd.is_asked_for_a_story, int_cnd.is_yes_vars])}, }, },
cnd.neg(loc_cnd.check_flag("art_skill_active")) ]), ("art", "photo_q", 1): cnd.all([ loc_cnd.art_skill_switch, cnd.neg(loc_cnd.check_flag("art_skill_active")) ]), } }, "art": { "drawing_q": { RESPONSE: "Do you like drawing?", TRANSITIONS: { ("drawing", "what_painter", 2): cnd.any([ int_cnd.is_yes_vars, cnd.regexp(templates.LIKE_PATTERN), ], ), lbl.forward(): cnd.true(), }, PROCESSING: { "set_flag": loc_prs.set_flag("art_skill_active"), "set_confidence": loc_prs.set_start_confidence, }, }, "photo_q": { RESPONSE: ["Do you like taking photos?"], TRANSITIONS: { ("photo", "what_photos"): cnd.any( [int_cnd.is_yes_vars,
"start": { RESPONSE: "" }, "fallback": { PROCESSING: { "set_confidence": int_prs.set_confidence(ZERO_CONFIDENCE) }, RESPONSE: "", }, }, "funfact": { LOCAL: { TRANSITIONS: { ("funfact", "random"): cnd.any([ loc_cnd.random_funfact_condition, loc_cnd.another_funfact_condition ]) } }, "random": { RESPONSE: rsp.random_funfact_response }, "thematic": { RESPONSE: rsp.thematic_funfact_response }, }, } actor = Actor(flows, start_label=("service", "start"), fallback_label=("service", "fallback"))
r"n['o]t (sure|know|remember|recall)|no (idea|clue)|never heard", re.IGNORECASE)) # todo: add more phrases likes_reading = cnd.regexp( re.compile( r"i (do )?(like|love|prefer|enjoy) (books{0,1}|read|to read|reading)", re.IGNORECASE, )) dislikes_reading = cnd.any([ cnd.regexp( re.compile( r"((n['o]t (want|like) (to )?(go on|continue|hear|talk|discuss|speak|listen))|" r"(no more)|" r"(whatever)|" r"((stop|quit|exit)))", re.IGNORECASE, )), cnd.regexp(re.compile(NOT_LIKE_PATTERN)), ]) exit_skill = cnd.any([ is_side_or_stop, # int_cnd.is_switch_topic, # is_switch_topic, cnd.all([is_proposed_skill, int_cnd.is_no_vars]), ]) has_read_transitions = { ("concrete_book_flow", "ask_opinion", 2):
flows = { GLOBAL: { TRANSITIONS: { ("global_flow", "fallback", 1.5): loc_cnd.exit_skill, ("books_general", "dislikes_reading", 1.5): loc_cnd.dislikes_reading, ("books_general", "book_start"): loc_cnd.start_condition, ("books_general", "book_restart"): cnd.all( [ loc_cnd.is_proposed_skill, cnd.neg(loc_cnd.check_flag("book_skill_active")), loc_cnd.check_flag("book_start_visited"), ] ), ("bot_fav_book", "fav_name", 4): cnd.any( # было 1.8 [ loc_cnd.is_last_used_phrase(loc_rsp.FAVOURITE_BOOK_PHRASES), loc_cnd.asked_fav_book, ] ), ("bot_fav_book", "fav_denied", 2): cnd.all( [ loc_cnd.is_last_used_phrase(loc_rsp.FAVOURITE_BOOK_PHRASES), int_cnd.is_no_vars, ] ), ("bible_flow", "bible_start", 1.8): cnd.all( [ loc_cnd.asked_about_bible, cnd.neg(loc_cnd.check_flag("bible_start_visited")), ] ), ("bible_flow", "bible_elaborate", 1.8): cnd.all(
return False def age_detected(ctx: Context, actor: Actor, *args, **kwargs): # See note in subject_detected age = get_age(ctx) if age: return True return False offered_more = cnd.any( [ cnd.negation(covid_facts_exhausted), cnd.negation(check_flag("asked_about_age")), ] ) replied_to_offer = { ("covid_fact", "replied_no"): cnd.all([offered_more, int_cnd.is_no_vars]), ("covid_fact", "feel_fear"): cnd.all([offered_more, emotion_detected("fear", 0.9)]), ("covid_fact", "replied_yes"): cnd.all([offered_more, int_cnd.is_yes_vars]), ("simple", "age_covid_risks"): cnd.all([offered_more, age_detected]), ("covid_fact", "core_fact_2"): cnd.all([offered_more, cnd.negation(age_detected)]), } about_virus = cnd.regexp(r"(virus|\bcovid\b|\bill\b|infect|code nineteen|corona|corana|corono|kroner)", re.IGNORECASE) about_coronavirus = cnd.all( [
) from scenario.constants import HIGH_CONF, ZERO_CONF from scenario.processing import location_request_processing from scenario.response import activity_answer_response, activity_question_response, forecast_response flows = { "service": { "start": { RESPONSE: "", TRANSITIONS: { ("weather", "forecast"): cnd.any([ homeland_forecast_requested_condition, cnd.all([ request_with_location_condition, cnd.any([ forecast_requested_condition, forecast_intent_condition ]), ]), ]), ("weather", "location_request"): cnd.any( [forecast_requested_condition, forecast_intent_condition]), ("weather", "continue_question"): chat_about_weather_condition, }, }, "fallback": { RESPONSE: "Oops", PROCESSING: { "set_confidence": int_prs.set_confidence(ZERO_CONF)