Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified actions/__pycache__/actions.cpython-38.pyc
Binary file not shown.
145 changes: 0 additions & 145 deletions actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from rasa_sdk.forms import FormValidationAction



class ValidateRestaurantForm(FormValidationAction):
"""Example of a form validation action."""

Expand Down Expand Up @@ -231,149 +230,6 @@ def selectUtterStatment(self,location):
else:
return "utter_default"


class FindRestaurant(Action):
def name(self):
return "find_restaurant"

@staticmethod
def restaurant_db():
"""Database of restaurants."""

return [
{
"name":"7th Block Night Canteen",
"cuisine":["north indian"],
"Outside":True,
"Non-Veg":True
},
{
"name":"NITK Block 3 Night Canteen",
"cuisine":['continental' , 'south indian' ],
"Outside":False,
"Non-Veg":False
},

{
"name":"NITK Food Court (OM Caterers)",
"cuisine":["north indian","south indian"],
"Outside":False,
"Non-Veg":False
},
{
"name":"Samudra Darshan cáfe NITK",
"cuisine":["north indain" , "south indian"],
"Outside":True,
"Non-Veg":False
},
{
"name":"Red Rock Residency",
"cuisine":["north indian"],
"Outside":True,
"Non-Veg":True
},
{
"name":"Red Rock's Bourbon Bakery & Cafe",
"cuisine":["north indian" , "italian","continental"],
"Outside":True,
"Non-Veg":True

},
{
"name":"Jyothi Prakash, Punjabi Dhaba",
"cuisine":["Punjabi" , "north indian"],
"Outside":True,
"Non-Veg":True
},
{
"name":"Kalash Veg Restaurant",
"cuisine":["north indian"],
"Outside":True,
"Non-Veg":True
}

]

async def run(self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]):
cuisine = tracker.get_slot('cuisine')
number_of_seats = tracker.get_slot('number_for_restaurant')
outdoor_seating = tracker.get_slot('outdoor_seating')
preferences = tracker.get_slot('preferences')
feedback = tracker.get_slot('feedback')

# TODO: use above variables to find restaurant using places api
restaurants = self.restaurant_db()
eligible_restaurants = []


dispatcher.utter_message(template="utter_parameters_values")
if cuisine!=None:
for r in restaurants:
# print(r["cuisine"])
if cuisine in r["cuisine"]:
eligible_restaurants.append(r)
restaurants = eligible_restaurants
eligible_restaurants = []
if outdoor_seating!=None:
if outdoor_seating:
for r in restaurants:
if r["Outside"]:
eligible_restaurants.append(r)
restaurants = eligible_restaurants
if len(restaurants):
dispatcher.utter_message(template="utter_found_restaurants")
for r in restaurants:
dispatcher.utter_message(text = r['name'])


events = []
events.append(SlotSet('cuisine',None))
events.append(SlotSet('number_for_restaurant',None))
events.append(SlotSet('outdoor_seating',None))
events.append(SlotSet('preferences',None))
events.append(SlotSet('feedback',None))
return events

class FormDetails(Action):
def name(self):
return "return_form_details"

@staticmethod
def cuisine_db() :
"""Database of supported cuisines."""

return "south indian, north indian, continental, italian, punjabi, mexican and assamese"


async def run(self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]):
cuisine = tracker.get_slot('cuisine')
number_of_seats = tracker.get_slot('number_for_restaurant')
outdoor_seating = tracker.get_slot('outdoor_seating')
required_details = next(tracker.get_latest_entity_values('restaurant_form_details'), None)
if required_details!=None :
if required_details == 'cuisine':
cuisines = self.cuisine_db()
dispatcher.utter_message(text = "Avaialble Cuisines are")
dispatcher.utter_message(text = cuisines)
if required_details == 'people':
dispatcher.utter_message(text = "number of people can range from 1 to 10")
else:
if cuisine == None:
cuisines = self.cuisine_db()
dispatcher.utter_message(text = "Avaialble Cuisines are")
dispatcher.utter_message(text = cuisines)
return []
if number_of_seats == None:
dispatcher.utter_message(text = "Number of people can range from 1 to 10")
return[]
if outdoor_seating == None:
dispatcher.utter_message(text = "Enter Yes if u want to sit outside or no if you want to sit inside")
return[]
return []




class LocationQuery(Action):
def name(self):
return "location_query"
Expand Down Expand Up @@ -471,4 +327,3 @@ def selectUtterStatment(self,department):
return self.department_utter_mapping()[department]
else:
return "utter_default"

30 changes: 1 addition & 29 deletions data/nlu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -678,33 +678,6 @@ nlu:
- When does [hcc](Location) close?
- Till when is the [ccc](Location) open?
- What are the timings of the [health care centre](Location)?


- intent: form_details
examples: |
- which [cuisine](restaurant_form_details) are available ?
- how many [people](restaurant_form_details) are allowed?
- why do you need this?
- what should i enter here?
- I am not understanding what to enter
- I am lost could u help me fill the form

- intent: skip
examples: |
- I want to skip this part
- you are wasting time just get on with it
- I dont have time just book a restaurant
- book asap
- I dont care about these details just finish.
- don't waste time.
- i am okay with anything
- leave the details
- i dont have time for this
- dont waste my time
- just get on with it
- you are asking too many questions
- these are irrelavant questions

- intent: purpose
examples: |
- how can you help me?
Expand Down Expand Up @@ -2197,5 +2170,4 @@ nlu:
- synonym: chem department
examples: |
- chemical department
- chemical engineering department

- chemical engineering department
29 changes: 2 additions & 27 deletions data/stories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,7 @@ stories:
- action: restaurant_form
- active_loop: null
- action: utter_submit
- action: find_restaurant

- story: happy form + form_details
steps:
- intent: request_restaurant
- action: restaurant_form
- active_loop: restaurant_form
- intent: form_details
- action: return_form_details
- action: restaurant_form
- active_loop: null
- action: utter_submit
- action: find_restaurant
- action: utter_slots_values

- story: happy form +
steps:
Expand All @@ -187,7 +175,7 @@ stories:
- active_loop: restaurant_form
- active_loop: null
- action: utter_submit
- action: find_restaurant
- action: utter_slots_values

- story: stop form + stop
steps:
Expand All @@ -200,19 +188,6 @@ stories:
- action: action_deactivate_loop
- active_loop: null


- story: skip form
steps:
- intent: request_restaurant
- action: restaurant_form
- active_loop: restaurant_form
- intent: skip
- action: action_deactivate_loop
- active_loop: null
- action: utter_submit
- action: find_restaurant


- story: happy Central_Computer_Centre
steps:
- intent: Central_Computer_Centre
Expand Down
Loading