RASA FORMS-'NoneType'对象不可迭代

问题描述

我正在创建一个机器人,以帮助用户根据所提供的名称搜索文件,并且我正在使用一个插槽来存储名为“ SEARCHCONTENT”的文件名的内存,并且我正在使用“ SEARCH”实体来帮助漫游器识别搜索词的不同同义词。这是我要搜索文件的nlu数据:

## intent:searchSynonyms
 - [search](SEARCH)
 - [look for](SEARCH)
 - [find](SEARCH)
 - [where is](SEARCH)

## intent:file
- file
- file [bills](SEARCHCONTENT)
- [search](SEARCH) file
- [search](SEARCH) file [mouse](SEARCHCONTENT)
- [search](SEARCH) for a file
- [search](SEARCH) for a file [laptops](SEARCHCONTENT)
- [searching](SEARCH) file
- [searching](SEARCH) file [accounting](SEARCHCONTENT)
- [where is](SEARCH) the file
- [where is](SEARCH) the file [order summary](SEARCHCONTENT) located
- [look for](SEARCH) the file
- [look for](SEARCH) the file [degree planner](SEARCHCONTENT)
- [find](SEARCH) file
- [find](SEARCH) file [design report](SEARCHCONTENT)

在域文件中,我指定了以“文本”作为输入的插槽名称

slots:
  SEARCHCONTENT:
    type: text
    auto_fill: false

然后我继续创建表单:

from typing import Any,Text,Dict,List

from rasa_sdk import Action,Tracker
from rasa_sdk.executor import Collectingdispatcher
from rasa_sdk.events import SlotSet
from rasa_sdk.forms import FormAction
class FormActionFileSearch(FormAction):
    """Custom form action to find file"""

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

    @staticmethod
    def required_slots(tracker: "Tracker") -> List[Text]:
        return ["SEARCHCONTENT"]

    def slot_mappings(self) -> Dict[Text,Any]:
        return {"SEARCHCONTENT": self.from_entity(entity="SEARCHCONTENT",intent=["file"])}

    def submit(
        self,dispatcher: "Collectingdispatcher",tracker: "Tracker",domain: Dict[Text,Any],) -> List[Dict]:
        search_content = tracker.get_slot("SEARCHCONTENT")
        dispatcher.utter_message("Searching file " + search_content)

现在,我要做的就是打印文件名,以检查文件名是否正确地从插槽中提取了值。
然后,我进入domain.yml文件添加表单操作名称

forms:
  - form_action_file_search

然后我继续在config.yml文件添加表单策略:

policies:
 - name: FormPolicy

然后我继续为文件搜索创建故事:

## file path affirm
* file{"SEARCHCONTENT":"car budget"}
- form_action_file_search
- form{"name": "form_action_file_search"}
- form{"name": null}
- utter_assistance
* affirm
- utter_askAssistance

然后将所有意图和操作添加到domain.yml文件中,这就是它的外观:

intents:
- file
- affirm
entities:
- SEARCH
- SEARCHCONTENT
slots:
  SEARCHCONTENT:
    type: text
    auto_fill: false
forms:
  - form_action_file_search
responses:
  utter_assistance:
  - text: Is there anything else you need?
  utter_askAssistance:
  - text: How can I help you?
actions:
- utter_assistance
- utter_askAssistance

运行机器人并输入“搜索文件帐户摘要”作为输入时,出现以下错误

enter image description here


解决方法

您可以尝试将插槽类型更改为未功能化吗?

slots:
  SEARCHCONTENT:
    type: unfeaturized
    auto_fill: false

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...