wit.ai HTTP API utterance request fails to validate utterance

264 views Asked by At

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.

1

There are 1 answers

0
user10248665 On

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.