-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
actions.py
51 lines (39 loc) 路 1.54 KB
/
actions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
class ActionSearchConcerts(Action):
def name(self):
return "action_search_concerts"
def run(self, dispatcher, tracker, domain):
concerts = [
{"artist": "Foo Fighters", "reviews": 4.5},
{"artist": "Katy Perry", "reviews": 5.0},
]
description = ", ".join([c["artist"] for c in concerts])
dispatcher.utter_message(f"{description}")
return [SlotSet("concerts", concerts)]
class ActionSearchVenues(Action):
def name(self):
return "action_search_venues"
def run(self, dispatcher, tracker, domain):
venues = [
{"name": "Big Arena", "reviews": 4.5},
{"name": "Rock Cellar", "reviews": 5.0},
]
dispatcher.utter_message("here are some venues I found")
description = ", ".join([c["name"] for c in venues])
dispatcher.utter_message(f"{description}")
return [SlotSet("venues", venues)]
class ActionShowConcertReviews(Action):
def name(self):
return "action_show_concert_reviews"
def run(self, dispatcher, tracker, domain):
concerts = tracker.get_slot("concerts")
dispatcher.utter_message(f"concerts from slots: {concerts}")
return []
class ActionShowVenueReviews(Action):
def name(self):
return "action_show_venue_reviews"
def run(self, dispatcher, tracker, domain):
venues = tracker.get_slot("venues")
dispatcher.utter_message(f"venues from slots: {venues}")
return []