|
70 | 70 | from rasa.core.http_interpreter import RasaNLUHttpInterpreter
|
71 | 71 | from rasa.core.processor import MessageProcessor
|
72 | 72 | from rasa.shared.core.trackers import DialogueStateTracker
|
73 |
| -from rasa.shared.nlu.constants import INTENT_NAME_KEY, METADATA_MODEL_ID |
| 73 | +from rasa.shared.nlu.constants import ( |
| 74 | + INTENT, |
| 75 | + INTENT_NAME_KEY, |
| 76 | + FULL_RETRIEVAL_INTENT_NAME_KEY, |
| 77 | + METADATA_MODEL_ID, |
| 78 | +) |
74 | 79 | from rasa.shared.nlu.training_data.message import Message
|
75 | 80 | from rasa.utils.endpoints import EndpointConfig
|
76 | 81 | from rasa.shared.core.constants import (
|
@@ -1928,3 +1933,60 @@ async def test_run_anonymization_pipeline_mocked_pipeline(
|
1928 | 1933 | await processor.run_anonymization_pipeline(tracker)
|
1929 | 1934 |
|
1930 | 1935 | event_diff.assert_called_once()
|
| 1936 | + |
| 1937 | + |
| 1938 | +async def test_update_full_retrieval_intent( |
| 1939 | + default_processor: MessageProcessor, |
| 1940 | +) -> None: |
| 1941 | + parse_data = { |
| 1942 | + "text": "I like sunny days in berlin", |
| 1943 | + "intent": {"name": "chitchat", "confidence": 0.9}, |
| 1944 | + "entities": [], |
| 1945 | + "response_selector": { |
| 1946 | + "all_retrieval_intents": ["faq", "chitchat"], |
| 1947 | + "faq": { |
| 1948 | + "response": { |
| 1949 | + "responses": [{"text": "Our return policy lasts 30 days."}], |
| 1950 | + "confidence": 1.0, |
| 1951 | + "intent_response_key": "faq/what_is_return_policy", |
| 1952 | + "utter_action": "utter_faq/what_is_return_policy", |
| 1953 | + }, |
| 1954 | + "ranking": [ |
| 1955 | + { |
| 1956 | + "confidence": 1.0, |
| 1957 | + "intent_response_key": "faq/what_is_return_policy", |
| 1958 | + }, |
| 1959 | + { |
| 1960 | + "confidence": 2.3378809862799945e-19, |
| 1961 | + "intent_response_key": "faq/how_can_i_track_my_order", |
| 1962 | + }, |
| 1963 | + ], |
| 1964 | + }, |
| 1965 | + "chitchat": { |
| 1966 | + "response": { |
| 1967 | + "responses": [ |
| 1968 | + { |
| 1969 | + "text": "The sun is out today! Isn't that great?", |
| 1970 | + }, |
| 1971 | + ], |
| 1972 | + "confidence": 1.0, |
| 1973 | + "intent_response_key": "chitchat/ask_weather", |
| 1974 | + "utter_action": "utter_chitchat/ask_weather", |
| 1975 | + }, |
| 1976 | + "ranking": [ |
| 1977 | + { |
| 1978 | + "confidence": 1.0, |
| 1979 | + "intent_response_key": "chitchat/ask_weather", |
| 1980 | + }, |
| 1981 | + {"confidence": 0.0, "intent_response_key": "chitchat/ask_name"}, |
| 1982 | + ], |
| 1983 | + }, |
| 1984 | + }, |
| 1985 | + } |
| 1986 | + |
| 1987 | + default_processor._update_full_retrieval_intent(parse_data) |
| 1988 | + |
| 1989 | + assert parse_data[INTENT][INTENT_NAME_KEY] == "chitchat" |
| 1990 | + # assert that parse_data["intent"] has a key called response |
| 1991 | + assert FULL_RETRIEVAL_INTENT_NAME_KEY in parse_data[INTENT] |
| 1992 | + assert parse_data[INTENT][FULL_RETRIEVAL_INTENT_NAME_KEY] == "chitchat/ask_weather" |
0 commit comments