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

[ATO-1151] Parentheses in button title overwrite button payload in rasa shell #12534

Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions changelog/12534.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rich responses containing buttons with parentheses characters are now correctly parsed.
Previously any characters found between the first identified pair of `()` in response button took precedence.
2 changes: 1 addition & 1 deletion rasa/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async def payload_from_button_question(button_question: "Question") -> Text:
response = await button_question.ask_async()
if response != FREE_TEXT_INPUT_PROMPT:
# Extract intent slash command if it's a button
response = response[response.find("(") + 1 : response.find(")")]
response = response[response.rfind("(") + 1 : response.rfind(")")]
return response


Expand Down
17 changes: 17 additions & 0 deletions tests/cli/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
)
import rasa.shared.utils.io
from tests.cli.conftest import RASA_EXE
from tests.conftest import AsyncMock


@contextlib.contextmanager
Expand Down Expand Up @@ -355,3 +356,19 @@ def test_validate_assistant_id_in_config_preserves_comment() -> None:

# reset input files to original state
rasa.shared.utils.io.write_yaml(original_config_data, config_file, True)


@pytest.mark.parametrize(
"text_input, button",
[
("hi this is test text\n", "hi this is test text"),
("hi this is test text (/button_one)", "/button_one"),
("hi this is test text (and something) (/button_one)", "/button_one"),
ancalita marked this conversation as resolved.
Show resolved Hide resolved
],
)
async def test_payload_from_button_question(text_input: str, button: str) -> None:
"""Test that the payload is extracted correctly from the text input."""
question = AsyncMock()
question.ask_async.return_value = text_input
result = await rasa.cli.utils.payload_from_button_question(question)
assert result == button
1 change: 1 addition & 0 deletions tests/nlu/featurizers/test_lm_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ def evaluate_message_shapes(
assert intent_sentence_vec is None

@pytest.mark.timeout(120, func_only=True)
@pytest.mark.skip_on_windows
ancalita marked this conversation as resolved.
Show resolved Hide resolved
def test_lm_featurizer_shapes_in_process_training_data(
self,
model_name: Text,
Expand Down
1 change: 1 addition & 0 deletions tests/nlu/test_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def test_all_components_are_in_at_least_one_test_pipeline():

@pytest.mark.timeout(600, func_only=True)
@pytest.mark.parametrize("language, pipeline", pipelines_for_tests())
@pytest.mark.skip_on_windows
async def test_train_persist_load_parse(
language: Optional[Text],
pipeline: List[Dict],
Expand Down