Intent returning Null for Rasa nlu

Viewed 749

I am currently running into an issue where if the user types a word that has not been trained in the nlu file, the nlu will return this:

"intent": {
   "name": null,
   "confidence": 0.0
}

With other scenarios, it works great! Is there a way to capture these errors and have rasa return the default error message? Please let me know. Thank you!

1 Answers

It is unclear how you are using this nlu response.

  1. If you are using it in rasa_core, you can capture & handle any such intent beforehand in your Custom Action Class. e.g.
def run(self, dispatcher, tracker, domain):
        intent  = tracker.latest_message.intent["name"]
  1. If you want to do it at rasa_nlu level itself, go to rasa_nlu installation directory (usually it is in "Python install folder"\Lib\site-packages\rasa_nlu\ and make below changes in model.py
def default_output_attributes():
        return {"intent": {"name": None, "confidence": 0.0}, "entities": []}

to

 def default_output_attributes():
        return {"intent": {"name": "YOUR_CUSTOM_NAME", "confidence": 0.0}, "entities": []}

But please be cautioned in using second one. You may have to take care while upgrading rasa_nlu python package.

Related