Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python rasa从自定义操作填充插槽_Python_Rasa Nlu_Rasa - Fatal编程技术网

Python rasa从自定义操作填充插槽

Python rasa从自定义操作填充插槽,python,rasa-nlu,rasa,Python,Rasa Nlu,Rasa,我正试着用rasa建立一个机器人。在对话的一开始,它应该用数据库中的数据填充一些插槽 我有一个自定义操作: class ActionFillSlots(Action): def name(self) -> Text: return "action_fill_slots" def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[

我正试着用rasa建立一个机器人。在对话的一开始,它应该用数据库中的数据填充一些插槽

我有一个自定义操作:

class ActionFillSlots(Action):

def name(self) -> Text:
    return "action_fill_slots"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

    example = "example"
    return [SlotSet("example", example)]
在我的domain.yml文件中,我设置了如下插槽:

slots:
  example:
  type: text
而这样的回答是:

 utter_greet:
 - text: "Show { example }"
在我的stories.yml文件中,我有如下故事:

- story: greet happy path
  steps:
  - intent: greet
  - action: action_fill_slots
  - action: utter_greet
如果我使用rasashell--debug运行bot 然后键入与问候意图匹配的内容,我得到以下错误:

无法填充话语模板“Show{example}”试图替换“example”,但找不到值 我很高兴。没有具有此名称的插槽,也没有在调用模板时显式传递值。返回模板而不填充模板

在我的调试窗口中,我可以看到插槽已由操作设置:

当前插槽值: 例句:例句


我正在使用rasa 2.1.0,这有帮助吗?让我知道

from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionFillSlots(Action):

def name(self) -> Text:
    return "action_fill_slots"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

    example = tracker.get_slot(example)
    dispatcher.utter_message(text = str(example))

    return []

这有用吗?让我知道

from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionFillSlots(Action):

def name(self) -> Text:
    return "action_fill_slots"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

    example = tracker.get_slot(example)
    dispatcher.utter_message(text = str(example))

    return []