wit-ai / wit-go Goto Github PK
View Code? Open in Web Editor NEWGo client for wit.ai HTTP API
License: MIT License
Go client for wit.ai HTTP API
License: MIT License
Hey,
I dont know if this issue should be reported here or in the main wit.ai repo.
But with the golang client when i try to delete a value with a space in it for an intent e.g
wit.DeleteEntityValue("intent", "Au revoir")
The value is not deleted on wit.ai because of this : url.QueryEscape(value)
Standard QueryEscape call encodes a space with a "+" character.
Also this curl command dont work
curl -XDELETE 'https://api.wit.ai/entities/intent/values/Au+revoir?v=20170307'
But this one does
curl -XDELETE 'https://api.wit.ai/entities/intent/values/Au%20revoir?v=20170307'
The latest release of this package is a major version (2.0.0) and thus requires a /v2
suffix on the module path per the Go modules docs. It is currently impossible to install the v2.0.0 release of this package via go get
because of invalid packaging.
Since wit.ai v2 the wit-go is broken.
I thought NewClientWithVersion(token, DefaultVersion)
would prevent this, as it calls the API with API versioning.
But the API may not send an old-fashioned result back.
It will not work with v2, but DefaultVersion = "20170307"
don't ensure, that this version is used.
I think it is not an issue of wit-go, but with the API.
But to workaround this issue, it is needed to update wit-go to the latest version of the API.
How to specify the language (English, German,etc..)?
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!
The latest version of the API response contract doesn't seem to match the current struct definition. Are there any plans to support this, maybe in v2 (since this is definitely breaking)? Is it fine if I create a PR for this?
With real Wit.ai API
According the wit.ai doc [1] when we create an app the response as the following structure
{ "access_token" : "NEW_ACCESS_TOKEN", "app_id" : "NEW_APP_ID" }
Then instead of returning an empty app the function CreateApp should return this structure instead of an empty App
I'd like to use this library on google appengine.
Though Appengine doesn't allow outbound http request [1], thus we should be able to pass a specific http.Client
[1] https://cloud.google.com/appengine/docs/standard/go/issue-requests
json: cannot unmarshal number into Go struct field MessageEntity.entities.value of type string
Hello,
Sorry for a basic question but I wasted 5 days for that problem
// communicate with AI service
result, err := witClient.Parse(&witai.MessageRequest{
Query: textMessage,
})
if err != nil { // handle error
}
// we have `result` (witai.MessageResponse) here
data := []byte(result.Entities) // cannot continue because error convert from interface{} to []byte
I cannot continue because error convert from interface{}
to []byte
.
I want to extract entities key to an array and entities content to an another.
Hope you can guide me how to extract that.
Thanks in advanced !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.