Skip to content

Commit

Permalink
Release 7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
il1tvinov committed Jul 31, 2020
1 parent 17e3e8e commit 9061ea2
Show file tree
Hide file tree
Showing 170 changed files with 5,471 additions and 2,542 deletions.
File renamed without changes.
11 changes: 11 additions & 0 deletions chatbot/Dockerfile-core
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM rasa/rasa:1.10.3-full

WORKDIR /app

COPY ./actions/requirements.txt ./

USER root

RUN pip install -r requirements.txt

COPY . /app/
50 changes: 46 additions & 4 deletions chatbot/actions/actions.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
from typing import Dict, Text, Any, List, Union
from datetime import datetime

from pytz import utc
from rasa_sdk import Tracker, Action
from rasa_sdk.forms import FormAction
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import SlotSet, FollowupAction, AllSlotsReset
from rasa_sdk.events import AllSlotsReset

from parsedatetime import Calendar

import requests


def convert_date(raw_date: str) -> str:
def convert_date(raw_date: str) -> tuple:
def _get_datetime_range(date: str) -> tuple:
""" Makes one day period by received date.
Parameters
----------
date:
Date for report generating.
Returns
-------
Datetime range.
"""
date = datetime.strptime(date, "%Y-%m-%d")
from_date = date.astimezone(utc)
from_date = from_date.strftime("%Y-%m-%dT%H:%M:%S.%f%z")

to_date = (
date.replace(hour=23, minute=59, second=59)
.astimezone(utc)
.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
)

return from_date, to_date

parser = Calendar()
date, status = parser.parse(raw_date)
date = datetime(*date[:3])
return date.strftime("%Y-%m-%d")
date = datetime(*date[:3]).strftime("%Y-%m-%d")
return _get_datetime_range(date)


def generate_report(date: str):
Expand Down Expand Up @@ -60,3 +85,20 @@ def submit(
message = generate_report(period)
dispatcher.utter_message(json_message=next(message), timeout=100)
return [AllSlotsReset()]


class ActionDefaultAskAffirmation(Action):
"""Override action default ask affirmation"""

def name(self) -> Text:
return "action_default_ask_affirmation"

def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
dispatcher.utter_message(template="utter_cannot_help")

return []
6 changes: 2 additions & 4 deletions chatbot/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: "en"

pipeline:
Expand All @@ -15,12 +13,12 @@ pipeline:
- name: DIETClassifier
- name: EntitySynonymMapper

# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
- name: MemoizationPolicy
- name: MappingPolicy
- name: TEDPolicy
- name: FormPolicy
- name: TwoStageFallbackPolicy
nlu_threshold: 0.8
fallback_core_action_name: "utter_cannot_help"
fallback_nlu_action_name: "utter_cannot_help"
3 changes: 0 additions & 3 deletions chatbot/credentials.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels/

rest:
# # you don't need to provide anything here - this channel doesn't
Expand Down
20 changes: 18 additions & 2 deletions chatbot/data/nlu.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
- OK
- Roger that
- Deal
- /affirm
- affirm
- ok great!
- okay
- okb;d

## intent:deny
- I don't want to
- NO
- NO DON"T WANT THIS!
- NO DON'T WANT THIS!
- Nah
- Neither
- Never
Expand Down Expand Up @@ -115,6 +115,8 @@
- Status report
- could you give me report please?
- status report for [today](period) please
- report status
- report

## intent:inform
- for [today](period) please
Expand Down Expand Up @@ -146,6 +148,7 @@
- report for [today](period) please
- [Today](period)
- [Yesterday](period)
- [Today](period)

## intent:out_of_scope
- please help with my ice cream it's dripping
Expand Down Expand Up @@ -196,9 +199,22 @@
- are you still here?
- how can I apply for a new job?
- lol
- aksjetk
- qwerty
- polkiujhytg
- zxcvbnmllkjhgfds
- polow
- colololo
- Some text bla bla bla
- elihgfe
- what the weather today?
- -
- tuc
- truto
- _
- dfghjkl
- ::::::
- [][][][]

## intent:goodbye
- Bye
Expand Down
140 changes: 140 additions & 0 deletions chatbot/data/stories.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,143 @@
- utter_what_do_you_can
* goodbye
- utter_goodbye

## interactive_story_1
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* out_of_scope
- utter_cannot_help
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* form: inform{"period": "Today"}
- form: report_form
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}

## interactive_story_1
* out_of_scope
- utter_cannot_help
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* form: inform{"period": "Today"}
- form: report_form
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}

## interactive_story_2
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* out_of_scope
- utter_cannot_help
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* form: inform{"period": "Yesterday"}
- form: report_form
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}

## interactive_story_1
* out_of_scope
- action_default_ask_affirmation
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* form: inform{"period": "Today"}
- form: report_form
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}

## interactive_story_2
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* out_of_scope
- action_default_ask_affirmation
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* form: inform{"period": "Today"}
- form: report_form
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}

## interactive_story_3
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* out_of_scope
- action_default_ask_affirmation
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* form: inform{"period": "Today"}
- form: report_form
- form: reset_slots
- form{"name": null}
- slot{"requested_slot": null}

## interactive_story_1
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* out_of_scope
- utter_cannot_help
* report
- report_form
- slot{"requested_slot": "period"}
* form: inform{"period": "Today"}
- form: report_form

## interactive_story_1
* report
- report_form
- form{"name": "report_form"}
- slot{"requested_slot": "period"}
* out_of_scope
- utter_cannot_help
* report
- report_form
- slot{"requested_slot": "period"}
* out_of_scope
- utter_cannot_help
* report
- report_form
- slot{"requested_slot": "period"}
* out_of_scope
- utter_cannot_help
* report
- report_form
- slot{"requested_slot": "period"}
10 changes: 7 additions & 3 deletions chatbot/domain.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
actions:
- action_default_ask_affirmation
- utter_ask_help
- utter_ask_period
- utter_ask_rephrase
- utter_cannot_help
- utter_describe_yourself
- utter_goodbye
Expand All @@ -13,17 +15,17 @@ entities:
forms:
- report_form
intents:
- out_of_scope
- report
- inform
- deny
- what_do_you_can
- goodbye
- thanks
- inform
- greet
- out_of_scope
- describe_yourself
- intro_nostradamus
- affirm
- deny
responses:
utter_ask_help:
- buttons:
Expand All @@ -41,6 +43,8 @@ responses:
- payload: yesterday
title: Yesterday
text: For which day?
utter_ask_rephrase:
- text: Sorry, I didn't get you.
utter_cannot_help:
- text: Sorry, I don't get it.
- text: I can't help you with that.
Expand Down
Binary file not shown.
17 changes: 10 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ services:
build:
context: ./nostradamus
dockerfile: Dockerfile
command: bash -c "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn -b 0.0.0.0:8000 nostradamus.wsgi --log-level debug --timeout 18000"
command: bash -c "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn -b 0.0.0.0:8000 -c gunicorn-conf.py -k uvicorn.workers.UvicornH11Worker nostradamus.asgi --access-logfile - --error-logfile - --log-level debug"
env_file: &envfile
- .env
links:
- mongodb
- redis
depends_on:
- redis
volumes:
- ./nostradamus/data/:/home/app/nostradamus/data/
- ./nostradamus/assets/:/home/app/nostradamus/assets/

nostradamus-frontend:
container_name: nostradamus-frontend
Expand Down Expand Up @@ -111,19 +114,19 @@ services:
image: rasa/rasa:1.10.3-full
ports:
- 5005:5005
volumes:
- ./chatbot:/app
- ./chatbot/models:/app/models
build:
context: ./chatbot
dockerfile: Dockerfile-core
command: run --enable-api --cors '*' --debug
env_file: *envfile

virtual-assistant-actions:
container_name: virtual-assistant-actions
volumes:
- ./chatbot/actions:/app/actions
build:
context: ./chatbot
dockerfile: Dockerfile
dockerfile: Dockerfile-actions
volumes:
- /etc/localtime:/etc/localtime
expose:
- "5055"
env_file: *envfile
Loading

0 comments on commit 9061ea2

Please sign in to comment.