Using Rasa NLU in a custom action

I want to use the NLU of Rasa inside a custom action to do information extraction from a DB to get the proper answer to a question. Can I somehow use the intent classificator from the NLU component withon a custom action of Core? Or do I need to write my own classificator inside a custom action?

When you install rasa_core, rasa_nlu is part of the requirements and exists as a python API, you can parse the model that does the information extraction using rasa_nlu.interpreter.parse(message) in your custom action

Say I want to use the SpacyNLP component only, can I do it from a custom action? Thanks!

it depends on your pipeline, if you are parsing more NLU in your custom actions - build a separate pipeline compared to the one that is used for understanding your user’s text from the chatbot

okey, I think that I can see what you say. But do I have to re-load the spacy language model again? This is in fact what i’m trying to avoid, in order to use less RAM and because I’m loading the same model twice. Is there any way to do it without loading twice? thanks for answering!

you can pre_load your models, there is an argument that lets you do that

parser.add_argument('--pre_load',
                        nargs='+',
                        default=[],
                        help='Preload models into memory before starting the '
                             'server. \nIf given `all` as input all the models '
                             'will be loaded.\nElse you can specify a list of '
                             'specific project names.\nEg: python -m '
                             'rasa_nlu.server --pre_load project1 --path projects '
                             '-c config.yaml')