hexastack / wit-api Goto Github PK
View Code? Open in Web Editor NEWNode lib to easily interact with Wit.ai HTTP API
License: BSD 4-Clause "Original" or "Old" License
Node lib to easily interact with Wit.ai HTTP API
License: BSD 4-Clause "Original" or "Old" License
Running unit tests returns :
nyc mocha --timeout 5000 --reporter nyan
17 --------------,------,
9 --------------| /_/\
0 --------------^|__( x .x)
-------------- "" ""
17 passing (43s)
9 failing
Wit
Entity services
Get one entity by name
Should fetch an Entity:
Error: expected [Error: Not Found] to be falsy
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.ok (node_modules/expect.js/index.js:115:10)
at Function.ok (node_modules/expect.js/index.js:499:17)
at wit.entity.get.then.catch.e (test/test.js:53:31)
at process._tickCallback (internal/process/next_tick.js:109:7)
Wit
Value services
Should add a value:
Error: expected [Error: expected [] to contain 'keywords'] to be falsy
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.ok (node_modules/expect.js/index.js:115:10)
at Function.ok (node_modules/expect.js/index.js:499:17)
at wit.value.add.then.catch.e (test/test.js:158:29)
at process._tickCallback (internal/process/next_tick.js:109:7)
Wit
Expression services
Should remove an expression:
Error: expected [Error: expected { status: 400,
body: 'This entity needs at least one of keywords or trait lookup to be able to delete expressions',
code: 'bad-request' } to have a property 'deleted'] to be falsy
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.ok (node_modules/expect.js/index.js:115:10)
at Function.ok (node_modules/expect.js/index.js:499:17)
at wit.expression.delete.then.catch.e (test/test.js:192:29)
at process._tickCallback (internal/process/next_tick.js:109:7)
Wit
Learning
Train using one sample at a time
Should yeild on a json response:
Error: expected [Error: expected [Error: You tried to create 'wit$greetings'. Use POST /entities instead] to be falsy] to be falsy
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.ok (node_modules/expect.js/index.js:115:10)
at Function.ok (node_modules/expect.js/index.js:499:17)
at wit.train.then.catch.e (test/test.js:246:31)
at process._tickCallback (internal/process/next_tick.js:109:7)
Wit
Text messages
Test on a learned text
Should respond by an Intent Object:
Error: expected [Error: expected {} to not be empty] to be falsy
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.ok (node_modules/expect.js/index.js:115:10)
at Function.ok (node_modules/expect.js/index.js:499:17)
at wit.message.then.catch.e (test/test.js:283:31)
at process._tickCallback (internal/process/next_tick.js:109:7)
Wit
Text messages
Test on a forgotten text
Should respond by an Intent Object containing greeting:
Error: expected [Error: expected {} to not be empty] to be falsy
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.ok (node_modules/expect.js/index.js:115:10)
at Function.ok (node_modules/expect.js/index.js:499:17)
at wit.message.then.catch.e (test/test.js:301:31)
at process._tickCallback (internal/process/next_tick.js:109:7)
Wit
Speech
Should respond by an Intent Object:
Error: expected [Error: expected 'Hello' to equal 'hello'] to be falsy
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.ok (node_modules/expect.js/index.js:115:10)
at Function.ok (node_modules/expect.js/index.js:499:17)
at wit.speech.then.catch.e (test/test.js:319:29)
at process._tickCallback (internal/process/next_tick.js:109:7)
Wit
App Management
Delete an App
The latest wit instance shall not work
Should trigger error:
Error: expected [Error: expected { name: 'intent',
id: '5b73fa2b-cf19-4591-a653-eb78a8dc719f',
values: [],
builtin: false,
doc: 'User-defined entity',
lang: 'en',
lookups: [ 'trait' ],
request: [Function] } to be falsy] to have a property 'code'
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.property (node_modules/expect.js/index.js:381:12)
at newWit.entity.get.then.catch.e (test/test.js:406:31)
at process._tickCallback (internal/process/next_tick.js:109:7)
Wit
Error handeling
Api fails
Should fail & return Error instance with a message and code props:
Error: expected 'no-auth' to equal 'unknown'
at Assertion.assert (node_modules/expect.js/index.js:96:13)
at Assertion.be.Assertion.equal (node_modules/expect.js/index.js:216:10)
at Assertion.(anonymous function) [as be] (node_modules/expect.js/index.js:69:24)
at defectedWit.entity.list.then.catch.e (test/test.js:424:29)
at process._tickCallback (internal/process/next_tick.js:109:7)
-----------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | 80.22 | 56.76 | 80.77 | 80.15 | |
wit-api | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
wit-api/src | 88.78 | 59.18 | 95 | 88.72 | |
Entity.js | 93.18 | 84.62 | 100 | 93.02 | 47,74,78 |
Expression.js | 85.71 | 50 | 100 | 85.71 | 27,31,42 |
Message.js | 93.75 | 50 | 100 | 93.75 | 24 |
Sample.js | 87.5 | 75 | 100 | 87.5 | 26,45,49 |
Speech.js | 80 | 41.67 | 100 | 80 | 11,29,40,43,44,50 |
Value.js | 85.71 | 33.33 | 100 | 85.71 | 29,33,44 |
Wit.js | 92.5 | 66.67 | 57.14 | 92.5 | 53,58,63 |
wit-api/src/lib | 57.33 | 52 | 33.33 | 57.33 | |
App.js | 100 | 66.67 | 100 | 100 | 1 |
Entity.js | 33.33 | 33.33 | 9.09 | 33.33 | ... 56,57,59,64,66 |
Intent.js | 52.94 | 20 | 33.33 | 52.94 | ... 11,13,14,15,18 |
requestAPI.js | 85.71 | 87.5 | 100 | 85.71 | 5,11 |
----------------- | ---------- | ---------- | ---------- | ---------- | ------------------- |
npm ERR! Test failed. See above for more details. |
Got the following error when calling Wit.train() :
{
"error" : "You need to provide an array of samples",
"code" : "bad-request"
}
According to the documentation, the body must be an array. That said, maybe changing the method so i can support having an argument with one or a set of samples.
New parse payload have the following data structure :
{"text":"Bonjour","intents":[{"id":"467958847129146","name":"greeting","confidence":0.9986}],"entities":{},"traits":{"language":[{"id":"0596e762-b648-4e55-84ff-2fbaa4eca22b","value":"fr","confidence":0.9989}]}}
I don't know how much it will impact the current code. We must review the full API documentation.
@bashz i would recommend tagging the current branch before
There are two issues :
We need to add a method in order to delete a training expression.
When sending train(), WIT API is not accepting samples when text length is greater than 280.
Two solutions are available : Either slice the text or return an error
@bashz : What do you think ?
Wit.entity.delete() fails when making multiple calls. The second call always concatenates the entity id in URL with the previous one.
{
method: 'DELETE',
uri: '/entities/5b0eaea8-3531-4138-8b18-555a2968de07/5b0eab46-b8c8-4438-a1f3-24522bf0311c'
}
I guess this could be also the case for other methods ... must check.
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.