简体   繁体   English

找不到Rasa自订元件

[英]Unable to find Rasa custom component

I am trying to add a custom component in Rasa. 我正在尝试在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: config.yml内部,我尝试添加自定义组件,如下所示:

pipeline: 
- name: RasaCustomPy.my_module.MyCustomComponent

All Rasa dependency packages are installed inside the venv folder. 所有Rasa依赖包都安装在venv文件夹中。 I get the error when I tried to train it using the command rasa train after activating my virtualenv. 激活virtualenv后,尝试使用命令rasa train对其进行训练时出现错误。 I am using Rasa 1.0.7. 我正在使用Rasa 1.0.7。

I am new to Rasa and any help would be appreciated. 我是Rasa的新手,任何帮助将不胜感激。

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) 自定义组件路径未正确添加到python路径的问题已在1.1.5中修复,因此请确保您使用的版本晚于该版本(通常包括您正在SO中运行的任何软件的版本)帖子对尝试调试/复制您的问题的人很有帮助)

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 路径应该相对于配置所在的位置,因此在这种情况下,因为您已经在RasaCustomPy目录中,所以我想

pipeline: 
 - name: my_module.MyCustomComponent

but if that doesn't work, try playing around with the path to the file. 但是,如果这样不起作用,请尝试播放文件的路径。

如何解决错误“异常:找不到组件 class for ' <spacy.lang.pt.portuguese object" in rasa_nlu python?< div><div id="text_translate"><p> 我使用 rasa_nlu package 在 Jupyter Notebook 中启动葡萄牙语聊天机器人,运行代码时收到以下错误消息:</p><pre> Exception: Failed to find component class for '&lt;spacy.lang.pt.Portuguese object at 0x000001D94243BE48&gt;'. 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.</pre><p> 这是我的代码。 我不确定问题的原因,但我认为这可能与葡萄牙语的使用有关:</p><pre> from rasa_nlu.converters import load_data from rasa_nlu.config import RasaNLUConfig from rasa_nlu.model import Trainer #Create args dictionary import spacy nlp = spacy.load('pt_core_news_sm') spacy_sklearn_pipeline = [ nlp, "ner_crf", "ner_synonyms", "intent_featurizer_spacy", "intent_classifier_sklearn" ] args = {"pipeline": spacy_sklearn_pipeline} config = RasaNLUConfig(cmdline_args = args) trainer = Trainer(config)</pre><p> 在上面的行之后,出现错误:</p><pre> TypeError Traceback (most recent call last) ~\anaconda3\lib\site-packages\rasa_nlu\registry.py in get_component_class(component_name) 126 try: --&gt; 127 return utils.class_from_module_path(component_name) 128 except Exception: ~\anaconda3\lib\site-packages\rasa_nlu\utils\__init__.py in class_from_module_path(module_path) 121 # load the module, will raise ImportError if module cannot be loaded --&gt; 122 if "." in module_path: 123 module_name, _, class_name = module_path.rpartition('.') TypeError: argument of type 'Portuguese' is not iterable During handling of the above exception, another exception occurred: Exception Traceback (most recent call last) &lt;ipython-input-14-eee0bfaf3435&gt; in &lt;module&gt; ----&gt; 1 trainer = Trainer(config) ~\anaconda3\lib\site-packages\rasa_nlu\model.py in __init__(self, config, component_builder, skip_validation) 124 # required packages are available 125 if not self.skip_validation: --&gt; 126 components.validate_requirements(config.pipeline) 127 128 # Transform the passed names of the pipeline components into classes ~\anaconda3\lib\site-packages\rasa_nlu\components.py in validate_requirements(component_names) 54 failed_imports = set() 55 for component_name in component_names: ---&gt; 56 component_class = registry.get_component_class(component_name) 57 failed_imports.update(find_unavailable_packages( 58 component_class.required_packages())) ~\anaconda3\lib\site-packages\rasa_nlu\registry.py in get_component_class(component_name) 134 "listed as part of the `component_classes` in " 135 "`rasa_nlu.registry.py` or is a proper name of a class " --&gt; 136 "in a module.".format(component_name)) 137 return registered_components[component_name] 138 Exception: Failed to find component class for '&lt;spacy.lang.pt.Portuguese object at 0x000001D94243BE48&gt;'. 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.</pre></div></spacy.lang.pt.portuguese> - How to solve the error "Exception: Failed to find component class for '<spacy.lang.pt.Portuguese object" in rasa_nlu in python?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未能加载组件 rasa - Failed to load the component rasa Rasa sdk 自定义日志记录 - Rasa sdk custom logging Rasa核心自定义模板 - Rasa core custom template 无法将 Rasa 机器人与 Flask 集成 - Unable to integrate Rasa bot with Flask 无法在 Rasa 中下载 Spacy 模型 - Unable to download a Spacy model in Rasa 如何解决错误“异常:找不到组件 class for ' <spacy.lang.pt.portuguese object" in rasa_nlu python?< div><div id="text_translate"><p> 我使用 rasa_nlu package 在 Jupyter Notebook 中启动葡萄牙语聊天机器人,运行代码时收到以下错误消息:</p><pre> Exception: Failed to find component class for '&lt;spacy.lang.pt.Portuguese object at 0x000001D94243BE48&gt;'. 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.</pre><p> 这是我的代码。 我不确定问题的原因,但我认为这可能与葡萄牙语的使用有关:</p><pre> from rasa_nlu.converters import load_data from rasa_nlu.config import RasaNLUConfig from rasa_nlu.model import Trainer #Create args dictionary import spacy nlp = spacy.load('pt_core_news_sm') spacy_sklearn_pipeline = [ nlp, "ner_crf", "ner_synonyms", "intent_featurizer_spacy", "intent_classifier_sklearn" ] args = {"pipeline": spacy_sklearn_pipeline} config = RasaNLUConfig(cmdline_args = args) trainer = Trainer(config)</pre><p> 在上面的行之后,出现错误:</p><pre> TypeError Traceback (most recent call last) ~\anaconda3\lib\site-packages\rasa_nlu\registry.py in get_component_class(component_name) 126 try: --&gt; 127 return utils.class_from_module_path(component_name) 128 except Exception: ~\anaconda3\lib\site-packages\rasa_nlu\utils\__init__.py in class_from_module_path(module_path) 121 # load the module, will raise ImportError if module cannot be loaded --&gt; 122 if "." in module_path: 123 module_name, _, class_name = module_path.rpartition('.') TypeError: argument of type 'Portuguese' is not iterable During handling of the above exception, another exception occurred: Exception Traceback (most recent call last) &lt;ipython-input-14-eee0bfaf3435&gt; in &lt;module&gt; ----&gt; 1 trainer = Trainer(config) ~\anaconda3\lib\site-packages\rasa_nlu\model.py in __init__(self, config, component_builder, skip_validation) 124 # required packages are available 125 if not self.skip_validation: --&gt; 126 components.validate_requirements(config.pipeline) 127 128 # Transform the passed names of the pipeline components into classes ~\anaconda3\lib\site-packages\rasa_nlu\components.py in validate_requirements(component_names) 54 failed_imports = set() 55 for component_name in component_names: ---&gt; 56 component_class = registry.get_component_class(component_name) 57 failed_imports.update(find_unavailable_packages( 58 component_class.required_packages())) ~\anaconda3\lib\site-packages\rasa_nlu\registry.py in get_component_class(component_name) 134 "listed as part of the `component_classes` in " 135 "`rasa_nlu.registry.py` or is a proper name of a class " --&gt; 136 "in a module.".format(component_name)) 137 return registered_components[component_name] 138 Exception: Failed to find component class for '&lt;spacy.lang.pt.Portuguese object at 0x000001D94243BE48&gt;'. 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.</pre></div></spacy.lang.pt.portuguese> - How to solve the error "Exception: Failed to find component class for '<spacy.lang.pt.Portuguese object" in rasa_nlu in python? 无法在 Windows 10 上安装 Rasa 1.7.0 - Unable to install Rasa 1.7.0 on Windows 10 无法预测在python中使用rasa_nlu - unable to predict using rasa_nlu in python 无法通过终端安装“rasa_nlu” - unable to install 'rasa_nlu' by terminal 无法在 RASA 聊天机器人中获得对话语的响应 - Unable to get response for utterance in RASA chatbot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM