Error. return template_key.split(UTTER_PREFIX)[1] or list index out of range?

Hey there,

I am struggling with an issue. Building a bot that started to have some different NLU files. Right know it is very much a FAQ bot. But I am struggling with some errors that I can’t find my way around. Maybe someone in the community have an idea what the problem is. Here is my issue.

(.envrasa) (base) mo@mo bot % rasa shell nlu

2021-03-30 19:13:02 INFO rasa.model - Loading model models/20210330-165815.tar.gz… /Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/utils/ FutureWarning: loss_type=softmax is deprecated. Please update your configuration file to useloss_type=cross_entropy instead. (will be removed in 3.0.0) /Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/utils/ UserWarning: constrain_similarities is set to False. It is recommended to set it to True when using cross-entropy loss. It will be set to True by default, Rasa Open Source 3.0.0 onwards. /Users/mo/.envrasa/lib/python3.8/site-packages/rasa/utils/ UserWarning: model_confidence is set to softmax. It is recommended to try using model_confidence=linear_norm to make it easier to tune fallback thresholds. NLU model loaded. Type a message and press enter to parse it. Next message: vat slänger jag mitt tegel? Traceback (most recent call last): File “/Users/mo/Rasa/.envrasa/bin/rasa”, line 10, in sys.exit(main()) File “/Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/”, line 116, in main cmdline_arguments.func(cmdline_arguments) File “/Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/cli/”, line 89, in shell_nlu File “/Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/nlu/”, line 36, in run_cmdline result = interpreter.parse(message) File “/Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/nlu/”, line 453, in parse component.process(message, **self.context) File “/Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/nlu/selectors/”, line 443, in process self._resolve_intent_response_key(label) or label[INTENT_NAME_KEY] File “/Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/nlu/selectors/”, line 397, in _resolve_intent_response_key search_key = util.template_key_to_intent_response_key(key) File “/Users/mo/Rasa/.envrasa/lib/python3.8/site-packages/rasa/shared/nlu/training_data/”, line 146, in template_key_to_intent_response_key return template_key.split(UTTER_PREFIX)[1] IndexError: list index out of range

(.envrasa) (base) mo@mo bot % rasa --version
Rasa Version : 2.4.3 Rasa SDK Version : 2.4.1 Rasa X Version : 0.34.0 Python Version : 3.8.2 Operating System : macOS-11.2.3-x86_64-i386-64bit Python Path : /Users/mo/Rasa/.envrasa/bin/python3

Any suggestions??

Thanks, /Magnus

Did you find a solution to it? I am facing the same issue.

@gaushh I just started a new virtual environment and it seemed to have solved itself. No good solution.

The IndexError is raised when attempting to retrieve an index from a sequence (e.g. list, tuple), and the index isn’t found in the sequence. The Python documentation defines when this exception is raised:

Raised when a sequence subscript is out of range. (Source)

Here’s an Python Split() example that raises the IndexError:

data = "one%two%three%four%five"
numbers = data.split('%')

The list numbers has 5 elements, and the indexing starts with 0, so, the last element will have index 4. If you try to subscript with an index higher than 4, the Python Interpreter will raise an IndexError since there is no element at such index.