【问题标题】:Unable to find Rasa custom component找不到 Rasa 自定义组件
【发布时间】:2019-07-22 07:32:27
【问题描述】:

我正在尝试在 Rasa 中添加自定义组件。 在尝试训练模型时编写自定义组件后,出现以下错误:

ModuleNotFoundError: No module named 'RasaCustomPy'

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.

我的项目结构如下:

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

config.yml 中,我尝试按如下方式添加我的自定义组件:

pipeline: 
- name: RasaCustomPy.my_module.MyCustomComponent

所有 Rasa 依赖包都安装在 venv 文件夹中。 当我在激活我的 virtualenv 后尝试使用命令rasa train 训练它时出现错误。我正在使用 Rasa 1.0.7。

我是 Rasa 的新手,如有任何帮助,我们将不胜感激。

【问题讨论】:

    标签: python rasa-nlu rasa


    【解决方案1】:

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

    路径应该是相对于你的配置所在的位置,所以在这种情况下,因为你已经在 RasaCustomPy 目录中,我想你想要

    pipeline: 
     - name: my_module.MyCustomComponent
    

    但如果这不起作用,请尝试使用文件的路径。

    【讨论】:

    • 确实是我使用的旧版本。将 rasa 更新到最新版本后,自定义组件得到了认可。谢谢。
    • 我还按照您的描述更改了管道中组件的名称。
    猜你喜欢
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 2020-05-01
    • 2020-07-23
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多