diff --git a/CHANGELOG.rst b/CHANGELOG.rst index aaaa78441941..cc5b8da5b2f6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,26 @@ This project adheres to `Semantic Versioning`_ starting with version 1.0. .. towncrier release notes start +[1.9.7] - 2020-04-23 +^^^^^^^^^^^^^^^^^^^^ + +Improvements +------------ +- `#4606 `_: The stream reading timeout for ``rasa shell` is now configurable by using the + environment variable ``RASA_SHELL_STREAM_READING_TIMEOUT_IN_SECONDS``. + This can help to fix problems when using ``rasa shell`` with custom actions which run + 10 seconds or longer. + +Bugfixes +-------- +- `#5709 `_: Reverted changes in 1.9.6 that led to model incompatibility. Upgrade to 1.9.7 to fix + ``self.sequence_lengths_for(tf_batch_data[TEXT_SEQ_LENGTH][0]) IndexError: list index out of range`` + error without needing to retrain earlier 1.9 models. + + Therefore, all 1.9 models `except for 1.9.6` will be compatible; a model trained on 1.9.6 will need + to be retrained on 1.9.7. + + [1.9.6] - 2020-04-15 ^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/user-guide/connectors/twilio.rst b/docs/user-guide/connectors/twilio.rst index 5f5195170e62..ff3b8945ea73 100644 --- a/docs/user-guide/connectors/twilio.rst +++ b/docs/user-guide/connectors/twilio.rst @@ -39,7 +39,10 @@ Connecting to WhatsApp You can deploy a Rasa Open Source assistant to WhatsApp through Twilio. However, to do so, you have to have a `WhatsApp Business `_ profile. Associate your Whatsapp Business profile with the phone number you purchased through Twilio to -access the `Twilio API for WhatsApp `_. +access the `Twilio API for WhatsApp `_. + +According to the `Twilio API documentation `_, +the phone number you use should be prefixed with `whatsapp:` in the ``credentials.yml`` described below. Applying the Credentials @@ -52,7 +55,7 @@ Add the Twilio credentials to your ``credentials.yml``: twilio: account_sid: "ACbc2dxxxxxxxxxxxx19d54bdcd6e41186" auth_token: "e231c197493a7122d475b4xxxxxxxxxx" - twilio_number: "+440123456789" + twilio_number: "+440123456789" # if using WhatsApp: "whatsapp:+440123456789" Make sure to restart your Rasa Open Source server or container to make changes to which connectors are available. diff --git a/pyproject.toml b/pyproject.toml index b04b6e1ae581..791a3a799ef7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ exclude = "((.eggs | .git | .pytype | .pytest_cache | build | dist))" [tool.poetry] name = "rasa" -version = "1.9.6" +version = "1.9.7" description = "Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants" authors = [ "Rasa Technologies GmbH ",] maintainers = [ "Tom Bocklisch ",] diff --git a/rasa/core/channels/console.py b/rasa/core/channels/console.py index 2fd9b4d8bf13..ab1437635fcc 100644 --- a/rasa/core/channels/console.py +++ b/rasa/core/channels/console.py @@ -2,6 +2,7 @@ import json import logging import asyncio +import os from typing import Text, Optional, Dict, List import aiohttp @@ -19,6 +20,7 @@ logger = logging.getLogger(__name__) +STREAM_READING_TIMEOUT_ENV = "RASA_SHELL_STREAM_READING_TIMEOUT_IN_SECONDS" DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS = 10 @@ -97,7 +99,7 @@ async def send_message_receive_stream( url = f"{server_url}/webhooks/rest/webhook?stream=true&token={auth_token}" # Define timeout to not keep reading in case the server crashed in between - timeout = ClientTimeout(DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS) + timeout = _get_stream_reading_timeout() async with aiohttp.ClientSession(timeout=timeout) as session: async with session.post(url, json=payload, raise_for_status=True) as resp: @@ -107,6 +109,16 @@ async def send_message_receive_stream( yield json.loads(line.decode(DEFAULT_ENCODING)) +def _get_stream_reading_timeout() -> ClientTimeout: + timeout_in_seconds = int( + os.environ.get( + STREAM_READING_TIMEOUT_ENV, DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS + ) + ) + + return ClientTimeout(timeout_in_seconds) + + async def record_messages( sender_id, server_url=DEFAULT_SERVER_URL, diff --git a/rasa/nlu/classifiers/diet_classifier.py b/rasa/nlu/classifiers/diet_classifier.py index 269bc6758d27..32d6966627b4 100644 --- a/rasa/nlu/classifiers/diet_classifier.py +++ b/rasa/nlu/classifiers/diet_classifier.py @@ -1255,7 +1255,7 @@ def _create_sequence( seq_ids = None inputs = self._combine_sparse_dense_features( - features, mask, name, sparse_dropout, dense_dropout, + features, mask, name, sparse_dropout, dense_dropout ) inputs = self._tf_layers[f"ffnn.{name}"](inputs, self._training) @@ -1287,7 +1287,7 @@ def _create_all_labels(self) -> Tuple[tf.Tensor, tf.Tensor]: mask_label = self._compute_mask(label_lengths) x = self._create_bow( - self.tf_label_data[LABEL_FEATURES], mask_label, self.label_name, + self.tf_label_data[LABEL_FEATURES], mask_label, self.label_name ) all_labels_embed = self._tf_layers[f"embed.{LABEL}"](x) @@ -1436,7 +1436,7 @@ def batch_loss( label_ids = tf_batch_data[LABEL_IDS][0] label = self._create_bow( - tf_batch_data[LABEL_FEATURES], mask_label, self.label_name, + tf_batch_data[LABEL_FEATURES], mask_label, self.label_name ) loss, acc = self._calculate_label_loss(cls, label, label_ids) self.intent_loss.update_state(loss) diff --git a/rasa/version.py b/rasa/version.py index 2f6bbbacee47..aa3cab48f5d3 100644 --- a/rasa/version.py +++ b/rasa/version.py @@ -1,3 +1,3 @@ # this file will automatically be changed, # do not add anything but the version number here! -__version__ = "1.9.6" +__version__ = "1.9.7" diff --git a/tests/core/test_channels.py b/tests/core/test_channels.py index 35d331bc1606..2b1d249c6e60 100644 --- a/tests/core/test_channels.py +++ b/tests/core/test_channels.py @@ -1,16 +1,17 @@ import json import logging -import urllib.parse from typing import Dict from unittest.mock import patch, MagicMock, Mock import pytest +from _pytest.monkeypatch import MonkeyPatch +from aiohttp import ClientTimeout from aioresponses import aioresponses from sanic import Sanic import rasa.core.run from rasa.core import utils -from rasa.core.channels import RasaChatInput +from rasa.core.channels import RasaChatInput, console from rasa.core.channels.channel import UserMessage from rasa.core.channels.rasa_chat import ( JWT_USERNAME_KEY, @@ -548,7 +549,7 @@ def test_slack_metadata_missing_keys(): "channel": channel, "event_ts": "1579802617.000800", "channel_type": "im", - }, + } } input_channel = SlackInput( @@ -1032,3 +1033,10 @@ def test_has_user_permission_to_send_messages_to_conversation_without_permission assert not RasaChatInput._has_user_permission_to_send_messages_to_conversation( jwt, message ) + + +def test_set_console_stream_reading_timeout(monkeypatch: MonkeyPatch): + expected = 100 + monkeypatch.setenv(console.STREAM_READING_TIMEOUT_ENV, str(100)) + + assert console._get_stream_reading_timeout() == ClientTimeout(expected)