Search code examples
pythonrasa-nlurasa

Unable to find Rasa custom component


I am trying to add a custom component in Rasa. After writing my custom component when I tried to train my model, I got the following errors:

ModuleNotFoundError: No module named 'RasaCustomPy'

and

Exception: Failed to find component class for 'RasaCustomPy.my_module.MyCustomComponent'. 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.

My project has the following structure:

RasaCustomPy
|
|---__init__.py
|
|---actions.py
|
|---my_module.py
|
|---data
|
|---venv
|
|---config.yml
|
|---credentials.yml
|
|---domain.yml
|
|---endpoints.yml

Inside config.yml, I have tried to add my custom component as follows:

pipeline: 
- name: RasaCustomPy.my_module.MyCustomComponent

All Rasa dependency packages are installed inside the venv folder. I get the error when I tried to train it using the command rasa train after activating my virtualenv. I am using Rasa 1.0.7.

I am new to Rasa and any help would be appreciated.


Solution

  • the issue of custom component paths not being correctly added to the python path was fixed in 1.1.5, so make sure that you have a version that is later than that one (in general including your version of whatever software you're running in SO posts is helpful for anyone trying to debug/replicate your issue)

    The paths should be relative to where your config is located, so in this case, as you're already in the RasaCustomPy directory, I think you want

    pipeline: 
     - name: my_module.MyCustomComponent
    

    but if that doesn't work, try playing around with the path to the file.