简体   繁体   中英

wit.ai HTTP API utterance request fails to validate utterance

I'm trying to use wit.ai's utterance HTTP API endpoint . I've set up some test phrases and made entities in the wit.ai interface. 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:

[{
  "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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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