From 08eda89fa5e6ab78495050ebed15c18c4a37d4cd Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Thu, 23 Jan 2020 13:22:21 +0200 Subject: [PATCH 01/31] Fix user ID always default on every shell session. --- rasa/core/channels/console.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index 054b44eb0deb..5cf39c755a9c 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -1,5 +1,6 @@ # this builtin is needed so we can overwrite in test import json +import uuid import logging import asyncio from typing import Text, Optional, Dict, List @@ -12,7 +13,6 @@ from rasa.cli import utils as cli_utils from rasa.core import utils from rasa.core.channels.channel import RestInput -from rasa.core.channels.channel import UserMessage from rasa.core.constants import DEFAULT_SERVER_URL from rasa.core.interpreter import INTENT_MESSAGE_PREFIX from rasa.utils.io import DEFAULT_ENCODING @@ -22,6 +22,8 @@ DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS = 10 +CONSOLE_SESSION_USER_ID = str(uuid.uuid4()) + def print_bot_output( message: Dict[Text, Any], color=cli_utils.bcolors.OKBLUE @@ -111,7 +113,7 @@ async def send_message_receive_stream( async def record_messages( server_url=DEFAULT_SERVER_URL, auth_token="", - sender_id=UserMessage.DEFAULT_SENDER_ID, + sender_id=CONSOLE_SESSION_USER_ID, max_message_limit=None, use_response_stream=True, ) -> int: From 4eda4ed8b5685c6fae03159d4f0550d56151f592 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 26 Jan 2020 10:38:33 +0200 Subject: [PATCH 02/31] add changelog record. --- changelog/5117.improvement.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelog/5117.improvement.rst diff --git a/changelog/5117.improvement.rst b/changelog/5117.improvement.rst new file mode 100644 index 000000000000..cbf21bfd287e --- /dev/null +++ b/changelog/5117.improvement.rst @@ -0,0 +1,2 @@ +New user ID will be generated for each shell session. +Previously the user ID was always 'default'. \ No newline at end of file From 7d093a80401538648a5402f62fe96fab7978ec7c Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Sun, 26 Jan 2020 12:09:36 +0200 Subject: [PATCH 03/31] Update rasa/core/channels/console.py Co-Authored-By: ricwo --- rasa/core/channels/console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index 5cf39c755a9c..fa70628f8d50 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -113,7 +113,7 @@ async def send_message_receive_stream( async def record_messages( server_url=DEFAULT_SERVER_URL, auth_token="", - sender_id=CONSOLE_SESSION_USER_ID, + sender_id=uuid.uuid4().hex, max_message_limit=None, use_response_stream=True, ) -> int: From 984c702f9dc02f436f3ee4f42706762dea760215 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Sun, 26 Jan 2020 12:10:02 +0200 Subject: [PATCH 04/31] Update rasa/core/channels/console.py Co-Authored-By: ricwo --- rasa/core/channels/console.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index fa70628f8d50..76838303881f 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -22,7 +22,6 @@ DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS = 10 -CONSOLE_SESSION_USER_ID = str(uuid.uuid4()) def print_bot_output( From 1622793124cc9bfccb925055b354d643cf72260d Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Sun, 26 Jan 2020 12:10:15 +0200 Subject: [PATCH 05/31] Update rasa/core/channels/console.py Co-Authored-By: ricwo --- rasa/core/channels/console.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index 76838303881f..934857f1152f 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -23,7 +23,6 @@ DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS = 10 - def print_bot_output( message: Dict[Text, Any], color=cli_utils.bcolors.OKBLUE ) -> Optional[questionary.Question]: From 0034e338e22145dfb1a526f034dc9f014f8f33ef Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Sun, 26 Jan 2020 12:22:42 +0200 Subject: [PATCH 06/31] Update changelog/5117.improvement.rst Co-Authored-By: ricwo --- changelog/5117.improvement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/5117.improvement.rst b/changelog/5117.improvement.rst index cbf21bfd287e..4d35018b1575 100644 --- a/changelog/5117.improvement.rst +++ b/changelog/5117.improvement.rst @@ -1,2 +1,2 @@ New user ID will be generated for each shell session. -Previously the user ID was always 'default'. \ No newline at end of file +Previously the conversation ID was always ``default``. From a5b185cd0a0a37c1d40d2ad9ec520ecef86a6b79 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Sun, 26 Jan 2020 12:23:08 +0200 Subject: [PATCH 07/31] Update changelog/5117.improvement.rst Co-Authored-By: ricwo --- changelog/5117.improvement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/5117.improvement.rst b/changelog/5117.improvement.rst index 4d35018b1575..f71c7aa10334 100644 --- a/changelog/5117.improvement.rst +++ b/changelog/5117.improvement.rst @@ -1,2 +1,2 @@ -New user ID will be generated for each shell session. +New conversation ID will be generated for each shell session. Previously the conversation ID was always ``default``. From a1351f53c835db239cf4f9c35a9c060d80967deb Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Thu, 30 Jan 2020 18:01:39 +0200 Subject: [PATCH 08/31] Fix rasa core channels test. --- tests/core/test_channels.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/core/test_channels.py b/tests/core/test_channels.py index c8af169ddad3..d62cce28c071 100644 --- a/tests/core/test_channels.py +++ b/tests/core/test_channels.py @@ -114,7 +114,9 @@ async def test_console_input(): ) await console.record_messages( - server_url="https://example.com", max_message_limit=3 + server_url="https://example.com", + max_message_limit=3, + sender_id="default" ) r = latest_request( From 529c2e9dd6981718aa8b7aae1ecaabe45d0c7a86 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 3 Feb 2020 16:18:23 +0200 Subject: [PATCH 09/31] Add --sender-id argument to rasa shell. --- rasa/cli/shell.py | 8 ++++++++ rasa/constants.py | 2 ++ rasa/core/run.py | 8 ++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/rasa/cli/shell.py b/rasa/cli/shell.py index ebbe4ac0dc1e..06907cb6f1a8 100644 --- a/rasa/cli/shell.py +++ b/rasa/cli/shell.py @@ -26,7 +26,14 @@ def add_subparser( ) shell_parser.set_defaults(func=shell) + shell_parser.add_argument('--sender-id', + action='store', + default="default", + required=False, + help='Set Conversation unique identifier.') + run_subparsers = shell_parser.add_subparsers() + shell_nlu_subparser = run_subparsers.add_parser( "nlu", parents=parents, @@ -34,6 +41,7 @@ def add_subparser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, help="Interprets messages on the command line using your NLU model.", ) + shell_nlu_subparser.set_defaults(func=shell_nlu) arguments.set_shell_arguments(shell_parser) diff --git a/rasa/constants.py b/rasa/constants.py index edfae6226e74..0c790ae3f810 100644 --- a/rasa/constants.py +++ b/rasa/constants.py @@ -59,3 +59,5 @@ DEFAULT_SESSION_EXPIRATION_TIME_IN_MINUTES = 60 DEFAULT_CARRY_OVER_SLOTS_TO_NEW_SESSION = True + +DEFAULT_SENDER_ID = "default" \ No newline at end of file diff --git a/rasa/core/run.py b/rasa/core/run.py index 9455332624b8..61ab373bf0af 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -10,7 +10,7 @@ import rasa.utils.common import rasa.utils.io from rasa import model, server -from rasa.constants import ENV_SANIC_BACKLOG +from rasa.constants import ENV_SANIC_BACKLOG, DEFAULT_SENDER_ID from rasa.core import agent, channels, constants from rasa.core.agent import Agent from rasa.core.brokers.broker import EventBroker @@ -87,6 +87,7 @@ def configure_app( port: int = constants.DEFAULT_SERVER_PORT, endpoints: Optional[AvailableEndpoints] = None, log_file: Optional[Text] = None, + sender_id: Optional[Text] = DEFAULT_SENDER_ID, ): """Run the agent.""" from rasa import server @@ -125,7 +126,8 @@ async def run_cmdline_io(running_app: Sanic): """Small wrapper to shut down the server once cmd io is done.""" await asyncio.sleep(1) # allow server to start await console.record_messages( - server_url=constants.DEFAULT_SERVER_FORMAT.format("http", port) + server_url=constants.DEFAULT_SERVER_FORMAT.format("http", port), + sender_id=sender_id, ) logger.info("Killing Sanic server now.") @@ -153,6 +155,7 @@ def serve_application( ssl_keyfile: Optional[Text] = None, ssl_ca_file: Optional[Text] = None, ssl_password: Optional[Text] = None, + sender_id=DEFAULT_SENDER_ID, ): from rasa import server @@ -171,6 +174,7 @@ def serve_application( port=port, endpoints=endpoints, log_file=log_file, + sender_id=sender_id, ) ssl_context = server.create_ssl_context( From 6c93b3fc2c292337704fda7d28dd59decea63cab Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 3 Feb 2020 16:34:13 +0200 Subject: [PATCH 10/31] Change sell --sender-id argument name to --conversation-id --- rasa/cli/shell.py | 2 +- rasa/core/run.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rasa/cli/shell.py b/rasa/cli/shell.py index 06907cb6f1a8..d34015c71f45 100644 --- a/rasa/cli/shell.py +++ b/rasa/cli/shell.py @@ -26,7 +26,7 @@ def add_subparser( ) shell_parser.set_defaults(func=shell) - shell_parser.add_argument('--sender-id', + shell_parser.add_argument('--conversation-id', action='store', default="default", required=False, diff --git a/rasa/core/run.py b/rasa/core/run.py index 61ab373bf0af..f2385e1d593f 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -155,7 +155,7 @@ def serve_application( ssl_keyfile: Optional[Text] = None, ssl_ca_file: Optional[Text] = None, ssl_password: Optional[Text] = None, - sender_id=DEFAULT_SENDER_ID, + conversation_id=DEFAULT_SENDER_ID, ): from rasa import server @@ -174,7 +174,7 @@ def serve_application( port=port, endpoints=endpoints, log_file=log_file, - sender_id=sender_id, + sender_id=conversation_id, ) ssl_context = server.create_ssl_context( From af2b561cd1a25fc4abd7c7948e5ff8ceb507a497 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Thu, 6 Feb 2020 13:08:23 +0200 Subject: [PATCH 11/31] Adjust rasa shell help test to changes. --- tests/cli/test_rasa_shell.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/cli/test_rasa_shell.py b/tests/cli/test_rasa_shell.py index 7301db203ec0..6f156ba1ba3a 100644 --- a/tests/cli/test_rasa_shell.py +++ b/tests/cli/test_rasa_shell.py @@ -5,9 +5,10 @@ def test_shell_help(run: Callable[..., RunResult]): output = run("shell", "--help") - help_text = """usage: rasa shell [-h] [-v] [-vv] [--quiet] [-m MODEL] [--log-file LOG_FILE] - [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN] - [--cors [CORS [CORS ...]]] [--enable-api] + help_text = """usage: rasa shell [-h] [-v] [-vv] [--quiet] + [--conversation-id CONVERSATION_ID] [-m MODEL] + [--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT] + [-t AUTH_TOKEN] [--cors [CORS [CORS ...]]] [--enable-api] [--remote-storage REMOTE_STORAGE] [--ssl-certificate SSL_CERTIFICATE] [--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE] From cc7614887767f3c45c6aebfa4e6567bbf39a7c87 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 9 Feb 2020 07:02:11 +0200 Subject: [PATCH 12/31] Add new line at the end of rasa consts file. --- rasa/constants.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rasa/constants.py b/rasa/constants.py index 0c790ae3f810..3092507cd46b 100644 --- a/rasa/constants.py +++ b/rasa/constants.py @@ -60,4 +60,5 @@ DEFAULT_SESSION_EXPIRATION_TIME_IN_MINUTES = 60 DEFAULT_CARRY_OVER_SLOTS_TO_NEW_SESSION = True -DEFAULT_SENDER_ID = "default" \ No newline at end of file +DEFAULT_SENDER_ID = "default" + From 368efe6586d88f27145faad0a2a9f7393cc972d7 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 9 Feb 2020 10:32:52 +0200 Subject: [PATCH 13/31] Remove unnecessary line at the end of the rasa constants. --- rasa/constants.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/constants.py b/rasa/constants.py index 3092507cd46b..9c302a889356 100644 --- a/rasa/constants.py +++ b/rasa/constants.py @@ -61,4 +61,3 @@ DEFAULT_CARRY_OVER_SLOTS_TO_NEW_SESSION = True DEFAULT_SENDER_ID = "default" - From a148933d266b15e5af6b2bbfc305f218114fabe1 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 9 Feb 2020 11:42:15 +0200 Subject: [PATCH 14/31] Fix channels test format. --- tests/core/test_channels.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/test_channels.py b/tests/core/test_channels.py index 6833aabc058b..e820d1e807ac 100644 --- a/tests/core/test_channels.py +++ b/tests/core/test_channels.py @@ -116,7 +116,7 @@ async def test_console_input(): await console.record_messages( server_url="https://example.com", max_message_limit=3, - sender_id="default" + sender_id="default", ) r = latest_request( From 0397e4df4ef0441111cbc5e6b4558e7cc4754826 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 9 Feb 2020 12:48:21 +0200 Subject: [PATCH 15/31] Reformat rasa cli shell.py --- rasa/cli/shell.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rasa/cli/shell.py b/rasa/cli/shell.py index d34015c71f45..7a8983935d21 100644 --- a/rasa/cli/shell.py +++ b/rasa/cli/shell.py @@ -26,11 +26,13 @@ def add_subparser( ) shell_parser.set_defaults(func=shell) - shell_parser.add_argument('--conversation-id', - action='store', - default="default", - required=False, - help='Set Conversation unique identifier.') + shell_parser.add_argument( + "--conversation-id", + action="store", + default="default", + required=False, + help="Set Conversation unique identifier.", + ) run_subparsers = shell_parser.add_subparsers() From dd52f11154b32ecc640821fe7a6a6729509cfe66 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Mon, 10 Feb 2020 10:22:44 +0200 Subject: [PATCH 16/31] Update rasa/cli/shell.py Co-Authored-By: ricwo --- rasa/cli/shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/cli/shell.py b/rasa/cli/shell.py index 7a8983935d21..4664a9415763 100644 --- a/rasa/cli/shell.py +++ b/rasa/cli/shell.py @@ -31,7 +31,7 @@ def add_subparser( action="store", default="default", required=False, - help="Set Conversation unique identifier.", + help="Set the conversation ID.", ) run_subparsers = shell_parser.add_subparsers() From d0115abe67364efbcb977b6ab189cacc5c6a57d8 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Mon, 10 Feb 2020 10:23:06 +0200 Subject: [PATCH 17/31] Update rasa/cli/shell.py Co-Authored-By: ricwo --- rasa/cli/shell.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/cli/shell.py b/rasa/cli/shell.py index 4664a9415763..6af7d84a3291 100644 --- a/rasa/cli/shell.py +++ b/rasa/cli/shell.py @@ -28,7 +28,6 @@ def add_subparser( shell_parser.add_argument( "--conversation-id", - action="store", default="default", required=False, help="Set the conversation ID.", From c5fb40c9afccd3210050d8083268c575d25de911 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 10 Feb 2020 10:30:50 +0200 Subject: [PATCH 18/31] Change changelog record according to the new changes. --- changelog/5117.improvement.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/5117.improvement.rst b/changelog/5117.improvement.rst index f71c7aa10334..18c6494a5270 100644 --- a/changelog/5117.improvement.rst +++ b/changelog/5117.improvement.rst @@ -1,2 +1,2 @@ -New conversation ID will be generated for each shell session. -Previously the conversation ID was always ``default``. +New command-line argument --conversation-id will be added and wiil give the ability to +set custom conversation ID for each shell session. From ec6590e69a2382b98306fedb5d74ed270af34e3e Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 10 Feb 2020 10:49:41 +0200 Subject: [PATCH 19/31] Use const as default --conversation-id argument value. --- rasa/cli/shell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rasa/cli/shell.py b/rasa/cli/shell.py index 6af7d84a3291..770fa2cb7428 100644 --- a/rasa/cli/shell.py +++ b/rasa/cli/shell.py @@ -6,7 +6,7 @@ from rasa.cli.arguments import shell as arguments from rasa.cli.utils import print_error from rasa.exceptions import ModelNotFound - +from rasa.constants import DEFAULT_SENDER_ID logger = logging.getLogger(__name__) @@ -28,7 +28,7 @@ def add_subparser( shell_parser.add_argument( "--conversation-id", - default="default", + default=DEFAULT_SENDER_ID, required=False, help="Set the conversation ID.", ) From f50d0c0931a871c1bf667c43e39ddf942bea4644 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Mon, 10 Feb 2020 10:50:24 +0200 Subject: [PATCH 20/31] Update rasa/core/channels/console.py Co-Authored-By: ricwo --- rasa/core/channels/console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index 934857f1152f..de6c435821d7 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -111,7 +111,7 @@ async def send_message_receive_stream( async def record_messages( server_url=DEFAULT_SERVER_URL, auth_token="", - sender_id=uuid.uuid4().hex, + sender_id=UserMessage.DEFAULT_SENDER_ID, max_message_limit=None, use_response_stream=True, ) -> int: From b7ab04d58377b151168f308a59afcc2ce1db92b4 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Mon, 10 Feb 2020 10:50:45 +0200 Subject: [PATCH 21/31] Update rasa/core/run.py Co-Authored-By: ricwo --- rasa/core/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/core/run.py b/rasa/core/run.py index f2385e1d593f..8091e7bf772f 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -155,7 +155,7 @@ def serve_application( ssl_keyfile: Optional[Text] = None, ssl_ca_file: Optional[Text] = None, ssl_password: Optional[Text] = None, - conversation_id=DEFAULT_SENDER_ID, + conversation_id: Optional[Text] = DEFAULT_SENDER_ID, ): from rasa import server From cc5e7b70103cb222ebaa4b5a4d2db68e96dcaa7b Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Mon, 10 Feb 2020 11:01:05 +0200 Subject: [PATCH 22/31] Update rasa/core/run.py Co-Authored-By: ricwo --- rasa/core/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/core/run.py b/rasa/core/run.py index 8091e7bf772f..fa62e856f07c 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -87,7 +87,7 @@ def configure_app( port: int = constants.DEFAULT_SERVER_PORT, endpoints: Optional[AvailableEndpoints] = None, log_file: Optional[Text] = None, - sender_id: Optional[Text] = DEFAULT_SENDER_ID, + conversation_id: Optional[Text] = DEFAULT_SENDER_ID, ): """Run the agent.""" from rasa import server From af501c7226fea2ef9304fd28dcfea2142527a079 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Mon, 10 Feb 2020 11:01:20 +0200 Subject: [PATCH 23/31] Update rasa/core/run.py Co-Authored-By: ricwo --- rasa/core/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/core/run.py b/rasa/core/run.py index fa62e856f07c..8ab63d6603c8 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -174,7 +174,7 @@ def serve_application( port=port, endpoints=endpoints, log_file=log_file, - sender_id=conversation_id, + conversation_id=conversation_id, ) ssl_context = server.create_ssl_context( From f01166cb67a8fd47c8c503b3150fa471d69bc7f3 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Mon, 10 Feb 2020 11:01:28 +0200 Subject: [PATCH 24/31] Update rasa/core/run.py Co-Authored-By: ricwo --- rasa/core/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/core/run.py b/rasa/core/run.py index 8ab63d6603c8..b63db220b3ac 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -127,7 +127,7 @@ async def run_cmdline_io(running_app: Sanic): await asyncio.sleep(1) # allow server to start await console.record_messages( server_url=constants.DEFAULT_SERVER_FORMAT.format("http", port), - sender_id=sender_id, + sender_id=conversation_id, ) logger.info("Killing Sanic server now.") From 2104ec3c6dfe522def337220337bcdcd4937c2f6 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Mon, 10 Feb 2020 11:01:50 +0200 Subject: [PATCH 25/31] Update rasa/core/channels/console.py Co-Authored-By: ricwo --- rasa/core/channels/console.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index de6c435821d7..62cbae0b9244 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -1,6 +1,5 @@ # this builtin is needed so we can overwrite in test import json -import uuid import logging import asyncio from typing import Text, Optional, Dict, List From 63fcf89ff72cab4ea3e7c264c87e5487ec38191f Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 10 Feb 2020 11:56:32 +0200 Subject: [PATCH 26/31] Fix unresolved reference for UserMessage. --- rasa/core/channels/console.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index 62cbae0b9244..cf4ec63003ab 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -11,6 +11,7 @@ from rasa.cli import utils as cli_utils from rasa.core import utils +from rasa.constants import DEFAULT_SENDER_ID from rasa.core.channels.channel import RestInput from rasa.core.constants import DEFAULT_SERVER_URL from rasa.core.interpreter import INTENT_MESSAGE_PREFIX @@ -110,7 +111,7 @@ async def send_message_receive_stream( async def record_messages( server_url=DEFAULT_SERVER_URL, auth_token="", - sender_id=UserMessage.DEFAULT_SENDER_ID, + sender_id=DEFAULT_SENDER_ID, max_message_limit=None, use_response_stream=True, ) -> int: From d2454b0ae7b3479827f38ddcede51ed868502f10 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Tue, 11 Feb 2020 10:00:59 +0200 Subject: [PATCH 27/31] Update changelog/5117.improvement.rst Co-Authored-By: ricwo --- changelog/5117.improvement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/5117.improvement.rst b/changelog/5117.improvement.rst index 18c6494a5270..97471940a848 100644 --- a/changelog/5117.improvement.rst +++ b/changelog/5117.improvement.rst @@ -1,2 +1,2 @@ -New command-line argument --conversation-id will be added and wiil give the ability to +New command-line argument ``--conversation-id`` will be added to ``rasa shell`` set custom conversation ID for each shell session. From 927a272c831388fb47826ea1555396a78c62ef61 Mon Sep 17 00:00:00 2001 From: Victor CoCo <56578799+VictorCoCo@users.noreply.github.com> Date: Tue, 11 Feb 2020 10:01:17 +0200 Subject: [PATCH 28/31] Update changelog/5117.improvement.rst Co-Authored-By: ricwo --- changelog/5117.improvement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/5117.improvement.rst b/changelog/5117.improvement.rst index 97471940a848..beceba40eb39 100644 --- a/changelog/5117.improvement.rst +++ b/changelog/5117.improvement.rst @@ -1,2 +1,2 @@ New command-line argument ``--conversation-id`` will be added to ``rasa shell`` -set custom conversation ID for each shell session. +and will give the ability to set custom conversation IDs for each shell session. From ecf01b645f0f273f9788168b4386ff0a642482b5 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 23 Feb 2020 15:42:44 +0200 Subject: [PATCH 29/31] Change --coversation-id to be random by default. --- changelog/5117.improvement.rst | 5 +++-- rasa/cli/shell.py | 4 ++-- rasa/constants.py | 2 -- rasa/core/channels/console.py | 3 +-- rasa/core/run.py | 10 ++++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/changelog/5117.improvement.rst b/changelog/5117.improvement.rst index beceba40eb39..8b2f824ff0bf 100644 --- a/changelog/5117.improvement.rst +++ b/changelog/5117.improvement.rst @@ -1,2 +1,3 @@ -New command-line argument ``--conversation-id`` will be added to ``rasa shell`` -and will give the ability to set custom conversation IDs for each shell session. +New command-line argument --conversation-id will be added and wiil give the ability to +set specific conversation ID for each shell session, if not passed will be random. + diff --git a/rasa/cli/shell.py b/rasa/cli/shell.py index 770fa2cb7428..572ce1424b84 100644 --- a/rasa/cli/shell.py +++ b/rasa/cli/shell.py @@ -1,12 +1,12 @@ import argparse import logging +import uuid from typing import List from rasa.cli.arguments import shell as arguments from rasa.cli.utils import print_error from rasa.exceptions import ModelNotFound -from rasa.constants import DEFAULT_SENDER_ID logger = logging.getLogger(__name__) @@ -28,7 +28,7 @@ def add_subparser( shell_parser.add_argument( "--conversation-id", - default=DEFAULT_SENDER_ID, + default=uuid.uuid4().hex, required=False, help="Set the conversation ID.", ) diff --git a/rasa/constants.py b/rasa/constants.py index b37c88a6161d..fd0c27def12a 100644 --- a/rasa/constants.py +++ b/rasa/constants.py @@ -60,5 +60,3 @@ DEFAULT_SESSION_EXPIRATION_TIME_IN_MINUTES = 60 DEFAULT_CARRY_OVER_SLOTS_TO_NEW_SESSION = True - -DEFAULT_SENDER_ID = "default" diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index cf4ec63003ab..2fd9b4d8bf13 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -11,7 +11,6 @@ from rasa.cli import utils as cli_utils from rasa.core import utils -from rasa.constants import DEFAULT_SENDER_ID from rasa.core.channels.channel import RestInput from rasa.core.constants import DEFAULT_SERVER_URL from rasa.core.interpreter import INTENT_MESSAGE_PREFIX @@ -109,9 +108,9 @@ async def send_message_receive_stream( async def record_messages( + sender_id, server_url=DEFAULT_SERVER_URL, auth_token="", - sender_id=DEFAULT_SENDER_ID, max_message_limit=None, use_response_stream=True, ) -> int: diff --git a/rasa/core/run.py b/rasa/core/run.py index b63db220b3ac..b086123e3983 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -1,5 +1,6 @@ import asyncio import logging +import uuid import os import shutil from functools import partial @@ -10,7 +11,7 @@ import rasa.utils.common import rasa.utils.io from rasa import model, server -from rasa.constants import ENV_SANIC_BACKLOG, DEFAULT_SENDER_ID +from rasa.constants import ENV_SANIC_BACKLOG from rasa.core import agent, channels, constants from rasa.core.agent import Agent from rasa.core.brokers.broker import EventBroker @@ -77,6 +78,7 @@ def _create_app_without_api(cors: Optional[Union[Text, List[Text]]] = None): def configure_app( + conversation_id: str, input_channels: Optional[List["InputChannel"]] = None, cors: Optional[Union[Text, List[Text], None]] = None, auth_token: Optional[Text] = None, @@ -87,7 +89,6 @@ def configure_app( port: int = constants.DEFAULT_SERVER_PORT, endpoints: Optional[AvailableEndpoints] = None, log_file: Optional[Text] = None, - conversation_id: Optional[Text] = DEFAULT_SENDER_ID, ): """Run the agent.""" from rasa import server @@ -125,6 +126,7 @@ async def configure_async_logging(): async def run_cmdline_io(running_app: Sanic): """Small wrapper to shut down the server once cmd io is done.""" await asyncio.sleep(1) # allow server to start + await console.record_messages( server_url=constants.DEFAULT_SERVER_FORMAT.format("http", port), sender_id=conversation_id, @@ -155,7 +157,7 @@ def serve_application( ssl_keyfile: Optional[Text] = None, ssl_ca_file: Optional[Text] = None, ssl_password: Optional[Text] = None, - conversation_id: Optional[Text] = DEFAULT_SENDER_ID, + conversation_id: Optional[Text] = uuid.uuid4().hex, ): from rasa import server @@ -165,6 +167,7 @@ def serve_application( input_channels = create_http_input_channels(channel, credentials) app = configure_app( + conversation_id, input_channels, cors, auth_token, @@ -174,7 +177,6 @@ def serve_application( port=port, endpoints=endpoints, log_file=log_file, - conversation_id=conversation_id, ) ssl_context = server.create_ssl_context( From ea750524da35054a5163686deece3c1761eb68a0 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 23 Feb 2020 17:09:26 +0200 Subject: [PATCH 30/31] Add conversation_id arg to interactive test. --- rasa/core/run.py | 2 +- rasa/core/training/interactive.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rasa/core/run.py b/rasa/core/run.py index b086123e3983..cd1c659cabcd 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -78,7 +78,7 @@ def _create_app_without_api(cors: Optional[Union[Text, List[Text]]] = None): def configure_app( - conversation_id: str, + conversation_id: Text, input_channels: Optional[List["InputChannel"]] = None, cors: Optional[Union[Text, List[Text], None]] = None, auth_token: Optional[Text] = None, diff --git a/rasa/core/training/interactive.py b/rasa/core/training/interactive.py index cad7709162f0..943d493aebf0 100644 --- a/rasa/core/training/interactive.py +++ b/rasa/core/training/interactive.py @@ -1624,7 +1624,7 @@ def run_interactive_learning( else: p = None - app = run.configure_app(enable_api=True) + app = run.configure_app(enable_api=True, conversation_id="default") endpoints = AvailableEndpoints.read_endpoints(server_args.get("endpoints")) # before_server_start handlers make sure the agent is loaded before the From b1d32cbae0c97753b2da0a3687c7f60dbe029782 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 23 Feb 2020 18:20:56 +0200 Subject: [PATCH 31/31] Add default conversation id value on core.run functions. --- rasa/core/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rasa/core/run.py b/rasa/core/run.py index cd1c659cabcd..6ec641838ce2 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -78,7 +78,6 @@ def _create_app_without_api(cors: Optional[Union[Text, List[Text]]] = None): def configure_app( - conversation_id: Text, input_channels: Optional[List["InputChannel"]] = None, cors: Optional[Union[Text, List[Text], None]] = None, auth_token: Optional[Text] = None, @@ -89,6 +88,7 @@ def configure_app( port: int = constants.DEFAULT_SERVER_PORT, endpoints: Optional[AvailableEndpoints] = None, log_file: Optional[Text] = None, + conversation_id: Optional[Text] = uuid.uuid4().hex, ): """Run the agent.""" from rasa import server @@ -167,7 +167,6 @@ def serve_application( input_channels = create_http_input_channels(channel, credentials) app = configure_app( - conversation_id, input_channels, cors, auth_token, @@ -177,6 +176,7 @@ def serve_application( port=port, endpoints=endpoints, log_file=log_file, + conversation_id=conversation_id, ) ssl_context = server.create_ssl_context(