Coder Social home page Coder Social logo

hexastack / wit-api Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 0.0 105 KB

Node lib to easily interact with Wit.ai HTTP API

License: BSD 4-Clause "Original" or "Old" License

JavaScript 100.00%
ai api facebook messenger natural-language-processing nlp nodejs wit wit-api

wit-api's People

Contributors

bashz avatar marrouchi avatar prasanthnarasimha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wit-api's Issues

Unable to add a new value a an entity - return entity "not-found'

Running unit tests returns :

nyc mocha --timeout 5000 --reporter nyan

17 --------------,------,
9 --------------| /_/\
0 --------------^|__( x .x)
-
------------- "" ""

17 passing (43s)
9 failing

  1. 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)

  2. 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)

  3. 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)

  4. 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)

  5. 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)

  6. 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)

  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)

  8. 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)

  9. 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.

Wit.train() not working

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.

Package needs update to implement new V2 API specification

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

Unable to wit.entity.update()

There are two issues :

  • HTTP request method is sent as POST instead of PUT
  • request var is undefined in the update() method

Train : Max text length is 280

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

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.