Ubuntu
commited on
Commit
·
c8c0c7c
1
Parent(s):
d1ab564
first commit
Browse files- .gitignore/.gitignore +2 -1
- README +8 -0
- actions/__init__.py +0 -0
- actions/actions.py +195 -0
- config.yml +39 -0
- credentials.yml +33 -0
- data/nlu.yml +100 -0
- data/rules.yml +18 -0
- data/stories.yml +38 -0
- domain.yml +55 -0
- endpoints.yml +42 -0
- requirements.txt +2 -0
- reviews.db +0 -0
- server.py +13 -0
- tests/test_stories.yml +91 -0
- web/index.html +21 -0
.gitignore/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
|
|
|
|
1 |
+
*.tar.gz
|
2 |
+
*.pyc
|
README
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
rasa run actions
|
3 |
+
|
4 |
+
rasa run --credentials ./credentials.yml --enable-api --auth-token XYZ123 --model ./models --endpoints ./endpoints.yml --cors "*"
|
5 |
+
|
6 |
+
python3 server.py
|
7 |
+
|
8 |
+
Open localhost:8080 in browser.
|
actions/__init__.py
ADDED
File without changes
|
actions/actions.py
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This files contains your custom actions which can be used to run
|
2 |
+
# custom Python code.
|
3 |
+
#
|
4 |
+
# See this guide on how to implement these action:
|
5 |
+
# https://rasa.com/docs/rasa/custom-actions
|
6 |
+
|
7 |
+
|
8 |
+
# This is a simple example for a custom action which utters "Hello World!"
|
9 |
+
|
10 |
+
# from typing import Any, Text, Dict, List
|
11 |
+
#
|
12 |
+
# from rasa_sdk import Action, Tracker
|
13 |
+
# from rasa_sdk.executor import CollectingDispatcher
|
14 |
+
#
|
15 |
+
#
|
16 |
+
# class ActionHelloWorld(Action):
|
17 |
+
#
|
18 |
+
# def name(self) -> Text:
|
19 |
+
# return "action_hello_world"
|
20 |
+
#
|
21 |
+
# def run(self, dispatcher: CollectingDispatcher,
|
22 |
+
# tracker: Tracker,
|
23 |
+
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
|
24 |
+
#
|
25 |
+
# dispatcher.utter_message(text="Hello World!")
|
26 |
+
#
|
27 |
+
# return []
|
28 |
+
|
29 |
+
from typing import Any, Text, Dict, List
|
30 |
+
import json
|
31 |
+
import requests
|
32 |
+
import sqlite3
|
33 |
+
import textwrap
|
34 |
+
|
35 |
+
|
36 |
+
from rasa_sdk import Action, Tracker
|
37 |
+
from rasa_sdk.events import UserUtteranceReverted
|
38 |
+
from rasa_sdk.executor import CollectingDispatcher
|
39 |
+
|
40 |
+
class ActionDefaultFallback(Action):
|
41 |
+
"""Executes the fallback action and goes back to the previous state
|
42 |
+
of the dialogue"""
|
43 |
+
|
44 |
+
con = None
|
45 |
+
|
46 |
+
def name(self) -> Text:
|
47 |
+
con = sqlite3.connect("./reviews.db")
|
48 |
+
self.cur = con.cursor()
|
49 |
+
return "zir_action_fallback"
|
50 |
+
|
51 |
+
async def run(
|
52 |
+
self,
|
53 |
+
dispatcher: CollectingDispatcher,
|
54 |
+
tracker: Tracker,
|
55 |
+
domain: Dict[Text, Any],
|
56 |
+
) -> List[Dict[Text, Any]]:
|
57 |
+
|
58 |
+
number_results = 3
|
59 |
+
data_dict = {
|
60 |
+
"query": [
|
61 |
+
{
|
62 |
+
"query": tracker.latest_message["text"],
|
63 |
+
"num_results": number_results,
|
64 |
+
"corpus_key": [
|
65 |
+
{
|
66 |
+
"customer_id": "1526022105",
|
67 |
+
"corpus_id": 40
|
68 |
+
}
|
69 |
+
]
|
70 |
+
}
|
71 |
+
]
|
72 |
+
}
|
73 |
+
header = {
|
74 |
+
"customer-id": "1526022105",
|
75 |
+
"x-api-key": "zqt_WvU_2atFHgqYxxT2sQswwIUgogI8K3QeWs0oqA"
|
76 |
+
}
|
77 |
+
payload = json.dumps(data_dict)
|
78 |
+
response = requests.post(f"https://h.serving.zir-ai.io:443/v1/query",
|
79 |
+
data=payload,
|
80 |
+
verify=True,
|
81 |
+
headers=header,
|
82 |
+
timeout=10)
|
83 |
+
parsed = json.loads(response.text)
|
84 |
+
first_resp = parsed["responseSet"][0]["response"][0]
|
85 |
+
last_resp = parsed["responseSet"][0]["response"][-1]
|
86 |
+
textQuery = []
|
87 |
+
print(last_resp["score"])
|
88 |
+
print(first_resp["score"])
|
89 |
+
if last_resp["score"] < 0.3 or first_resp["score"] < 0.3:
|
90 |
+
textQuery.append("I'm sorry, I can't help you.")
|
91 |
+
else:
|
92 |
+
textQuery = print_responses(parsed["responseSet"][0], self.cur)
|
93 |
+
# items = [d['text'] for d in parsed["responseSet"][0]["response"]]
|
94 |
+
textQuery.insert(0, "\n" )
|
95 |
+
textQuery.insert(0, "This is what i found in the reviews:" )
|
96 |
+
textQuery = "\n".join(textQuery)
|
97 |
+
dispatcher.utter_message(text=textQuery)
|
98 |
+
# Revert user message which led to fallback.
|
99 |
+
return [UserUtteranceReverted()]
|
100 |
+
|
101 |
+
|
102 |
+
def print_responses(response_set, sqlite_cursor):
|
103 |
+
"""Print responses to the console."""
|
104 |
+
textList = []
|
105 |
+
for result in response_set["response"]:
|
106 |
+
doc = response_set["document"][result["documentIndex"]]
|
107 |
+
query = f"""
|
108 |
+
SELECT title, date, hotel, review FROM reviews
|
109 |
+
WHERE doc_id="{doc["id"]}"
|
110 |
+
"""
|
111 |
+
for row in sqlite_cursor.execute(query):
|
112 |
+
title, date, hotel, fulltext = row
|
113 |
+
textList.append("**" + title + "**")
|
114 |
+
if is_title(result):
|
115 |
+
textList.append(f"{head(fulltext)}")
|
116 |
+
else:
|
117 |
+
t = result["text"]
|
118 |
+
textList.append(f"{highlight(fulltext, t)}")
|
119 |
+
textList.append("*" + f"{hotel_name(hotel)} reviewed on {date}" + "*")
|
120 |
+
textList.append("\n")
|
121 |
+
break
|
122 |
+
return textList
|
123 |
+
|
124 |
+
def hotel_name(hotel):
|
125 |
+
"""Returns a human-readable name for a hotel."""
|
126 |
+
if hotel == "sheraton_fisherman_s_wharf_hotel":
|
127 |
+
return "Sheraton Fisherman's Wharf Hotel"
|
128 |
+
if hotel == "the_westin_st_francis":
|
129 |
+
return "The Westin St. Francis San Francisco on Union Square"
|
130 |
+
if hotel == "best_western_tuscan_inn_fisherman_s_wharf_a_kimpton_hotel":
|
131 |
+
return "Best Western Fishermans Wharf"
|
132 |
+
return hotel
|
133 |
+
|
134 |
+
|
135 |
+
def highlight(fulltext, snippet):
|
136 |
+
"""Return a result snippet with context, suitable for terminal display."""
|
137 |
+
if snippet in fulltext:
|
138 |
+
start = fulltext.index(snippet)
|
139 |
+
end = start + len(snippet)
|
140 |
+
|
141 |
+
lines = textwrap.wrap(fulltext)
|
142 |
+
start_line = 0
|
143 |
+
end_line = len(lines)
|
144 |
+
pos = 0
|
145 |
+
|
146 |
+
# Figure out which lines to display, and insert ANSI
|
147 |
+
# code to highlight the actual snippet.
|
148 |
+
for x, line in enumerate(lines):
|
149 |
+
next_pos = pos + len(line)
|
150 |
+
|
151 |
+
color_start = pos <= start < next_pos
|
152 |
+
color_end = pos <= end < next_pos
|
153 |
+
|
154 |
+
if color_start and color_end:
|
155 |
+
start_line = end_line = x
|
156 |
+
ips = start - pos - x # insertion point
|
157 |
+
ipe = end - pos - x # insertion point
|
158 |
+
lines[x] = line[:ips] + "**" + line[ips:ipe] + \
|
159 |
+
"**" + line[ipe:]
|
160 |
+
elif color_start:
|
161 |
+
start_line = x
|
162 |
+
ip = start - pos - x # insertion point
|
163 |
+
lines[x] = line[:ip] + "**" + line[ip:]
|
164 |
+
elif color_end:
|
165 |
+
end_line = x
|
166 |
+
ip = end - pos - x # insertion point
|
167 |
+
lines[x] = line[:ip] + "**" + line[ip:]
|
168 |
+
|
169 |
+
pos = next_pos
|
170 |
+
|
171 |
+
# Widen the line selection to include a bit of context.
|
172 |
+
if start_line > 0:
|
173 |
+
start_line -= 1
|
174 |
+
end_line += 2
|
175 |
+
return prettify('\n'.join(lines[start_line:end_line]))
|
176 |
+
return prettify(snippet)
|
177 |
+
|
178 |
+
|
179 |
+
def head(fulltext):
|
180 |
+
"""Returns the first three lines of the review."""
|
181 |
+
lines = textwrap.wrap(fulltext)
|
182 |
+
return prettify('\n'.join(lines[0:3]) + '...')
|
183 |
+
|
184 |
+
|
185 |
+
def is_title(result):
|
186 |
+
"""Returns true if the result is a title match."""
|
187 |
+
for metadatum in result["metadata"]:
|
188 |
+
if metadatum["name"] == "is_title":
|
189 |
+
return metadatum["value"] == "true"
|
190 |
+
return False
|
191 |
+
|
192 |
+
|
193 |
+
def prettify(text):
|
194 |
+
"""Clean up the text to make it more suitable for display."""
|
195 |
+
return text.replace("&", "&").replace(""", "\"")
|
config.yml
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Configuration for Rasa NLU.
|
2 |
+
# https://rasa.com/docs/rasa/nlu/components/
|
3 |
+
language: en
|
4 |
+
|
5 |
+
pipeline:
|
6 |
+
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
|
7 |
+
# # If you'd like to customize it, uncomment and adjust the pipeline.
|
8 |
+
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
|
9 |
+
- name: SpacyNLP
|
10 |
+
- name: SpacyTokenizer
|
11 |
+
- name: SpacyFeaturizer
|
12 |
+
- name: RegexFeaturizer
|
13 |
+
- name: LexicalSyntacticFeaturizer
|
14 |
+
- name: CountVectorsFeaturizer
|
15 |
+
- name: CountVectorsFeaturizer
|
16 |
+
analyzer: "char_wb"
|
17 |
+
min_ngram: 1
|
18 |
+
max_ngram: 4
|
19 |
+
- name: DIETClassifier
|
20 |
+
epochs: 100
|
21 |
+
- name: EntitySynonymMapper
|
22 |
+
- name: ResponseSelector
|
23 |
+
epochs: 100
|
24 |
+
- name: FallbackClassifier
|
25 |
+
threshold: 0.6
|
26 |
+
ambiguity_threshold: 0.1
|
27 |
+
|
28 |
+
# Configuration for Rasa Core.
|
29 |
+
# https://rasa.com/docs/rasa/core/policies/
|
30 |
+
policies:
|
31 |
+
# # No configuration for policies was provided. The following default policies were used to train your model.
|
32 |
+
# # If you'd like to customize them, uncomment and adjust the policies.
|
33 |
+
# # See https://rasa.com/docs/rasa/policies for more information.
|
34 |
+
# - name: MemoizationPolicy
|
35 |
+
# - name: RulePolicy
|
36 |
+
# - name: TEDPolicy
|
37 |
+
# max_history: 5
|
38 |
+
# epochs: 100
|
39 |
+
# constrain_similarities: true
|
credentials.yml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file contains the credentials for the voice & chat platforms
|
2 |
+
# which your bot is using.
|
3 |
+
# https://rasa.com/docs/rasa/messaging-and-voice-channels
|
4 |
+
|
5 |
+
rest:
|
6 |
+
# # you don't need to provide anything here - this channel doesn't
|
7 |
+
# # require any credentials
|
8 |
+
|
9 |
+
|
10 |
+
#facebook:
|
11 |
+
# verify: "<verify>"
|
12 |
+
# secret: "<your secret>"
|
13 |
+
# page-access-token: "<your page access token>"
|
14 |
+
|
15 |
+
#slack:
|
16 |
+
# slack_token: "<your slack token>"
|
17 |
+
# slack_channel: "<the slack channel>"
|
18 |
+
# slack_signing_secret: "<your slack signing secret>"
|
19 |
+
|
20 |
+
#socketio:
|
21 |
+
# user_message_evt: <event name for user message>
|
22 |
+
# bot_message_evt: <event name for bot messages>
|
23 |
+
# session_persistence: <true/false>
|
24 |
+
|
25 |
+
#mattermost:
|
26 |
+
# url: "https://<mattermost instance>/api/v4"
|
27 |
+
# token: "<bot token>"
|
28 |
+
# webhook_url: "<callback URL>"
|
29 |
+
|
30 |
+
# This entry is needed if you are using Rasa X. The entry represents credentials
|
31 |
+
# for the Rasa X "channel", i.e. Talk to your bot and Share with guest testers.
|
32 |
+
rasa:
|
33 |
+
url: "http://localhost:5002/api"
|
data/nlu.yml
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: "2.0"
|
2 |
+
|
3 |
+
nlu:
|
4 |
+
- intent: greet
|
5 |
+
examples: |
|
6 |
+
- hey
|
7 |
+
- hello
|
8 |
+
- hi
|
9 |
+
- hello there
|
10 |
+
- good morning
|
11 |
+
- good evening
|
12 |
+
- moin
|
13 |
+
- hey there
|
14 |
+
- let's go
|
15 |
+
- hey dude
|
16 |
+
- goodmorning
|
17 |
+
- goodevening
|
18 |
+
- good afternoon
|
19 |
+
|
20 |
+
- intent: goodbye
|
21 |
+
examples: |
|
22 |
+
- good afternoon
|
23 |
+
- cu
|
24 |
+
- good by
|
25 |
+
- cee you later
|
26 |
+
- good night
|
27 |
+
- bye
|
28 |
+
- goodbye
|
29 |
+
- have a nice day
|
30 |
+
- see you around
|
31 |
+
- bye bye
|
32 |
+
- see you later
|
33 |
+
|
34 |
+
- intent: affirm
|
35 |
+
examples: |
|
36 |
+
- yes
|
37 |
+
- y
|
38 |
+
- indeed
|
39 |
+
- of course
|
40 |
+
- that sounds good
|
41 |
+
- correct
|
42 |
+
|
43 |
+
- intent: deny
|
44 |
+
examples: |
|
45 |
+
- no
|
46 |
+
- n
|
47 |
+
- never
|
48 |
+
- I don't think so
|
49 |
+
- don't like that
|
50 |
+
- no way
|
51 |
+
- not really
|
52 |
+
|
53 |
+
- intent: ask_location
|
54 |
+
examples: |
|
55 |
+
- Where is the hotel?
|
56 |
+
- The hotel is where?
|
57 |
+
- In which city is the hotel?
|
58 |
+
|
59 |
+
- intent: jumeirah_living
|
60 |
+
examples: |
|
61 |
+
- What is Jumeirah Living?
|
62 |
+
- Is Jumeirah Living a package?
|
63 |
+
- What can yo tell of Jumeirah Living?
|
64 |
+
- Jumeirah Living?
|
65 |
+
- Jumeirah?
|
66 |
+
|
67 |
+
- intent: jumeirah_one
|
68 |
+
examples: |
|
69 |
+
- What is Jumeirah One?
|
70 |
+
- Is Jumeirah One a package?
|
71 |
+
- What can yo tell of Jumeirah One?
|
72 |
+
- Jumeirah One?
|
73 |
+
- Jumeirah?
|
74 |
+
|
75 |
+
- intent: lost_and_found
|
76 |
+
examples: |
|
77 |
+
- What is your policy on list and found items?
|
78 |
+
- I lost something, can it be returned?
|
79 |
+
- Luggage lost
|
80 |
+
- Lost my phone.
|
81 |
+
- Return a lost items?
|
82 |
+
|
83 |
+
- intent: jumeirah
|
84 |
+
examples: |
|
85 |
+
- What is Jumeirah?
|
86 |
+
- Is Jumeirah a hotel or a brand?
|
87 |
+
|
88 |
+
- intent: reservations
|
89 |
+
examples: |
|
90 |
+
- How many rooms do you have?
|
91 |
+
- i want to reserve rooms
|
92 |
+
- Rooms available
|
93 |
+
- Book a room
|
94 |
+
- Need a place to stay for the night
|
95 |
+
|
96 |
+
- intent: out_of_scope
|
97 |
+
examples: |
|
98 |
+
- I want to order food
|
99 |
+
- What is 2 + 2?
|
100 |
+
- Who's the US President?
|
data/rules.yml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: "2.0"
|
2 |
+
|
3 |
+
rules:
|
4 |
+
|
5 |
+
- rule: Say goodbye anytime the user says goodbye
|
6 |
+
steps:
|
7 |
+
- intent: goodbye
|
8 |
+
- action: utter_goodbye
|
9 |
+
|
10 |
+
- rule: Ask the user to rephrase whenever they send a message with low NLU confidence
|
11 |
+
steps:
|
12 |
+
- intent: nlu_fallback
|
13 |
+
- action: zir_action_fallback
|
14 |
+
|
15 |
+
- rule: out of scope
|
16 |
+
steps:
|
17 |
+
- intent: out_of_scope
|
18 |
+
- action: zir_action_fallback
|
data/stories.yml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: "2.0"
|
2 |
+
|
3 |
+
stories:
|
4 |
+
|
5 |
+
- story: faq question
|
6 |
+
steps:
|
7 |
+
- intent: greet
|
8 |
+
- action: utter_greet
|
9 |
+
- intent: reservations
|
10 |
+
- action: utter_reservation
|
11 |
+
|
12 |
+
- story: faq jum liv
|
13 |
+
steps:
|
14 |
+
- intent: greet
|
15 |
+
- action: utter_greet
|
16 |
+
- intent: jumeirah_living
|
17 |
+
- action: utter_jum_liv
|
18 |
+
|
19 |
+
- story: faq jum one
|
20 |
+
steps:
|
21 |
+
- intent: greet
|
22 |
+
- action: utter_greet
|
23 |
+
- intent: jumeirah_one
|
24 |
+
- action: utter_jum_one
|
25 |
+
|
26 |
+
- story: faq jum
|
27 |
+
steps:
|
28 |
+
- intent: greet
|
29 |
+
- action: utter_greet
|
30 |
+
- intent: jumeirah
|
31 |
+
- action: utter_jum
|
32 |
+
|
33 |
+
- story: faq lost
|
34 |
+
steps:
|
35 |
+
- intent: greet
|
36 |
+
- action: utter_greet
|
37 |
+
- intent: lost_and_found
|
38 |
+
- action: utter_lost_found
|
domain.yml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: "2.0"
|
2 |
+
|
3 |
+
intents:
|
4 |
+
- greet
|
5 |
+
- goodbye
|
6 |
+
- affirm
|
7 |
+
- deny
|
8 |
+
- jumeirah_living
|
9 |
+
- jumeirah_one
|
10 |
+
- lost_and_found
|
11 |
+
- jumeirah
|
12 |
+
- reservations
|
13 |
+
- ask_location
|
14 |
+
|
15 |
+
responses:
|
16 |
+
utter_please_rephrase:
|
17 |
+
- text: Sorry I didn't get that. Can you rephrase?
|
18 |
+
|
19 |
+
utter_greet:
|
20 |
+
- text: "Hey! How are you?"
|
21 |
+
|
22 |
+
utter_cheer_up:
|
23 |
+
- text: "Here is something to cheer you up:"
|
24 |
+
image: "https://i.imgur.com/nGF1K8f.jpg"
|
25 |
+
|
26 |
+
utter_did_that_help:
|
27 |
+
- text: "Did that help you?"
|
28 |
+
|
29 |
+
utter_happy:
|
30 |
+
- text: "Great, carry on!"
|
31 |
+
|
32 |
+
utter_goodbye:
|
33 |
+
- text: "Bye"
|
34 |
+
|
35 |
+
utter_reservation:
|
36 |
+
- text: "Please go to 'Check Rates & Book Now' section of the hotel you have a reservation for. You will find and an area called 'Cancellations and Amendments'. For all other amendments and cancellations, email or call our Reservations Office."
|
37 |
+
|
38 |
+
utter_jum_liv:
|
39 |
+
- text: "Jumeirah Living is our luxury brand of residences and serviced apartments. Whether for short, mid-term or extended stays, Jumeirah Living will offer innovative yet personal lifestyle experiences unique to each guest, resident and owner, with a strong emphasis on effortless living."
|
40 |
+
|
41 |
+
utter_jum_one:
|
42 |
+
- text: "Jumeirah One is Jumeirah’s loyalty programme designed to recognise and reward loyal guests of Jumeirah. Guests can enjoy more of life’s pleasures with privileged access to an exclusive global lifestyle."
|
43 |
+
|
44 |
+
utter_lost_found:
|
45 |
+
- text: "Should any guests lose personal belongings whilst staying at a Jumeirah Hotel or Resort in Dubai, if recovered, the item will be recorded as 'found' by that particular property. Each property keeps detailed records of all 'found' items and will store these for a maximum of three months. After this period, in line with the directives of the General Department of Criminal Investigation in Dubai, all unclaimed items will be handed over to the nearest Police Station. These 'found' items will then be kept at the police warehouse for a further three months after which they will be auctioned, and any funds raised given to charity.Should hotel guests need to locate any item after the initial three month period expires, they are requested to contact the hotel who will assist in coordinating with the police station where the found items are handed over. The police will then advise the necessary procedures to locate any item."
|
46 |
+
|
47 |
+
utter_jum:
|
48 |
+
- text: "Jumeirah is a world-class international hotel and hospitality company which currently manages hotels in Abu Dhabi, Bahrain, Dubai, Frankfurt, Kuwait, London, Maldives, Mallorca and Shanghai. Please view our Portfolio for more information."
|
49 |
+
|
50 |
+
session_config:
|
51 |
+
session_expiration_time: 60
|
52 |
+
carry_over_slots_to_new_session: true
|
53 |
+
|
54 |
+
actions:
|
55 |
+
- zir_action_fallback
|
endpoints.yml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file contains the different endpoints your bot can use.
|
2 |
+
|
3 |
+
# Server where the models are pulled from.
|
4 |
+
# https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server
|
5 |
+
|
6 |
+
#models:
|
7 |
+
# url: http://my-server.com/models/default_core@latest
|
8 |
+
# wait_time_between_pulls: 10 # [optional](default: 100)
|
9 |
+
|
10 |
+
# Server which runs your custom actions.
|
11 |
+
# https://rasa.com/docs/rasa/custom-actions
|
12 |
+
|
13 |
+
action_endpoint:
|
14 |
+
url: "http://0.0.0.0:5055/webhook"
|
15 |
+
|
16 |
+
# Tracker store which is used to store the conversations.
|
17 |
+
# By default the conversations are stored in memory.
|
18 |
+
# https://rasa.com/docs/rasa/tracker-stores
|
19 |
+
|
20 |
+
#tracker_store:
|
21 |
+
# type: redis
|
22 |
+
# url: <host of the redis instance, e.g. localhost>
|
23 |
+
# port: <port of your redis instance, usually 6379>
|
24 |
+
# db: <number of your database within redis, e.g. 0>
|
25 |
+
# password: <password used for authentication>
|
26 |
+
# use_ssl: <whether or not the communication is encrypted, default false>
|
27 |
+
|
28 |
+
#tracker_store:
|
29 |
+
# type: mongod
|
30 |
+
# url: <url to your mongo instance, e.g. mongodb://localhost:27017>
|
31 |
+
# db: <name of the db within your mongo instance, e.g. rasa>
|
32 |
+
# username: <username used for authentication>
|
33 |
+
# password: <password used for authentication>
|
34 |
+
|
35 |
+
# Event broker which all conversation events should be streamed to.
|
36 |
+
# https://rasa.com/docs/rasa/event-brokers
|
37 |
+
|
38 |
+
#event_broker:
|
39 |
+
# url: localhost
|
40 |
+
# username: username
|
41 |
+
# password: password
|
42 |
+
# queue: queue
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
sqlite3
|
2 |
+
textwrap
|
reviews.db
ADDED
Binary file (926 kB). View file
|
|
server.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import http.server
|
2 |
+
import socketserver
|
3 |
+
import os
|
4 |
+
|
5 |
+
PORT = 8080
|
6 |
+
|
7 |
+
web_dir = os.path.join(os.path.dirname(__file__), 'web')
|
8 |
+
os.chdir(web_dir)
|
9 |
+
|
10 |
+
Handler = http.server.SimpleHTTPRequestHandler
|
11 |
+
httpd = socketserver.TCPServer(("0.0.0.0", PORT), Handler)
|
12 |
+
print("serving at port", PORT)
|
13 |
+
httpd.serve_forever()
|
tests/test_stories.yml
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#### This file contains tests to evaluate that your bot behaves as expected.
|
2 |
+
#### If you want to learn more, please see the docs: https://rasa.com/docs/rasa/testing-your-assistant
|
3 |
+
|
4 |
+
stories:
|
5 |
+
- story: happy path 1
|
6 |
+
steps:
|
7 |
+
- user: |
|
8 |
+
hello there!
|
9 |
+
intent: greet
|
10 |
+
- action: utter_greet
|
11 |
+
- user: |
|
12 |
+
amazing
|
13 |
+
intent: mood_great
|
14 |
+
- action: utter_happy
|
15 |
+
|
16 |
+
- story: happy path 2
|
17 |
+
steps:
|
18 |
+
- user: |
|
19 |
+
hello there!
|
20 |
+
intent: greet
|
21 |
+
- action: utter_greet
|
22 |
+
- user: |
|
23 |
+
amazing
|
24 |
+
intent: mood_great
|
25 |
+
- action: utter_happy
|
26 |
+
- user: |
|
27 |
+
bye-bye!
|
28 |
+
intent: goodbye
|
29 |
+
- action: utter_goodbye
|
30 |
+
|
31 |
+
- story: sad path 1
|
32 |
+
steps:
|
33 |
+
- user: |
|
34 |
+
hello
|
35 |
+
intent: greet
|
36 |
+
- action: utter_greet
|
37 |
+
- user: |
|
38 |
+
not good
|
39 |
+
intent: mood_unhappy
|
40 |
+
- action: utter_cheer_up
|
41 |
+
- action: utter_did_that_help
|
42 |
+
- user: |
|
43 |
+
yes
|
44 |
+
intent: affirm
|
45 |
+
- action: utter_happy
|
46 |
+
|
47 |
+
- story: sad path 2
|
48 |
+
steps:
|
49 |
+
- user: |
|
50 |
+
hello
|
51 |
+
intent: greet
|
52 |
+
- action: utter_greet
|
53 |
+
- user: |
|
54 |
+
not good
|
55 |
+
intent: mood_unhappy
|
56 |
+
- action: utter_cheer_up
|
57 |
+
- action: utter_did_that_help
|
58 |
+
- user: |
|
59 |
+
not really
|
60 |
+
intent: deny
|
61 |
+
- action: utter_goodbye
|
62 |
+
|
63 |
+
- story: sad path 3
|
64 |
+
steps:
|
65 |
+
- user: |
|
66 |
+
hi
|
67 |
+
intent: greet
|
68 |
+
- action: utter_greet
|
69 |
+
- user: |
|
70 |
+
very terrible
|
71 |
+
intent: mood_unhappy
|
72 |
+
- action: utter_cheer_up
|
73 |
+
- action: utter_did_that_help
|
74 |
+
- user: |
|
75 |
+
no
|
76 |
+
intent: deny
|
77 |
+
- action: utter_goodbye
|
78 |
+
|
79 |
+
- story: say goodbye
|
80 |
+
steps:
|
81 |
+
- user: |
|
82 |
+
bye-bye!
|
83 |
+
intent: goodbye
|
84 |
+
- action: utter_goodbye
|
85 |
+
|
86 |
+
- story: bot challenge
|
87 |
+
steps:
|
88 |
+
- user: |
|
89 |
+
are you a bot?
|
90 |
+
intent: bot_challenge
|
91 |
+
- action: utter_iamabot
|
web/index.html
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<head>
|
2 |
+
<link rel="stylesheet"
|
3 |
+
href="https://npm-scalableminds.s3.eu-central-1.amazonaws.com/@scalableminds/chatroom@master/dist/Chatroom.css" />
|
4 |
+
</head>
|
5 |
+
|
6 |
+
<body>
|
7 |
+
<div class="chat-container"></div>
|
8 |
+
|
9 |
+
<script
|
10 |
+
src="https://npm-scalableminds.s3.eu-central-1.amazonaws.com/@scalableminds/chatroom@master/dist/Chatroom.js" />
|
11 |
+
</script>
|
12 |
+
<script type="text/javascript">
|
13 |
+
var chatroom = new window.Chatroom({
|
14 |
+
host: "http://35.80.14.146:5005",
|
15 |
+
title: "Kendra, powered by Rasa and ZIR AI",
|
16 |
+
container: document.querySelector(".chat-container"),
|
17 |
+
welcomeMessage: "Hello, my name is Kendra, and I'll be happy to assist with your questions about Burj Al Arab Jumeirah. How may I help you"
|
18 |
+
});
|
19 |
+
chatroom.openChat();
|
20 |
+
</script>
|
21 |
+
</body>
|