Skip to content

Commit bc201d1

Browse files
committed
update order pizza tests
1 parent 9615e12 commit bc201d1

File tree

7 files changed

+99
-125
lines changed

7 files changed

+99
-125
lines changed

actions/order_pizza.py

-31
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,6 @@ def run(self, dispatcher: CollectingDispatcher,
3434
return [SlotSet("membership_points", 150)]
3535

3636

37-
class ActionCorrectOrderDetails(Action):
38-
39-
def name(self) -> str:
40-
return "action_ask_correct_order"
41-
42-
def run(self, dispatcher: CollectingDispatcher,
43-
tracker: Tracker, domain: Dict[str, Any]):
44-
dispatcher.utter_message(
45-
text="I'm sorry about that. Let's correct your order. What would you like to change?",
46-
buttons=[
47-
{"title": "Pizza", "payload": "/SetSlots(pizza=null)"},
48-
{"title": "Quantity", "payload": "/SetSlots(num_pizza=null)"},
49-
{"title": "Address", "payload": "/SetSlots(address=null)"},
50-
]
51-
)
52-
return [SlotSet("confirmation_order", None), SlotSet("correct_order", True)]
53-
54-
5537
class ActionShowVacancies(Action):
5638

5739
def name(self) -> str:
@@ -74,16 +56,3 @@ def run(self, dispatcher: CollectingDispatcher,
7456
text="We don't have any vacancies at the moment in that department. Please check back later."
7557
)
7658
return []
77-
78-
79-
class ActionCorrectAddress(Action):
80-
81-
def name(self) -> str:
82-
return "action_correct_address"
83-
84-
def run(self, dispatcher: CollectingDispatcher,
85-
tracker: Tracker, domain: Dict[str, Any]):
86-
dispatcher.utter_message(
87-
text="I'm sorry about that. Let's correct your address. Please confirm your new address?"
88-
)
89-
return [SlotSet("address", None)]

data/flows/nlu.yml

-35
Original file line numberDiff line numberDiff line change
@@ -165,28 +165,6 @@ nlu:
165165
- [3](number) pizzas
166166
- [4](number) pizzas
167167
168-
- intent: correct_order
169-
examples: |
170-
- I actually need to update my order.
171-
- I made a mistake in my order.
172-
- I need to change my order.
173-
- I made a mistake in the delivery address.
174-
- I need to update the delivery address.
175-
- I made a mistake in the payment option.
176-
177-
- intent: correct_num_pizza
178-
examples: |
179-
- I actually want to order [2](number) pizzas.
180-
- Need [10](number) pizzas now instead.
181-
- I actually want to order [3](number) pizzas.
182-
- I actually want to order [4](number) pizzas.
183-
- I actually want to order [5](number) pizzas.
184-
- I actually want to order [6](number) pizzas.
185-
- I actually want to order [7](number) pizzas.
186-
- I actually want to order [8](number) pizzas.
187-
- I actually want to order [9](number) pizzas.
188-
- I actually want to order [10](number) pizzas.
189-
190168
- intent: correct_pizza_type
191169
examples: |
192170
- I actually want to order a [margherita](pizza_type) pizza.
@@ -202,19 +180,6 @@ nlu:
202180
- Actually, can i get a [diavola](pizza_type) instead.
203181
- Actually, can i get a [quattro formaggi](pizza_type) instead.
204182
205-
- intent: correct_address
206-
examples: |
207-
- I actually want to change the delivery address to 13 Pine Road.
208-
- actually can i get the pizza delivered to 13 Pine Road.
209-
- I made a mistake and need to update my delivery address first to 43 Elm Street.
210-
- Send the pizza to 25 Maple Avenue instead.
211-
- I need to update the delivery address to 59 Oak Drive.
212-
213-
- intent: correct_payment_option
214-
examples: |
215-
- Can I pay with credit card instead?
216-
- I actually want to pay with membership points.
217-
218183
- intent: affirm
219184
examples: |
220185
- Yes, that's correct.

data/flows/order_pizza.yml

-22
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,6 @@ flows:
6363
next: END
6464
- else: END
6565

66-
correct_order:
67-
name: correct_order
68-
description: user wants to correct order details
69-
nlu_trigger:
70-
- intent:
71-
name: correct_order
72-
confidence_threshold: 0.5
73-
steps:
74-
- collect: correct_order
75-
- call: fill_pizza_order
76-
77-
correct_address:
78-
name: correct_address
79-
description: user wants to correct the delivery address
80-
nlu_trigger:
81-
- intent:
82-
name: correct_address
83-
confidence_threshold: 0.7
84-
steps:
85-
- action: action_correct_address
86-
- call: fill_pizza_order
87-
8866
job_vacancies:
8967
name: job vacancies
9068
description: user asks for job vacancies

domain/flows/order_pizza.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ intents:
66
- inform_pizza_type
77
- inform_address
88
- inform_num_pizza
9-
- correct_order
10-
- correct_num_pizza
119
- correct_pizza_type
12-
- correct_address
13-
- correct_payment_option
1410
- affirm
1511
- deny
1612

@@ -24,6 +20,7 @@ slots:
2420
mappings:
2521
- type: from_entity
2622
entity: pizza_type
23+
- type: from_llm
2724
num_pizza:
2825
type: float
2926
mappings:
@@ -32,19 +29,20 @@ slots:
3229
intent: inform_num_pizza
3330
conditions:
3431
- active_flow: fill_pizza_order
35-
- type: from_entity
36-
entity: number
37-
intent: correct_num_pizza
32+
- type: from_llm
33+
allow_nlu_correction: true
3834
conditions:
39-
- active_flow: fill_pizza_order
40-
- active_flow: order_pizza
35+
- active_flow: fill_pizza_order
36+
- active_flow: order_pizza
4137
address:
4238
type: text
4339
mappings:
4440
- type: from_text
4541
intent: inform_address
4642
conditions:
4743
- active_flow: fill_pizza_order
44+
- type: from_llm
45+
allow_nlu_correction: true
4846
confirmation_order:
4947
type: bool
5048
mappings:

e2e_tests/passing/corrections/user_corrects_slot_with_nlu_based_mapping.yml

+8-10
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ test_cases:
4646
- user: /SetSlots(confirmation_order=True)
4747
- utter: utter_ask_payment_option
4848
- user: wait, i meant to say the pizza should be delivered to 13 Pine Road.
49-
- bot: "I'm sorry about that. Let's correct your address. Please confirm your new address?"
50-
- utter: utter_ask_address
51-
- user: 13 Pine Road
49+
- bot: Would you like to change the address?
50+
- user: /SetSlots(confirm_slot_correction=true)
51+
- utter: utter_corrected_previous_input
5252
- utter: utter_confirm
5353
- user: /SetSlots(confirmation_order=True)
54-
- utter: utter_flow_continue_interrupted
5554
- utter: utter_ask_payment_option
5655

5756
- test_case: user_orders_pizza_stating_which_type_and_corrects_payment_option_later
@@ -72,7 +71,7 @@ test_cases:
7271
- utter: utter_corrected_previous_input
7372
- utter: utter_ask_card_details
7473

75-
- test_case: user_orders_pizza_stating_which_type_and_corrects_order_details_later
74+
- test_case: user_orders_pizza_stating_which_type_and_corrects_address_mistake_later
7675
steps:
7776
- user: I would like to order a diavola pizza.
7877
- utter: utter_ask_num_pizza
@@ -83,12 +82,11 @@ test_cases:
8382
- user: /SetSlots(confirmation_order=True)
8483
- utter: utter_ask_payment_option
8584
- user: actually, i made a mistake and need to update my delivery address first.
86-
- bot: "I'm sorry about that. Let's correct your order. What would you like to change?"
87-
# TODO: ideal place to assert planned buttons feature in e2e testing
88-
- user: /SetSlots(address=null)
85+
- bot: Would you like to change the address?
86+
- user: /SetSlots(confirm_slot_correction=true)
87+
- utter: utter_corrected_previous_input
8988
- utter: utter_ask_address
90-
- user: 3 Pine Road
89+
- user: 31 Pine Road
9190
- utter: utter_confirm
9291
- user: /SetSlots(confirmation_order=True)
93-
- utter: utter_flow_continue_interrupted
9492
- utter: utter_ask_payment_option

e2e_tests_with_assertions/passing/corrections/user_corrects_slot_with_nlu_based_mapping.yml

+77-17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
metadata:
2+
- duplicate_confirmation:
3+
turn_idx: 2
14
test_cases:
25
- test_case: user_orders_pizza_stating_which_type_and_corrects_quantity_later
36
steps:
@@ -120,21 +123,18 @@ test_cases:
120123
utter_name: utter_ask_payment_option
121124
- user: wait, i meant to say the pizza should be delivered to 13 Pine Road.
122125
assertions:
126+
- flow_started: pattern_correction
123127
- bot_uttered:
124-
text_matches: "I'm sorry about that. Let's correct your address. Please confirm your new address?"
125-
- slot_was_set:
126-
- name: address
127-
value: null
128-
- bot_uttered:
129-
utter_name: utter_ask_address
130-
- user: 13 Pine Road
128+
utter_name: utter_ask_confirm_slot_correction
129+
- user: /SetSlots(confirm_slot_correction=true)
131130
assertions:
132131
- slot_was_set:
133132
- name: address
134133
value: 13 Pine Road
135134
- bot_uttered:
136135
utter_name: utter_confirm
137136
- user: /SetSlots(confirmation_order=True)
137+
metadata: duplicate_confirmation
138138
assertions:
139139
- bot_uttered:
140140
utter_name: utter_ask_payment_option
@@ -189,7 +189,7 @@ test_cases:
189189
- bot_uttered:
190190
utter_name: utter_ask_card_details
191191

192-
- test_case: user_orders_pizza_stating_which_type_and_corrects_order_details_later
192+
- test_case: user_orders_pizza_stating_which_type_and_corrects_generically_later
193193
steps:
194194
- user: I would like to order a diavola pizza.
195195
assertions:
@@ -218,17 +218,16 @@ test_cases:
218218
utter_name: utter_ask_payment_option
219219
- user: actually, i made a mistake and need to update my delivery address first.
220220
assertions:
221+
- flow_started: pattern_correction
221222
- bot_uttered:
222-
text_matches: "I'm sorry about that. Let's correct your order. What would you like to change?"
223-
buttons:
224-
- title: Pizza
225-
payload: /SetSlots(pizza=null)
226-
- title: Quantity
227-
payload: /SetSlots(num_pizza=null)
228-
- title: Address
229-
payload: /SetSlots(address=null)
230-
- user: /SetSlots(address=null)
223+
utter_name: utter_ask_confirm_slot_correction
224+
- user: /SetSlots(confirm_slot_correction=true)
231225
assertions:
226+
- slot_was_set:
227+
- name: confirm_slot_correction
228+
value: true
229+
- bot_uttered:
230+
utter_name: utter_corrected_previous_input
232231
- bot_uttered:
233232
utter_name: utter_ask_address
234233
- user: 3 Pine Road
@@ -239,6 +238,67 @@ test_cases:
239238
- bot_uttered:
240239
utter_name: utter_confirm
241240
- user: /SetSlots(confirmation_order=True)
241+
metadata: duplicate_confirmation
242242
assertions:
243243
- bot_uttered:
244244
utter_name: utter_ask_payment_option
245+
246+
- test_case: user_orders_pizza_then_corrects_pizza_type_and_number_and_address
247+
steps:
248+
- user: I'd like to order some pizza.
249+
assertions:
250+
- bot_uttered:
251+
utter_name: utter_ask_pizza
252+
- user: Could I have a cappriciosa?
253+
assertions:
254+
- slot_was_set:
255+
- name: pizza
256+
value: cappriciosa
257+
- bot_uttered:
258+
utter_name: utter_ask_num_pizza
259+
- user: 3 please
260+
assertions:
261+
- slot_was_set:
262+
- name: num_pizza
263+
value: 3
264+
- bot_uttered:
265+
utter_name: utter_ask_address
266+
- user: wait can i actually just get 1 festa de carne pizza instead
267+
assertions:
268+
- flow_started: pattern_correction
269+
- bot_uttered:
270+
utter_name: utter_ask_confirm_slot_correction
271+
- user: /SetSlots(confirm_slot_correction=true)
272+
assertions:
273+
- slot_was_set:
274+
- name: pizza
275+
value: festa de carne
276+
- slot_was_set:
277+
- name: num_pizza
278+
value: 1
279+
- bot_uttered:
280+
utter_name: utter_corrected_previous_input
281+
- bot_uttered:
282+
utter_name: utter_ask_address
283+
- user: 30 Pine Road
284+
assertions:
285+
- slot_was_set:
286+
- name: address
287+
value: 30 Pine Road
288+
- bot_uttered:
289+
utter_name: utter_confirm
290+
- user: oh I gave my work address, i actually want it delivered to my home at 13 Pine Road
291+
assertions:
292+
- flow_started: pattern_correction
293+
- bot_uttered:
294+
utter_name: utter_ask_confirm_slot_correction
295+
- user: /SetSlots(confirm_slot_correction=true)
296+
metadata: duplicate_confirmation
297+
assertions:
298+
- slot_was_set:
299+
- name: address
300+
value: 13 Pine Road
301+
- bot_uttered:
302+
utter_name: utter_corrected_previous_input
303+
- bot_uttered:
304+
utter_name: utter_confirm

endpoints.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ action_endpoint:
5757
#
5858
nlg:
5959
type: rephrase
60+
llm:
61+
model_group: openai-direct-gpt-4o
6062

6163
# Run OTEL collector (via `otel-docker-compose.yml`), and uncomment this section, to send traces to it.
6264
# tracing:
@@ -94,4 +96,8 @@ model_groups:
9496
model: gpt-3.5-turbo-0125
9597
timeout: 7
9698
temperature: 0.0
97-
top_p: 0.0
99+
top_p: 0.0
100+
- id: openai-direct-gpt-4o
101+
models:
102+
- provider: openai
103+
model: gpt-4o

0 commit comments

Comments
 (0)