notice

This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).

Version: 2.x

rasa.core.nlg.interpolator

interpolate_text

interpolate_text(response: Text, values: Dict[Text, Text]) -> Text

Interpolate values into responses with placeholders.

Transform response tags from "{tag_name}" to "{0[tag_name]}" as described here: https://stackoverflow.com/questions/7934620/python-dots-in-the-name-of-variable-in-a-format-string#comment9695339_7934969 Block characters, making sure not to allow: (a) newline in slot name (b) { or } in slot name

Arguments:

  • response - The piece of text that should be interpolated.
  • values - A dictionary of keys and the values that those keys should be replaced with.

Returns:

The piece of text with any replacements made.

interpolate

interpolate(response: Union[List[Any], Dict[Text, Any], Text], values: Dict[Text, Text]) -> Union[List[Any], Dict[Text, Any], Text]

Recursively process response and interpolate any text keys.

Arguments:

  • response - The response that should be interpolated.
  • values - A dictionary of keys and the values that those keys should be replaced with.

Returns:

The response with any replacements made.