我不了解插槽映射如何知道要回答用户的“话语”以获取所请求的“实体”。
我的表单类的示例:
class RestaurantForm(FormAction):
"""Example of a custom form action"""
def name(self):
# type: () -> Text
"""Unique identifier of the form"""
return "formaejemplo"
@staticmethod
def required_slots(tracker):
# type: () -> List[Text]
"""A list of required slots that the form has to fill"""
return ["valor1","valor2","valor3"]
def slot_mappings(self):
return {"valor1": self.from_entity(entity="valor1",intent="getvalor1"),
"valor2": self.from_entity(entity="valor2",intent="getvalor2"),
"valor3": self.from_entity(entity="valor3",intent="getvalor3")}
def submit(self, dispatcher, tracker, domain):
dispatcher.utter_template('utter_listo', tracker)
return []
domain.yml:
intents:
- peticion_habitacion:
use_entities: false
- getvalor1
- getvalor2
- getvalor3
entities:
- valor1
- valor2
- valor3
slots:
valor1:
type: unfeaturized
auto_fill: false
valor2:
type: unfeaturized
auto_fill: false
valor3:
type: unfeaturized
auto_fill: false
actions:
- utter_prueba
- utter_completo
templates:
utter_completo:
- text: "listo:\nvalor 1 {valor1} \nvalor 2 {valor2} \nvalor 3 {valor3}"
utter_prueba:
- text: "iniciando prueba:\n"
utter_valor1:
- text: "dame el valor 1 no enteros"
utter_valor2:
- text: "dame el valor 2 no enteros"
utter_valor3:
- text: "dame el valor 3 no enteros"
utter_listo:
- text: "prueba completa"
forms:
- formaejemplo
在获取value1,value2等的部分...根据Rasa文档:“ valor1”:self.from_entity(entity =“ valor1”,intent =“ getvalor1”“” valor 1“将从意图getvalor1获取。”
我的问题是,在什么时候,在哪个部分或什么文件中,操作表单将被告知必须发送“话语”,“ utter_valor1”或“ utter_valor2”,因为对于几个Internet示例以及相同的示例的拉萨机器人,我看到这些机器人发出了话语,然后恢复了价值,但是我无法理解它们如何发出话语并得到了价值
答案 0 :(得分:0)
我假设您的意思是sdk操作如何确定应使用哪个模板来请求所请求的广告位,对吗?
此逻辑实际上是在此处硬编码的:https://github.com/RasaHQ/rasa_core_sdk/blob/cfffaac0013606f7614ab0f213bc39623ee8b53c/rasa_core_sdk/forms.py#L374
它所做的只是发出utter_ask_{the name of slot which should be requested}
的语音。
如果用户随后将其答案发送回去,则会再次触发表单操作,并且可以提取广告位值。