简体   繁体   English

wit.ai HTTP API 话语请求无法验证话语

[英]wit.ai HTTP API utterance request fails to validate utterance

I'm trying to use wit.ai's utterance HTTP API endpoint .我正在尝试使用wit.ai 的话语 HTTP API 端点 I've set up some test phrases and made entities in the wit.ai interface.我在 wit.ai 界面中设置了一些测试短语并创建了实体。 The entities are registered as being related to the intent.实体被注册为与意图相关。 I've set the entity to "Free Text".我已将实体设置为“自由文本”。

Now I'm trying to add utterances/entities in bulk programmatically using Python. An example of the utterances/entities I want to send is below:现在,我正在尝试使用 Python 以编程方式批量添加话语/实体。下面是我要发送的话语/实体的示例:

[{
  "text": "I want to get a cat, dog, and bird.",
  "intent": "want_pet",
  "entities": [
    {
      "entity": "pet",
      "start": 16,
      "end": 19,
      "body": "cat",
      "entities": []
    },
    {
      "entity": "pet",
      "start": 21,
      "end": 24,
      "body": "dog",
      "entities": []
    },
    {
      "entity": "pet",
      "start": 30,
      "end": 34,
      "body": "bird",
      "entities": []
    },
  ],
  "traits": []
},
{
  "text": "I'd like a fish and an iguana.",
  "intent": "want_pet",
  "entities": [
    {
      "entity": "pet",
      "start": 11,
      "end": 15,
      "body": "fish",
      "entities": []
    },
    {
      "entity": "pet",
      "start": 23,
      "end": 29,
      "body": "iguana",
      "entities": []
    }
  ],
  "traits": []
}]

When I send the request, though, I get back the following error:但是,当我发送请求时,我收到以下错误:

{'error': 'Failed to validate utterance at index 0. Could not find entity "pet".', 'code': 'bad-request'}

Any ideas about what's going wrong or what I could look into would be very helpful.关于出了什么问题或我可以调查的任何想法都会非常有帮助。 I'd really like to upload batches of utterances at once.我真的很想一次上传成批的话语。

In the entity values, I put "pet:pet" and it worked.在实体值中,我输入了“pet:pet”,它起作用了。

It seems like the entity field needs the "entity" and the "role."似乎实体字段需要“实体”和“角色”。 The role doesn't have to be the same as the entity, but it needs to be defined.角色不必与实体相同,但需要对其进行定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM