python - 要求用户填写 Rasa Chatbot 中的空位
问题描述
当我需要要求用户填补空位时,我正在努力创建一个对话结构。
考虑以下交互。
User: What is the scientific name of Eagles?
Bot: There are 3 eagles. Choose one.
- greater spotted eagle
- tawny eagle
- indian spotted eagle
User: tawny eagle
Bot: Scientific name of Tawny Eagle is Clanga clanga
Stories.md
如果只有一个值,这是我的文件。
## Story1
* Scientific_name{'common_name': 'eagles'}
- action_sci_name
和我的action.py
class ActionSciName(Action):
def name(self):
return "action_sci_name"
def run(self, dispatcher, tracker, domain):
# below line gives 'Eagles`
name = tracker.latest_message['entities'][0]['value']
## I fetch the value from DB for eagles if they are more than 1
## More code here
response = """There are 3 eagles. Choose one
1. greater spotted eagle
2. tawny eagle
3. indian spotted eagle"""
dispatcher.utter_message(response)
return []
上面的文件可以很好地完成第一部分。但我被困在下一个用户需要输入这 3 个值之间的地方。
意图:
- 科学名称
- Common_name
实体:
- common_name
- sci_name
我看过很多文章和博客,但它们都是非常基础的。他们使用slots
但用户在第一行本身输入值。
任何帮助表示赞赏。
解决方案
我认为Rasa中的表格可以帮助您。使用表单,您可以验证输入并指定用户必须填写哪些插槽。
推荐阅读
- c# - Xml中的无效操作?
- electron - 如何从网站启动我的电子应用程序
- akka - 为什么 Akka 不返回地址/主机信息?
- python - 使用方法将文本文件内容附加到 Python 中的字典中?
- java - 另一个数组中元素的 Java 桶排序
- angular-ui-grid - 隐藏所有项目时隐藏或刷新元素 ui-grid
- batch-file - 从批处理文件中的日期减去年数
- python - 我的 selenium instagram 机器人的 xpath 单击配置文件而不是弹出类似框
- wordpress - Integrating authorize.net in contact form 7
- datetime - 一个 time.Parse 错误,我做错了什么?