Custom NLU Components Failed to find component class

Rasa version: 0.14

Rasa X version (if used & relevant):

Python version: 3.6

Operating system: Ubuntu

Issue: I’m trying to make own Custom NLU Components, but rasa_nlu can’t find my component, probably I miss something

rasa_nlu : 
├── classifiers
│   ├── ....
├── emulators
│   ├── ...
├── extractors
│   ├── ...
├── featurizers
│   ├── ...
├── schemas
│   └── ...
├── tokenizers
│   ├── ...
├── training_data
│   ├── ...
├── utils
│   ├── ...
│
│ 
├── customcomponents
│   ├── __init__.py
│   └── sentiment.py
│
│
├── __init__.py
├── registry.py
├── config.json
│
│
├── components.py
├── config.py
├── convert.py
├── data_router.py
├── evaluate.py
├── model.py
├── persistor.py
├── project.py
├── run.py
├── server.py
├── train.py
└── version.py

My Custom component sentiment.py :


from rasa_nlu.components import Component
# all import needed

class MySentimentAnalyzer(Component):
    """A pre-trained sentiment component"""

    name = "MySentimentAnalyzer"
    provides = ["entities"]
    requires = ["tokens"]
    defaults = {}
    language_list = ["en"]

    def __init__(self, component_config=None):
        super(MySentimentAnalyzer, self).__init__(component_config)

  ## THE REST OF CODE ...

registry.py :


from rasa_nlu.customcomponents.sentiment import MySentimentAnalyzer
# all import needed

component_classes = [
#
# all rasa components added no change
#
MySentimentAnalyzer
]

## THE REST OF COD

Error (including full traceback):

{
  "error": "Failed to find component class for 'customcomponents.sentiment.MySentimentAnalyzer'. Unknown component name. Check your configured pipeline and make sure the mentioned component is not misspelled. If you are creating your own component, make sure it is either listed as part of the `component_classes` in `rasa_nlu.registry.py` or is a proper name of a class in a module."
}

Command or request that led to error: (Python)


requests.post(
                url='http://0.0.0.0:5000/train',
                params = (('project', PROJECT_NAME), ('model', MODEL_NAME)),
                headers = {'content-type': 'application/x-yml'},
                data = data
            )

Content of configuration file (config.json) (if relevant):

{
   "language":"pl",
   "pipeline":[
      {
         "name":"tokenizer_whitespace"
      },
      {
         "name":"customcomponents.sentiment.MySentimentAnalyzer"
      },
      {
         "name":"ner_duckling_http",
         "locale":"pl_Pl",
         "url":"http://127.0.0.1:8000",
         "dimensions":[
            "time",
            "number",
            "money"
         ]
      }
   ]
}

NEED HELP :

in config file try different combinations, still rasa can’t find my component :confused: any ide wht’s wrong ??

Content of configuration file (config.json) which I try :

  • name:“customcomponents.sentiment.MySentimentAnalyzer”
  • name:“sentiment.MySentimentAnalyzer”
  • name:".MySentimentAnalyzer"

All of them don’t work for me :confused:

Hey @SalAlba if you’ve added it to the registry, then I think just the name of the component should work. You shouldn’t need to add it to the registry though, take a look here: Custom NLU Components