Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: python docker image #8

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Pipfile.lock
story_graph.dot

endpoints.yml
results/
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7.7-stretch AS BASE
FROM python:3.7.7-slim AS BASE

RUN apt-get update \
&& apt-get --assume-yes --no-install-recommends install \
Expand All @@ -15,6 +15,7 @@ WORKDIR /app
RUN pip install --no-cache-dir --upgrade pip

RUN pip install rasa==3.2.5
RUN pip install websockets==10.0

ADD config.yml config.yml
ADD domain.yml domain.yml
Expand Down
Empty file.
19 changes: 19 additions & 0 deletions actions/cancel_command_actions/action_cancel_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from typing import Any, Text, Dict, List

from rasa_sdk.events import AllSlotsReset, ActiveLoop
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher


class ActionCancelCommands(Action):
"""This is the action that is called when the user says "cancel"."""

@staticmethod
def name(**kwargs) -> Text:
return "action_cancel_commands"

def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], **kwargs) -> List[
Dict[Text, Any]
]:
dispatcher.utter_message("Okay, cancelling running commands!")
return [AllSlotsReset(), ActiveLoop(None)]
6 changes: 6 additions & 0 deletions actions/car_selection_actions/action_ask_car_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def run(
"action": response.action.as_dict(),
"data": response.data
})
else:
# return a message and deactive the form
print(f"{self.name()}: User is not on car selection or dashboard screen")
dispatcher.utter_message(
text="User is not on car selection or dashboard screen")
return [ActiveLoop(None), SlotSet('car_number', None)]
# else:
# return a message and deactive the form
# print(f"{self.name()}: {metadata['type']} is not CAR_SELECTION")
Expand Down
14 changes: 3 additions & 11 deletions actions/car_selection_actions/validate_car_selection_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def validate_car_number(
# if s
if slot_value.lower() not in ALLOWED_CAR_NUMBER:
response = car_utils.return_response(
"Please specify a correct number that is one, two or three")
"Please specify a correct number that is first, second, or third")
dispatcher.utter_message(json_message={
"query": response.query,
"reply": response.reply,
Expand All @@ -78,7 +78,7 @@ def validate_car_number(
return {"car_number": None, "next_car": True, "previous_car": False,
"select_car_iteration": return_select_car_iteration}
if slot_value.lower() == "previous" and select_car_iteration == 0:
response = car_utils.return_response(available_message)
response = car_utils.return_response("You are on the first list, you can't go previous")
dispatcher.utter_message(json_message={
"query": response.query,
"reply": response.reply,
Expand Down Expand Up @@ -115,11 +115,6 @@ def validate_car_verification(
"""Validate `car_number` value."""

print("Slot Value", slot_value)
intent = None
try:
intent = tracker.latest_message['intent'].get('name')
except KeyError:
print(f"No intent, something went wrong, error:{Exception}")

select_car_iteration = tracker.get_slot("select_car_iteration")
metadata = tracker.latest_message.get("metadata")
Expand All @@ -136,7 +131,7 @@ def validate_car_verification(
response = car_utils.return_response(available_message)
dispatcher.utter_message(json_message={
"query": response.query,
"reply": response.reply,
"reply": f"Okay reverting the last decision, {response.reply}",
"action": response.action.as_dict(),
"data": response.data
})
Expand Down Expand Up @@ -181,13 +176,10 @@ def validate_car_selection(self, dispatcher: CollectingDispatcher, slot_value: s

# TODO: new function -> reset only car selection related slots
if slot_value == "third" and len(available_cars) >= 3:
# dispatcher.utter_message(text=f"{available_cars[2]} car is available")
return {"car_number": "third", "car_name": available_cars[2]}
if slot_value == "second" and len(available_cars) >= 2:
# dispatcher.utter_message(text=f"{available_cars[1]} car is available")
return {"car_number": "second", "car_name": available_cars[1]}
if slot_value == "first" and len(available_cars) >= 1:
# dispatcher.utter_message(text=f"{available_cars[0]} car is available")
return {"car_number": "first", "car_name": available_cars[0]}

print(f"{self.name()}: Something went wrong with validating car selection and assigning 'car_name' slot.")
Expand Down
10 changes: 5 additions & 5 deletions actions/start_recording_actions/action_start_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[T
text="Wrong Recording state, Something went wrong!")
return [SlotSet("recording_start_query", False)]
else:
reply = "Recording is already running! Navigating to recording screen"
reply = "User is not on dashboard screen, Please navigate to Dashboard screen and ask start recording again."
nav_to_recording_screen(dispatcher, message, reply, intent)
return [SlotSet("recording_start_query", False)]
else:
print(f"{self.name()}: No Recording going on!")
dispatcher.utter_message(
text="There is currently no Recording going on")
return []
print(f"{self.name()}: Recording already going on!")
reply = "Recording is already running! Navigating to recording screen"
nav_to_recording_screen(dispatcher, message, reply, intent)
return [SlotSet("recording_start_query", False)]
# else:
# print(f" {self.name()}: {metadata['type']} is not RECORDING")
# dispatcher.utter_message(
Expand Down
14 changes: 14 additions & 0 deletions data/nlu/nlu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,20 @@ nlu:
- choose [second](car_selection_number) car
- choose [third](car_selection_number) car please

- intent: overall_cancel_command
examples: |
- cancel
- cancel it
- cancel everything
- cancel all
- cancel start recording
- cancel stop recording
- cancel select car
- cancel choose car
- can you cancel this
- please cancel command
- enviroBot cancel this

- synonym: select
examples: |
- select
Expand Down
17 changes: 16 additions & 1 deletion data/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ rules:
- action: utter_iamabot

- rule: Run a followup start action anytime the user affirms
condition:
- active_loop: null
steps:
- intent: affirm
- action: action_followup
Expand Down Expand Up @@ -52,4 +54,17 @@ rules:
- active_loop: null
- slot_was_set:
- requested_slot: null
- action: action_car_selection
- action: action_car_selection

- rule: Select a car whenever user affirms in car selection form
condition:
- active_loop: car_selection_form
steps:
- slot_was_set:
- car_verification: yes
- action: action_car_selection

- rule: Run `cancel_commands` action whenever `overall_cancel_command` intent is triggered
steps:
- intent: overall_cancel_command
- action: action_cancel_commands
4 changes: 1 addition & 3 deletions domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ actions:
- action_ask_car_verification
- action_car_selection
- action_followup
- action_cancel_commands

forms:
car_selection_form:
Expand Down Expand Up @@ -92,7 +93,6 @@ slots:
requested_slot: car_number
car_name:
type: text
influence_conversation: true
mappings:
- type: custom
conditions:
Expand All @@ -110,15 +110,13 @@ slots:
requested_slot: select_car_iteration
next_car:
type: bool
influence_conversation: true
mappings:
- type: custom
conditions:
- active_loop: car_selection_form
requested_slot: next_car
previous_car:
type: bool
influence_conversation: true
mappings:
- type: custom
conditions:
Expand Down