1. 指令执行步骤
1).训练数据
rasa train
2).启动Rasa动作服务器
rasa run actions
3).启动Rasa服务器和客户端(在新建的命令行里)
rasa shell
3.1).(基于网页访问方式)启动Rasa服务器和客户端(在新建的命令行里)
启动Rasa服务器
rasa run --cors "*"
启动网页客户端
切换到目录 web_client
下,
cd web_client
然后执行:
python -m http.server
在网页浏览器中输入
http://localhost:8000/
或
http://127.0.0.1:8000/
2. 问题追踪
Q1:首次不能完全识别"今天上海天气怎么样"?
Fixed:
Q2: exception while running action ‘respond_chitchat’
2022-04-03 08:47:46 ERROR rasa.core.processor - Encountered an exception while running action 'respond_chitchat'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
Traceback (most recent call last):
File "/Users/liaowenfeng/opt/anaconda3/envs/py380_rasa/lib/python3.8/site-packages/rasa/core/actions/action.py", line 722, in run
response = await self.action_endpoint.request(
File "/Users/liaowenfeng/opt/anaconda3/envs/py380_rasa/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 173, in request
raise ClientResponseError(
rasa.utils.endpoints.ClientResponseError: 404, Not Found, body='b'{"error":"No registered action found for name \'respond_chitchat\'.","action_name":"respond_chitchat"}''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/liaowenfeng/opt/anaconda3/envs/py380_rasa/lib/python3.8/site-packages/rasa/core/processor.py", line 868, in _run_action
events = await action.run(
File "/Users/liaowenfeng/opt/anaconda3/envs/py380_rasa/lib/python3.8/site-packages/rasa/core/actions/action.py", line 746, in run
raise RasaException("Failed to execute custom action.") from e
rasa.shared.exceptions.RasaException: Failed to execute custom action.
Fixed:
这是因为:respond_chitchat没有实现,改成:utter_chitchat即可
Q3: 不能识别更多的意图时
FIXED:
Q4 询问天气时,返回results
Fixed
services/weather.py中需要设置SENIVERSE_KEY值,如:
KEY = os.getenv("SENIVERSE_KEY", "Sq0zIGw7UCR7Evo30") # API key
Q5 运行rasa run actions时报警告: constrain_similarities is set to False
.
fixed(暂时可忽略):
config.yml中添加"constrain_similarities: true"
深究下去,发现原来其初始值是False
Q6 运行rasa run actions时报警告: Misaligned entity annotation in message ‘今天天气如何’ with intent ‘weather’
fixed:
使用自定义分词组件可修复之,参考第9章的源码;
Q7 运行rasa shell时报警告:Slot auto-fill has been removed in 3.0 and replaced with a new explicit mechanism to set slots
rasa\shared\core\slot_mappings.py:213: UserWarning: Slot auto-fill has been removed in 3.0 and replaced with a new explicit mechanism to set slots. Please refer to https://rasa.com/docs/rasa/domain#slots to learn more.
rasa.shared.utils.io.raise_warning(
fixed(暂时可忽略):
官方说明:
3. 参考:
我正在「AI爱好者社区」服务器中聊天,来和我一起畅聊吧 ~ 点击加入:https://fanbook.mobi/3H6D5FVN