def __init__(
        self,
        name: str,
        synonyms: List[str],
        intro: Union[str, Utterance],
        question_intent: Optional[Intent] = None,
        buy_info: Optional[BuyInfo] = (None, ),
        types: List[Concept] = [],
        activities_provided: List[Concept] = [],
        things_provided: List[Concept] = [],
    ):
        super().__init__(name=name, synonyms=synonyms)

        if isinstance(intro, str):
            self.intro = Utterance(intro)
        else:
            self.intro = intro

        self.question_intent = question_intent
        self.buy_info = buy_info
        self.types = types
        self.activities_provided = activities_provided
        self.things_provided = things_provided
Esempio n. 2
0
    ActionName,
    Utterance,
)

state_machine = StateMachine(
    initial_state=state_visitor_center.start_state,
    other_states=[
        state_buy_citypass.buy_citypass_state,
        state_book_tour.book_tour_state,
    ],
)

sold_out_stories = [
    Story([
        ActionName("action_trigger_buy_citypass"),
        Utterance("Sorry, we are sold out at the moment."),
    ]),
    Story([
        ActionName("action_trigger_book_tour"),
        Utterance("Sorry, we are sold out of the tours at the moment."),
    ]),
]

stories = (object_stories.stories + common_stories.stories_chitchat +
           sold_out_stories)

chatbot = Chatbot(
    state_machine=state_machine,
    stories=stories,
    objects=places.places,
    additional_intents=places.intents,
Esempio n. 3
0
)
from rasa.shared.nlu.state_machine.state_machine_state import (
    Response,
    StateMachineState,
    Transition,
)

import data_generation.common_nlu.common_intents as common

slot_number_tickets = TextSlot(
    name="citypass_num_tickets",
    entities=["number"],
    intents={
        IntentWithExamples(examples=["Just me", "Myself", "Just the one"]): 1
    },
    prompt_actions=[Utterance("How many tickets do you need?")],
    only_fill_when_prompted=True,
)

slot_citypass_confirmed = BooleanSlot(
    name="citypass_confirmed",
    intents={
        "affirm": True,
        "deny": False,
    },
    prompt_actions=[
        Utterance(
            "Just to confirm. You want {citypass_num_tickets} of the CityPass. Is that correct?"
        ),
    ],
    only_fill_when_prompted=True,
    def __init__(
        self,
        name: str,
        synonyms: List[str],
        intro: Union[str, Utterance],
        question_intent: Optional[Intent] = None,
        buy_info: Optional[BuyInfo] = (None, ),
        types: List[Concept] = [],
        activities_provided: List[Concept] = [],
        things_provided: List[Concept] = [],
        hours: Optional[Union[str, Utterance]] = None,
        details: Optional[Union[str, Utterance]] = None,
        price: Optional[Union[str, Utterance]] = None,
        duration: Optional[Union[str, Utterance]] = None,
        directions: Optional[Union[str, Utterance]] = None,
        opinion: Optional[Union[str, Utterance]] = None,
    ):
        super().__init__(
            name=name,
            synonyms=synonyms,
            intro=intro,
            question_intent=question_intent,
            buy_info=buy_info,
            types=types,
            activities_provided=activities_provided,
            things_provided=things_provided,
        )

        name_altered = "".join(
            e.lower() for e in name
            if e.isalnum() or e.isspace() or e in ["-", "_"])
        name_altered = "_".join(name_altered.split(" "))

        if isinstance(hours, str):
            self.hours = Utterance(hours, name=f"utter_{name_altered}_hours")
        else:
            self.hours = hours

        if isinstance(details, str):
            self.details = Utterance(details,
                                     name=f"utter_{name_altered}_details")
        else:
            self.details = details

        if isinstance(price, str):
            self.price = Utterance(price, name=f"utter_{name_altered}_price")
        else:
            self.price = price

        if isinstance(duration, str):
            self.duration = Utterance(duration,
                                      name=f"utter_{name_altered}_duration")
        else:
            self.duration = duration

        if isinstance(directions, str):
            self.directions = Utterance(
                directions, name=f"utter_{name_altered}_directions")
        else:
            self.directions = directions

        if isinstance(opinion, str):
            self.opinion = Utterance(opinion,
                                     name=f"utter_{name_altered}_opinion")
        else:
            self.opinion = opinion
Esempio n. 5
0
from rasa.shared.nlu.state_machine.state_machine_models import Utterance

import data_generation.common_nlu.common_intents as common
from data_generation.models.story_models import Or, Story

stories_chitchat = [
    Story([
        Or(common.intent_reaction_positive, common.intent_affirm),
        Utterance("Yeah! What else can I help you with?", ),
    ]),
]
Esempio n. 6
0
        "The lasagna for me."
        "Lasagna",
        "I'll get the lasagna",
    ],
)

# What is lasagna?
# What is the special?
# How much is it?
# Do you have vegetarian food?
# Do you have a kids menu?
# Ask about specials
# Ask for recommendations
# What's an entree

action_ask_appetizer = Utterance("What would you like for your appetizer?",
                                 name="utter_ask_appetizer")

action_ask_entree = Utterance("What would you like for your entree?",
                              name="utter_ask_entree")

slot_appetizer = TextSlot(
    name="appetizer",
    intents={
        select_salad: "salad",
        select_soup: "soup",
        select_tatare: "tatare",
    },
    prompt_actions=[
        action_ask_appetizer,
    ],
)
dog_story = Story(
    name="dog_story",
    elements=[
        Or(
            i_like_dogs,
            Intent(examples=[
                "Do you have a dog?",
                "Are you a dog lover?",
                "Do you like dogs?",
                "What do you think about dogs?",
                "Do you like puppies?",
            ]),
        ),
        Utterance(
            text=
            "Dogs are great. I have a cockerspaniel. Are you a dog lover too?"
        ),
        Fork(
            [
                Or(
                    i_like_dogs,
                    "affirm",
                ),
                Utterance(text="Great, we can be friends then."),
            ],
            [
                Or(
                    Intent(examples=[
                        "I love cats",
                        "I prefer cats",
                        "I'm more of a cat person",
Esempio n. 8
0
#         "bus",
#         "I would prefer the bus one",
#         "The last one",
#         "The latter",
#         "The second",
#         "The second one",
#         "The 4pm",
#         "The one at 4 o clock",
#         "The tour at 4",
#         "4 sounds good",
#         "Four",
#     ]
# )

action_ask_tour = Utterance(
    "We have a boat tour of Bath on the River Anon at 3:00 PM. The last City Boat Tour starts at 4:30 PM. We also have a bus tour of Bath at 4:00 PM. Which one would you prefer?"
)

slot_tour = TextSlot(
    name="tour_type",
    # intents={intent_select_bus_tour: "bus", intent_select_boat_tour: "boat",},
    prompt_actions=[
        action_ask_tour,
    ],
)

slot_number_tickets = TextSlot(
    name="tour_num_tickets",
    entities=["number"],
    intents={
        IntentWithExamples(examples=["Just me", "Myself", "Just the one"]): 1
    Utterance,
)

import data_generation.common_nlu.common_intents as common
import data_generation.common_nlu.common_intent_creators as common_creators
import data_generation.chatbots.visitor_center.book_tour.state_book_tour as book_tour
from data_generation.chatbots.visitor_center import places_visitor_center
from data_generation.models.story_models import (
    Intent,
    SlotWasSet,
    Story,
    Fork,
    Or,
)

utter_put_down_boat_tour = Utterance(
    "Sure, I'll put you down for the 3pm boat tour then.")

utter_put_down_bus_tour = Utterance(
    "Sure, I'll put you down for the 4pm bus tour then.")

utter_recommend_boat = Utterance(
    "May I recommend the boat tour? It's a refreshing way to see the city.")

stories_tours = [
    Story(
        name="tours",
        elements=[
            book_tour.action_ask_tour,
            Fork(
                [
                    Intent(common_creators.intent_i_want_to_buy_creator.name),
    examples=[
        "Where's the washroom?",
        "Where is the restroom?",
        "What is the location of the washroom?",
        "I need to find the toilet",
    ],
)
how_are_you_doing_intent = Intent(name="how_are_you_doing",
                                  examples=["How are you doing?"])

slotName = TextSlot(
    name="name",
    entities=["PERSON"],
    prompt_actions=[
        Utterance(
            text="Can I get your name?",
            name="utter_can_i_get_your_name",
        ),
        Utterance(
            text="What about your name?",
            name="utter_what_about_your_name",
        ),
    ],
)

slotHometown = TextSlot(
    name="hometown",
    entities=["GPE", "LOC"],
    prompt_actions=[
        Utterance(text="What is your hometown?",
                  name="utter_what_is_your_hometown")
    ],