Beispiel #1
0
import common.dff.integration.processing as int_prs
import scenario.condition as loc_cnd
import scenario.processing as loc_prs
import common.universal_templates as templates
from common.art import SUPER_CONFIDENCE, HIGH_CONFIDENCE

sentry_sdk.init(getenv("SENTRY_DSN"))

logger = logging.getLogger(__name__)

flows = {
    GLOBAL: {
        TRANSITIONS: {
            ("art", "drawing_q", 2):
            cnd.all([
                loc_cnd.art_skill_switch,
                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,
Beispiel #2
0
from . import condition as loc_cnd
from . import response as loc_rsp

logger = logging.getLogger(__name__)

flows = {
    GLOBAL: {TRANSITIONS: {("story_flow", "fallback_node"): cnd.true()}},
    "story_flow": {
        "start_node": {
            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,
Beispiel #3
0
def check_slot(prop: str) -> bool:
    return to_boolean(universal.get_slot(prop))


check_author_regexp: Callable[[Context, Actor],
                              bool] = to_boolean(universal.get_author_regexp)

check_genre_regexp: Callable[[Context, Actor],
                             bool] = to_boolean(universal.get_genre_regexp)

asked_what = cnd.regexp(re.compile(r"what (are|was|were|it|is)",
                                   re.IGNORECASE))

asked_to_offer_book = cnd.all([
    # int_cnd.is_question,
    is_question,
    cnd.regexp(re.compile(r"(suggest|recommend)", re.IGNORECASE)),
])

asked_about_book = cnd.all([
    # int_cnd.is_question,
    is_question,
    about_book,
])

asked_book_content = cnd.all([
    # int_cnd.is_question,
    is_question,
    cnd.regexp(re.compile(r"what('s| is).+ about\?{0,1}$", re.IGNORECASE)),
])
Beispiel #4
0
SUPER_CONFIDENCE = 1.0
HIGH_CONFIDENCE = 0.98
DEFAULT_CONFIDENCE = 0.95
BIT_LOWER_CONFIDENCE = 0.90
ZERO_CONFIDENCE = 0.0

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,
                ]
            ),
Beispiel #5
0
    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(
    [
        about_virus,
        cnd.any(
            [
                cnd.regexp(
                    r"(corona|corana|corono|clone a|colonel|chrono|quran|corvette|current|kroner|corolla|"
Beispiel #6
0
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)