Custom NLU Components Failed to find component class
See original GitHub issueRasa 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 😕 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 😕
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Custom NLU Components Failed to find component class
Issue: I'm trying to make own Custom NLU Components, but rasa_nlu can't find my component, probably I miss something
Read more >rasa - rasa_nlu: Failed to find component class, unknown ...
I don't have any custom components - I'm only using the standard pipeline. Exception: Failed to find component class for 'WhitespaceTokenizer'.
Read more >Hi! Thanks for the tutorial.. Exception: Failed to find component…
Hi! Thanks for the tutorial. I have created the sentiment.py file in the main project directory and added sentiment.
Read more >Oracle Digital Assistant Known Issues - Cloud
If there are files in that directory structure that aren't custom components, the upload process fails because it can't parse the file as...
Read more >Advance Rasa: NLU Pipelines and more - Turtle-Techies
Custom NLU pipeline Components. Rasa NLU permits making a custom Component to play out a particular task which NLU doesn't presently offer.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The error message can be misleading. You will see the same error if your component fails to import for any reason i.e. missing dependencies, has any syntax or other error you might have in your custom component or component not in your
PYTHONPATH
. I had to fix all these three issues to get it working:To debug try:
Also check that you can import any dependencies you declared in
required_packages
. For example if yourrequired_packages
looks like:check that you can import
nltk
.Finally make sure that your component is in the PYTHONPATH (ex:
export PYTHONPATH=.
). It is not enough to have it on the root folder of the project. For some reason rasa doesn’t look there at least if you use the new cli (rasa train
).Related issues: https://github.com/RasaHQ/rasa/issues/3552 https://github.com/RasaHQ/rasa/issues/1513
I’ve had a similar problem. The path to my sentiment analyzer is this:
nlu.custom_components.sentiment.SentimentAnalyzer
, but when I runrasa train
I get this error:I haven’t added the directory to my Python path, but I shouldn’t need to do that, right?