Skip to content

Commit

Permalink
Keep multistep config in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchariGr committed Jul 3, 2024
2 parents 397fccd + 99e28cb commit 35320a6
Show file tree
Hide file tree
Showing 25 changed files with 258 additions and 146 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/continous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ jobs:
make test-passing
- name: Run e2e flaky tests
if: always()
env:
OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}}
RASA_PRO_LICENSE: ${{secrets.RASA_PRO_LICENSE}}
Expand All @@ -193,6 +194,7 @@ jobs:
make test-flaky || true
- name: Run e2e failing tests
if: always()
env:
OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}}
RASA_PRO_LICENSE: ${{secrets.RASA_PRO_LICENSE}}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,5 @@ dmypy.json
models/
.config/
.keras/
prompts/
tests/
16 changes: 15 additions & 1 deletion actions/order_pizza.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def run(self, dispatcher: CollectingDispatcher,
)
return [SlotSet("confirmation_order", None), SlotSet("correct_order", True)]

class ActionShowVacancie(Action):

class ActionShowVacancies(Action):

def name(self) -> str:
return "action_show_vacancies"
Expand All @@ -73,3 +74,16 @@ def run(self, dispatcher: CollectingDispatcher,
text="We don't have any vacancies at the moment in that department. Please check back later."
)
return []


class ActionCorrectAddress(Action):

def name(self) -> str:
return "action_correct_address"

def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker, domain: Dict[str, Any]):
dispatcher.utter_message(
text="I'm sorry about that. Let's correct your address. Please confirm your new address?"
)
return [SlotSet("address", None)]
5 changes: 4 additions & 1 deletion actions/search_hotel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ async def run(
returned through the endpoint
"""

return [SlotSet("hotel_name", "Shadyside Inn"), SlotSet("hotel_average_rating", 2)]
metadata = tracker.latest_message.get("metadata", {})
hotel_name = metadata.get("hotel_name", "Shadyside Inn")
hotel_average_rating = metadata.get("hotel_average_rating", 2)
return [SlotSet("hotel_name", hotel_name), SlotSet("hotel_average_rating", hotel_average_rating)]
15 changes: 8 additions & 7 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ pipeline:
openai_api_base: "https://devtribe-testing-canada-east.openai.azure.com/"
openai_api_type: azure
openai_api_version: "2024-02-01"
llm:
model_name: "gpt-35-turbo"
engine: "test-gpt-35-turbo"
api_type: "azure"
api_version: "2024-02-01"
openai_api_base: "https://devtribe-testing-canada-east.openai.azure.com/"
request_timeout: 7
#- name: SingleStepLLMCommandGenerator
# llm:
# model_name: "gpt-35-turbo"
# engine: "test-gpt-35-turbo"
# api_type: "azure"
# api_version: "2024-02-01"
# openai_api_base: "https://devtribe-testing-canada-east.openai.azure.com/"
# request_timeout: 7

policies:
- name: RulePolicy
Expand Down
45 changes: 28 additions & 17 deletions data/flows/nlu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ nlu:
- Remove an entry from my contact list.
- Help me delete a contact permanently.
- intent: inform_pizza
- intent: request_pizza
examples: |
- Can i get a pizza please?
- I would like to order a pizza.
Expand All @@ -130,6 +130,25 @@ nlu:
- I would like to order a [diavola](pizza_type) pizza.
- I would like to order a [quattro formaggi](pizza_type) pizza.
- intent: inform_pizza_type
examples: |
- [margherita](pizza_type)
- [pepperoni](pizza_type)
- [vegetarian](pizza_type)
- [hawaiian](pizza_type)
- [diavola](pizza_type)
- [quattro formaggi](pizza_type)
- a [margherita](pizza_type) pizza
- a [pepperoni](pizza_type) pizza
- a [vegetarian](pizza_type) pizza
- a [hawaiian](pizza_type) pizza
- a [diavola](pizza_type) pizza
- a [quattro formaggi](pizza_type) and a [margherita](pizza_type) pizza
- a [quattro formaggi](pizza_type) and a [pepperoni](pizza_type) pizza
- a [quattro formaggi](pizza_type) and a [vegetarian](pizza_type) pizza
- a [quattro formaggi](pizza_type) and a [hawaiian](pizza_type) pizza
- a [quattro formaggi](pizza_type) and a [diavola](pizza_type) pizza
- intent: inform_address
examples: |
- 1234 Main Street
Expand All @@ -146,22 +165,6 @@ nlu:
- [3](number) pizzas
- [4](number) pizzas
- intent: ask_availability
examples: |
- Do you have any pizzas left?
- Are there any [diavola](pizza_type) pizzas in stock?
- Can I still order a [margherita](pizza_type) pizza?
- Are there any pizzas available for delivery?
- Can I order a pizza now?
- Do you have any pizzas available for delivery?
- Can I still get a pizza delivered?
- Are there any pizzas left for delivery?
- Can I order a pizza for delivery now?
- Do you have any [margherita](pizza_type) pizzas available for takeout?
- Can I still get a [pepperoni](pizza_type) pizza for takeout?
- Are there any pizzas left for takeout?
- Can I order a [diavola](pizza_type) pizza for takeout now?
- intent: correct_order
examples: |
- I actually need to update my order.
Expand Down Expand Up @@ -199,6 +202,14 @@ nlu:
- Actually, can i get a [diavola](pizza_type) instead.
- Actually, can i get a [quattro formaggi](pizza_type) instead.
- intent: correct_address
examples: |
- I actually want to change the delivery address to 13 Pine Road.
- actually can i get the pizza delivered to 13 Pine Road.
- I made a mistake and need to update my delivery address first to 43 Elm Street.
- Send the pizza to 25 Maple Avenue instead.
- I need to update the delivery address to 59 Oak Drive.
- intent: correct_payment_option
examples: |
- Can I pay with credit card instead?
Expand Down
14 changes: 13 additions & 1 deletion data/flows/order_pizza.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ flows:
description: user asks for a pizza
nlu_trigger:
- intent:
name: inform_pizza
name: request_pizza
confidence_threshold: 0.5
steps:
- call: fill_pizza_order
Expand Down Expand Up @@ -48,6 +48,7 @@ flows:
- collect: address
- collect: confirmation_order
reset_after_flow_ends: False
ask_before_filling: True

use_membership_points:
if: False
Expand All @@ -73,6 +74,17 @@ flows:
- collect: correct_order
- call: fill_pizza_order

correct_address:
name: correct_address
description: user wants to correct the delivery address
nlu_trigger:
- intent:
name: correct_address
confidence_threshold: 0.7
steps:
- action: action_correct_address
- call: fill_pizza_order

job_vacancies:
name: job vacancies
description: user asks for job vacancies
Expand Down
7 changes: 4 additions & 3 deletions domain/flows/order_pizza.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ version: "3.1"

intents:
- greet
- inform_pizza
- request_pizza
- inform_pizza_type
- inform_address
- inform_num_pizza
- ask_availability
- correct_order
- correct_num_pizza
- correct_pizza_type
- correct_address
- correct_payment_option
- affirm
- deny

entities:
- pizza_type
- address
- department

slots:
Expand Down Expand Up @@ -126,3 +126,4 @@ actions:
- action_check_points
- action_ask_correct_order
- action_show_vacancies
- action_correct_address
4 changes: 2 additions & 2 deletions domain/flows/patterns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ responses:
utter_ask_confirm_slot_correction:
- text: "Do you want to update the {{ context.corrected_slots.keys()|join(', ') }}?"
buttons:
- payload: yes
- payload: /SetSlots(confirm_slot_correction=true)
title: "Yes"
- payload: no
- payload: /SetSlots(confirm_slot_correction=false)
title: "No, please keep the previous information"
metadata:
rephrase: True
Expand Down
4 changes: 0 additions & 4 deletions domain/nlu-based/restaurant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ slots:
mappings:
- type: from_entity
entity: number
conditions:
- active_loop: restaurant_form
restaurant_name:
type: text
mappings:
Expand All @@ -51,8 +49,6 @@ slots:
mappings:
- type: from_entity
entity: time
conditions:
- active_loop: restaurant_form

actions:
- action_list_restaurants
Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/passing/corrections/user_cancels_correction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_cases:
- utter: utter_ask_transfer_money_final_confirmation
- user: Ah wait I think I actually owe him 60
- utter: utter_ask_confirm_slot_correction
- user: "No"
- user: /SetSlots(confirm_slot_correction=false)
- utter: utter_not_corrected_previous_input
- utter: utter_ask_transfer_money_final_confirmation
- user: "Yes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_cases:
- utter: utter_ask_verify_account_sufficient_california_income
- user: sorry, I need to correct the previous input
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- utter: utter_corrected_previous_input
- slot_was_set:
- based_in_california
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_cases:
- utter: utter_ask_transfer_money_final_confirmation
- user: Ah, scratch that, I meant 110$
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- slot_was_set:
- transfer_money_amount_of_money: "110"
- utter: utter_corrected_previous_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_cases:
- utter: utter_ask_transfer_money_final_confirmation
- user: Ah, not 50, I meant 55
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- slot_was_set:
- transfer_money_amount_of_money: "55"
- utter: utter_corrected_previous_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_cases:
- utter: utter_ask_transfer_money_amount_of_money
- user: Sorry, I meant to say Jimmy, not John
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- slot_was_set:
- transfer_money_recipient: Jimmy
- utter: utter_corrected_previous_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_cases:
- utter: utter_ask_transfer_money_amount_of_money
- user: Sorry, I meant to say Joe
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- slot_was_set:
- transfer_money_recipient: Joe
- utter: utter_corrected_previous_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_cases:
- utter: utter_ask_transfer_money_final_confirmation
- user: Oh wait, I want to send it to James!
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- slot_was_set:
- transfer_money_recipient: James
- utter: utter_corrected_previous_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ test_cases:
- utter: utter_ask_payment_option
- user: actually can i get 2 pizzas instead
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- utter: utter_corrected_previous_input
- utter: utter_confirm
- user: /SetSlots(confirmation_order=True)
- utter: utter_ask_payment_option

- test_case: user_orders_pizza_stating_which_type_and_corrects_pizza_type_later
Expand All @@ -27,8 +29,29 @@ test_cases:
- utter: utter_ask_payment_option
- user: actually can i get a margherita instead
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- utter: utter_corrected_previous_input
- utter: utter_confirm
- user: /SetSlots(confirmation_order=True)
- utter: utter_ask_payment_option

- test_case: user_orders_pizza_stating_which_type_and_corrects_address_later
steps:
- user: I would like to order a diavola pizza.
- utter: utter_ask_num_pizza
- user: 1 please
- utter: utter_ask_address
- user: 31 Pine Road
- utter: utter_confirm
- user: /SetSlots(confirmation_order=True)
- utter: utter_ask_payment_option
- user: wait, i meant to say the pizza should be delivered to 13 Pine Road.
- bot: "I'm sorry about that. Let's correct your address. Please confirm your new address?"
- utter: utter_ask_address
- user: 13 Pine Road
- utter: utter_confirm
- user: /SetSlots(confirmation_order=True)
- utter: utter_flow_continue_interrupted
- utter: utter_ask_payment_option

- test_case: user_orders_pizza_stating_which_type_and_corrects_payment_option_later
Expand All @@ -45,7 +68,7 @@ test_cases:
- utter: utter_ask_user_name
- user: actually can i pay with a credit card
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- utter: utter_corrected_previous_input
- utter: utter_ask_card_details

Expand All @@ -61,9 +84,11 @@ test_cases:
- utter: utter_ask_payment_option
- user: actually, i made a mistake and need to update my delivery address first.
- bot: "I'm sorry about that. Let's correct your order. What would you like to change?"
# TODO: ideal place to test next buttons feature in e2e testing
# TODO: ideal place to assert planned buttons feature in e2e testing
- user: /SetSlots(address=null)
# FIXME: To uncomment once ATO-2553 is fixed
# - utter: utter_ask_address
# - user: 3 Pine Road
# - utter: utter_confirm
- utter: utter_ask_address
- user: 3 Pine Road
- utter: utter_confirm
- user: /SetSlots(confirmation_order=True)
- utter: utter_flow_continue_interrupted
- utter: utter_ask_payment_option
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_cases:
- utter: utter_ask_add_contact_confirmation
- user: Ah, please use Spidey as the name
- utter: utter_ask_confirm_slot_correction
- user: "yes"
- user: /SetSlots(confirm_slot_correction=true)
- utter: utter_corrected_previous_input
- utter: utter_ask_add_contact_confirmation
- user: "yes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_cases:
- utter: utter_ask_confirm_slot_correction
- user: damn, should be Alex
- utter: utter_ask_confirm_slot_correction
- user: "Yes"
- user: /SetSlots(confirm_slot_correction=true)
- slot_was_set:
- transfer_money_recipient: Alex
- utter: utter_corrected_previous_input
Expand Down
Loading

0 comments on commit 35320a6

Please sign in to comment.