Beispiel #1
0
 def create_slot(self):
     slot = CategoricalSlot("test",
                            values=[1, "two", "小于", {
                                "three": 3
                            }, None])
     slot.add_default_value()
     return slot
Beispiel #2
0
 def create_slot(self, influence_conversation: bool) -> Slot:
     slot = CategoricalSlot(
         "test",
         values=[1, "two", "小于", {"three": 3}, None],
         influence_conversation=influence_conversation,
     )
     slot.add_default_value()
     return slot
Beispiel #3
0
 def create_slot(
     self, mappings: List[Dict[Text, Any]], influence_conversation: bool
 ) -> Slot:
     slot = CategoricalSlot(
         "test",
         mappings=mappings,
         values=[1, "two", "小于", {"three": 3}, "nOnE", "None", "null"],
         influence_conversation=influence_conversation,
     )
     slot.add_default_value()
     return slot
Beispiel #4
0
async def test_nlg_conditional_response_variations_with_yaml_and_channel():
    domain = Domain.from_file(
        path="data/test_domains/conditional_response_variations.yml"
    )
    t = TemplatedNaturalLanguageGenerator(responses=domain.responses)

    slot = CategoricalSlot(
        name="account_type",
        mappings=[{}],
        initial_value="primary",
        influence_conversation=False,
    )
    tracker = DialogueStateTracker(sender_id="conversation_id", slots=[slot])

    r = await t.generate(
        utter_action="utter_check_balance", tracker=tracker, output_channel="os"
    )
    assert (
        r.get("text") == "As a primary account holder, you can now set-up "
        "your access on mobile app too."
    )

    resp = await t.generate(
        utter_action="utter_check_balance", tracker=tracker, output_channel="app"
    )
    assert resp.get("text") == "Welcome to your app account overview."
Beispiel #5
0
async def test_nlg_conditional_response_variations_with_yaml_multi_constraints():
    domain = Domain.from_file(
        path="data/test_domains/conditional_response_variations.yml"
    )
    t = TemplatedNaturalLanguageGenerator(responses=domain.responses)

    first_slot = CategoricalSlot(
        name="account_type",
        mappings=[{}],
        initial_value="primary",
        influence_conversation=False,
    )
    second_slot = BooleanSlot(
        name="can_withdraw",
        mappings=[{}],
        initial_value=True,
        influence_conversation=False,
    )
    tracker = DialogueStateTracker(
        sender_id="conversation_id", slots=[first_slot, second_slot]
    )
    r = await t.generate(
        utter_action="utter_withdraw", tracker=tracker, output_channel=""
    )
    assert r.get("text") == "Withdrawal has been approved."
Beispiel #6
0
 def create_slot(self, influence_conversation: bool) -> Slot:
     return CategoricalSlot(
         "test",
         values=[1, "two", "小于", {
             "three": 3
         }, "nOnE", "None", "null"],
         influence_conversation=influence_conversation,
     )
Beispiel #7
0
def test_categorical_slot_ignores_none_value():
    """Checks that None can't be added as a possible value for categorical slots."""
    with pytest.warns(UserWarning) as records:
        slot = CategoricalSlot(name="branch",
                               values=["Berlin", None, "San Francisco"])

    assert not ("none" in slot.values)

    message_text = "Rasa will ignore `null` as a possible value for the 'branch' slot."
    assert any(message_text in record.message.args[0] for record in records)
Beispiel #8
0
 def create_slot(self):
     return CategoricalSlot("test", values=[1, "two", "小于", {"three": 3}, None])