go-wit icon indicating copy to clipboard operation
go-wit copied to clipboard

Deprecated API

Open lenfree opened this issue 7 years ago • 0 comments

Making a request directly to wit.ai endpoint returns a new data structure:

curl \
  -H 'Authorization: Bearer $TOKEN' \
  'https://api.wit.ai/message?v=20160526&q=hello_world'
{
  "msg_id" : "e83597bb-cf63-429a-be0f-76779cd95b5f",
  "_text" : "hello_world",
  "entities" : {
    "intent" : [ {
      "confidence" : 1.0,
      "value" : "greetings"
    } ]
  }
}

Hence, with this package, should make necessary changes

@ -22,7 +22,6 @@ type Outcome struct {
        Intent     string                     `json:"intent"`
        IntentId   string                     `json:"intent_id"`
        Entities   map[string][]MessageEntity `json:"entities"`
-       Confidence float32                    `json:"confidence"`
 }

 // MessageEntity represents the entity portion of a Wit message
@@ -39,6 +38,7 @@ type MessageEntity struct {
        Values   *[]interface{}       `json:"values,omitempty"`
        From     *DatetimeIntervalEnd `json:"from,omitempty"`
        To       *DatetimeIntervalEnd `json:"to,omitempty"`
+       Confidence float32                    `json:"confidence"`
 }

to get correct output:

 "msg_id": "946659de-7457-480f-9f61-dd24b72c8dd7",
 "_text": "Hello world",
 "outcome": {
            "_text": "Hello world",
            "intent": "default_intent",
            "intent_id": "",
            "entities": {
               "intent": [
                    {
                        "value": "greetings",
                        "confidence": 0.5108957
                    }
                ]
            }      
  }

lenfree avatar Jan 10 '17 01:01 lenfree