Skip to content

Commit 32785b7

Browse files
authored
Merge pull request RasaHQ#5712 from RasaHQ/1.9.x-merge
merge 1.9.x into master and reapply reverted 1.9.x changes
2 parents e456f78 + 7fffa52 commit 32785b7

File tree

7 files changed

+54
-11
lines changed

7 files changed

+54
-11
lines changed

CHANGELOG.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ This project adheres to `Semantic Versioning`_ starting with version 1.0.
1717

1818
.. towncrier release notes start
1919
20+
[1.9.7] - 2020-04-23
21+
^^^^^^^^^^^^^^^^^^^^
22+
23+
Improvements
24+
------------
25+
- `#4606 <https://github.com/rasahq/rasa/issues/4606>`_: The stream reading timeout for ``rasa shell` is now configurable by using the
26+
environment variable ``RASA_SHELL_STREAM_READING_TIMEOUT_IN_SECONDS``.
27+
This can help to fix problems when using ``rasa shell`` with custom actions which run
28+
10 seconds or longer.
29+
30+
Bugfixes
31+
--------
32+
- `#5709 <https://github.com/rasahq/rasa/issues/5709>`_: Reverted changes in 1.9.6 that led to model incompatibility. Upgrade to 1.9.7 to fix
33+
``self.sequence_lengths_for(tf_batch_data[TEXT_SEQ_LENGTH][0]) IndexError: list index out of range``
34+
error without needing to retrain earlier 1.9 models.
35+
36+
Therefore, all 1.9 models `except for 1.9.6` will be compatible; a model trained on 1.9.6 will need
37+
to be retrained on 1.9.7.
38+
39+
2040
[1.9.6] - 2020-04-15
2141
^^^^^^^^^^^^^^^^^^^^
2242

docs/user-guide/connectors/twilio.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ Connecting to WhatsApp
3939
You can deploy a Rasa Open Source assistant to WhatsApp through Twilio. However, to do so, you have
4040
to have a `WhatsApp Business <https://www.whatsapp.com/business/>`_ profile. Associate
4141
your Whatsapp Business profile with the phone number you purchased through Twilio to
42-
access the `Twilio API for WhatsApp <https://www.twilio.com/whatsapp>`_.
42+
access the `Twilio API for WhatsApp <https://www.twilio.com/docs/whatsapp/api>`_.
43+
44+
According to the `Twilio API documentation <https://www.twilio.com/docs/whatsapp/api#using-phone-numbers-with-whatsapp>`_,
45+
the phone number you use should be prefixed with `whatsapp:` in the ``credentials.yml`` described below.
4346

4447

4548
Applying the Credentials
@@ -52,7 +55,7 @@ Add the Twilio credentials to your ``credentials.yml``:
5255
twilio:
5356
account_sid: "ACbc2dxxxxxxxxxxxx19d54bdcd6e41186"
5457
auth_token: "e231c197493a7122d475b4xxxxxxxxxx"
55-
twilio_number: "+440123456789"
58+
twilio_number: "+440123456789" # if using WhatsApp: "whatsapp:+440123456789"
5659
5760
Make sure to restart your Rasa Open Source server or container to make changes to
5861
which connectors are available.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exclude = "((.eggs | .git | .pytype | .pytest_cache | build | dist))"
99

1010
[tool.poetry]
1111
name = "rasa"
12-
version = "1.9.6"
12+
version = "1.9.7"
1313
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"
1414
authors = [ "Rasa Technologies GmbH <[email protected]>",]
1515
maintainers = [ "Tom Bocklisch <[email protected]>",]

rasa/core/channels/console.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import logging
44
import asyncio
5+
import os
56
from typing import Text, Optional, Dict, List
67

78
import aiohttp
@@ -19,6 +20,7 @@
1920

2021
logger = logging.getLogger(__name__)
2122

23+
STREAM_READING_TIMEOUT_ENV = "RASA_SHELL_STREAM_READING_TIMEOUT_IN_SECONDS"
2224
DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS = 10
2325

2426

@@ -97,7 +99,7 @@ async def send_message_receive_stream(
9799
url = f"{server_url}/webhooks/rest/webhook?stream=true&token={auth_token}"
98100

99101
# Define timeout to not keep reading in case the server crashed in between
100-
timeout = ClientTimeout(DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS)
102+
timeout = _get_stream_reading_timeout()
101103

102104
async with aiohttp.ClientSession(timeout=timeout) as session:
103105
async with session.post(url, json=payload, raise_for_status=True) as resp:
@@ -107,6 +109,16 @@ async def send_message_receive_stream(
107109
yield json.loads(line.decode(DEFAULT_ENCODING))
108110

109111

112+
def _get_stream_reading_timeout() -> ClientTimeout:
113+
timeout_in_seconds = int(
114+
os.environ.get(
115+
STREAM_READING_TIMEOUT_ENV, DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS
116+
)
117+
)
118+
119+
return ClientTimeout(timeout_in_seconds)
120+
121+
110122
async def record_messages(
111123
sender_id,
112124
server_url=DEFAULT_SERVER_URL,

rasa/nlu/classifiers/diet_classifier.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ def _create_sequence(
12551255
seq_ids = None
12561256

12571257
inputs = self._combine_sparse_dense_features(
1258-
features, mask, name, sparse_dropout, dense_dropout,
1258+
features, mask, name, sparse_dropout, dense_dropout
12591259
)
12601260

12611261
inputs = self._tf_layers[f"ffnn.{name}"](inputs, self._training)
@@ -1287,7 +1287,7 @@ def _create_all_labels(self) -> Tuple[tf.Tensor, tf.Tensor]:
12871287
mask_label = self._compute_mask(label_lengths)
12881288

12891289
x = self._create_bow(
1290-
self.tf_label_data[LABEL_FEATURES], mask_label, self.label_name,
1290+
self.tf_label_data[LABEL_FEATURES], mask_label, self.label_name
12911291
)
12921292
all_labels_embed = self._tf_layers[f"embed.{LABEL}"](x)
12931293

@@ -1436,7 +1436,7 @@ def batch_loss(
14361436

14371437
label_ids = tf_batch_data[LABEL_IDS][0]
14381438
label = self._create_bow(
1439-
tf_batch_data[LABEL_FEATURES], mask_label, self.label_name,
1439+
tf_batch_data[LABEL_FEATURES], mask_label, self.label_name
14401440
)
14411441
loss, acc = self._calculate_label_loss(cls, label, label_ids)
14421442
self.intent_loss.update_state(loss)

rasa/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# this file will automatically be changed,
22
# do not add anything but the version number here!
3-
__version__ = "1.9.6"
3+
__version__ = "1.9.7"

tests/core/test_channels.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import json
22
import logging
3-
import urllib.parse
43
from typing import Dict
54
from unittest.mock import patch, MagicMock, Mock
65

76
import pytest
7+
from _pytest.monkeypatch import MonkeyPatch
8+
from aiohttp import ClientTimeout
89
from aioresponses import aioresponses
910
from sanic import Sanic
1011

1112
import rasa.core.run
1213
from rasa.core import utils
13-
from rasa.core.channels import RasaChatInput
14+
from rasa.core.channels import RasaChatInput, console
1415
from rasa.core.channels.channel import UserMessage
1516
from rasa.core.channels.rasa_chat import (
1617
JWT_USERNAME_KEY,
@@ -548,7 +549,7 @@ def test_slack_metadata_missing_keys():
548549
"channel": channel,
549550
"event_ts": "1579802617.000800",
550551
"channel_type": "im",
551-
},
552+
}
552553
}
553554

554555
input_channel = SlackInput(
@@ -1032,3 +1033,10 @@ def test_has_user_permission_to_send_messages_to_conversation_without_permission
10321033
assert not RasaChatInput._has_user_permission_to_send_messages_to_conversation(
10331034
jwt, message
10341035
)
1036+
1037+
1038+
def test_set_console_stream_reading_timeout(monkeypatch: MonkeyPatch):
1039+
expected = 100
1040+
monkeypatch.setenv(console.STREAM_READING_TIMEOUT_ENV, str(100))
1041+
1042+
assert console._get_stream_reading_timeout() == ClientTimeout(expected)

0 commit comments

Comments
 (0)