While using the ValidateSamples
method with the sample code shown in the docs : https://wit.ai/docs/http/20170307#post__samples_link
[{
"text": "I want to fly to sfo",
"entities": [
{
"entity": "intent",
"value": "flight_request"
},
{
"entity": "wit$location",
"start": 17,
"end": 20,
"value": "sfo"
}
]
}]
I'm getting error : unable to make a request. error: Failed to validate sample at index 0. Start must be less than end.
I also slightly altered your integration test to reproduce the same error. I added below code to the TestIntegrationSamples
test :
// samples test
_, validateErr := c.ValidateSamples([]Sample{
{
Text: "I want to fly SFO",
Entities: []SampleEntity{
{
Entity: "intent",
Value: "flight_request",
},
{
Entity: "wit$location",
Value: "SFO",
Start: 17,
End: 20,
},
},
},
})
The added lines were just to make the test match the sample curl command in the docs : https://wit.ai/docs/http/20170307#post__samples_link
And as suspected the integration test now fails with :
=== RUN TestIntegrationSamples
--- FAIL: TestIntegrationSamples (5.53s)
integration_test.go:197: expected nil error, got unable to make a request. error: Failed to validate sample at index 0. Start must be less than end.
I believe this is because the struct def has int values for the start
and end
fields, but in this example where the intent
doesn't need the text selection to be called out (like when you have a trait lookup strategy) so there is no value given for start
and end
, they are give the zero value for the type, which is 0
.
The problem is the api receives :
[
{
"text": "I want to fly to sfo",
"entities": [
{
"entity": "intent",
"value": "flight_request",
"start": 0,
"end": 0,
"role": "",
"subentities": null,
},
{
"entity": "wit$location",
"value": "SFO",
"start": 17,
"end": 20,
"role": "",
"subentities": null,
}
]
}
]
and it responds with a 400 :
{
"error": "Failed to validate sample at index 0. Start must be less than end.",
"code": "bad-request"
}
If I hit the api outside of the library and replace the values of start
and end
with null
or omit them completely then I get back a 200 and it works as expected.
Maybe I'm missing something here? I would really appreciate some help here. Thanks!