Rasa自定义action_redirect_to_scholarship未注册错误求助
解决Rasa中「No registered action found for name 'action_redirect_to_scholarship'」错误的方案
核心排查步骤
1. 确认自定义Action类的命名与注册
- 检查
actions/目录下的Python文件(比如actions/actions.py),确保类的name方法返回值与报错中的action名称完全一致:from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher class ActionRedirectToScholarship(Action): def name(self) -> str: return "action_redirect_to_scholarship" # 必须和domain、触发逻辑里的名称完全匹配 def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: dict) -> list: # 编写跳转逻辑,比如发送带链接的提示 dispatcher.utter_message(text=f"奖学金详情请查看:[点击进入](https://your-school-scholarship-url.com)") return [] - 确保
actions/目录下存在空的__init__.py文件,让Rasa能识别该模块。
2. 验证domain.yml的配置
- 在
domain.yml的actions列表里必须显式添加这个action,不能有拼写或大小写错误:actions: - action_redirect_to_scholarship # 其他已定义的action...
3. 检查Action Server的运行状态
- 本地开发时,要单独启动Action Server,且指定正确的actions模块:
rasa run actions --actions actions - 确保Action Server和Rasa Core服务同时运行,端口默认5055,若有修改需和
endpoints.yml配置一致。
4. 核对endpoints.yml的Action配置
- 如果配置了自定义Action Server地址,确认地址正确且服务可访问:
action_endpoint: url: "http://localhost:5055/webhook" - 本地开发无特殊需求时,保持默认配置即可,但必须保证Action Server在运行。
5. 清理缓存并重启服务
- 清理旧模型缓存,重新训练:
rasa train - 重启Rasa Core和Action Server,避免旧缓存导致的识别异常。
额外排查点
- 检查stories.yml/rules.yml中触发该action的逻辑是否正确,确保意图与action的关联无误:
stories: - story: 查询奖学金触发跳转 steps: - intent: ask_scholarship - action: action_redirect_to_scholarship - 确认
rasa和rasa-sdk版本一致,版本不兼容会导致action注册失败:
比如两者都保持3.6.x系列版本。pip list | grep rasa
内容的提问来源于stack exchange,提问作者Radical Rosh
相关产品推荐
相关产品推荐

