kengz / aiva

AIVA (A.I. Virtual Assistant): General-purpose virtual assistant for developers.
http://kengz.me/aiva/
MIT License
824 stars 597 forks source link

error : qp not defined #28

Closed nguruprasanna closed 8 years ago

nguruprasanna commented 8 years ago

Hi,

I have installed as per the blog (https://explosion.ai/blog/chatbot-node-js-spacy). and I get following error. I am exploring to use spacy, aiva, and spacy-nlpfor building our chatbots. During evaluation I am stuck as given below.

guru@qubeme:~/qubeme/aiva$ npm start --debug

aiva@4.1.2 start /home/guru/qubeme/aiva bin/start

[ ------- Starting on local machine, not Docker ------- ]

aiva@4.1.2 development /home/guru/qubeme/aiva mkdir -p ./logs; NODE_ENV=development ./node_modules/forever/bin/forever --minUptime=1000 --spinSleepTime=1000 --killSignal=SIGTERM --uid aiva-development -m 10 -a index.js | tee ./logs/aiva-development.log

[Sun Nov 06 2016 21:39:39 GMT+0000 (utc)] INFO Authenticated database successfully [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] DEBUG Sequelize [Node: 6.9.1, CLI: 2.4.0, ORM: 3.24.8]

Loaded configuration file "config/db.json". Using environment "development". No migrations were executed, database schema was already up to date.

[Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] INFO Starting aiva process [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] DEBUG globalConfig { "BOTNAME": "aivadev", "PORTS": { "NEO4J": 7476, "SOCKETIO": 6466, "SLACK": 8345, "TELEGRAM": 8443, "FB": 8545 }, "NGROK_AUTH": "sign up at https://ngrok.com for custom domain", "ADMINS": [ "your_chat_account@email.com" ], "TEST": { "HUBOT_SHELL_USER_ID": "ID0000001", "HUBOT_SHELL_USER_NAME": "alice" } } [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] INFO Starting poly-socketio server on port: 6466, expecting 4 IO clients [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] DEBUG adapterConfig { "ACTIVATE": true, "HUBOT_SLACK_TOKEN": "xoxb-101071100564-BfpiYk5RUTVvmhLgqRYif8zi" } [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] DEBUG import js lib from client.js [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] INFO Starting socketIO client for js at 6466 [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] INFO Starting socketIO client for python3 at 6466 [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] DEBUG Set SLACK PORT: 8345 [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] DEBUG No WEBHOOK set for adapter SLACK [Sun Nov 06 2016 21:39:42 GMT+0000 (utc)] INFO Deploying bot aivadev with adapter SLACK [Sun Nov 06 2016 21:39:43 GMT+0000 (utc)] INFO Starting socketIO client for python3 at 6466 [Sun Nov 06 2016 21:39:47 GMT+0000 (utc)] DEBUG js 7kXQcLv692VVYP2HAAAA joined, 3 remains [Sun Nov 06 2016 21:39:48 GMT+0000 (utc)] DEBUG py GymNT7B3Z70qe52NAAAB joined, 2 remains [Sun Nov 06 2016 21:39:48 GMT+0000 (utc)] DEBUG cgkb-py SDAEbR5_vH1kVGvWAAAC joined, 1 remains [Sun Nov 06 2016 21:39:48 GMT+0000 (utc)] INFO Logged in as qubemefaq of ETIOS [Sun Nov 06 2016 21:39:48 GMT+0000 (utc)] INFO Slack client now connected [Sun Nov 06 2016 21:39:49 GMT+0000 (utc)] DEBUG Started global js socketIO client for SLACK at 6466 [Sun Nov 06 2016 21:39:49 GMT+0000 (utc)] DEBUG global-client-js cxDW7rY6y7mPZz29AAAD joined, 0 remains [Sun Nov 06 2016 21:39:49 GMT+0000 (utc)] INFO All 4 IO clients have joined [Sun Nov 06 2016 21:40:02 GMT+0000 (utc)] DEBUG Started global js socketIO client for SLACK at 6466 [Sun Nov 06 2016 21:40:02 GMT+0000 (utc)] DEBUG Added a callback to hasher for global-client [Sun Nov 06 2016 21:40:03 GMT+0000 (utc)] DEBUG global-client-js cxDW7rY6y7mPZz29AAAD joined, -1 remains [Sun Nov 06 2016 21:40:03 GMT+0000 (utc)] INFO All 4 IO clients have joined [Sun Nov 06 2016 21:40:03 GMT+0000 (utc)] DEBUG IO on pass, msg: { "hash": "global-client-js_ca2ac79176604b19bfdb2fcb29e75584", "from": "global-client-js", "input": "Book a flight from new york to london for sunday.", "to": "nlp.cgkb-py", "intent": "parse" } fn: undefined [Sun Nov 06 2016 21:40:03 GMT+0000 (utc)] DEBUG IO on pass, msg: { "to": "global-client-js", "output": null, "from": "cgkb-py", "hash": "global-client-js_ca2ac79176604b19bfdb2fcb29e75584" } fn: undefined [Sun Nov 06 2016 21:40:03 GMT+0000 (utc)] DEBUG hash string exists for global-client [Sun Nov 06 2016 21:40:03 GMT+0000 (utc)] DEBUG hasher.handle invoking cb for global-client [Sun Nov 06 2016 21:40:03 GMT+0000 (utc)] DEBUG hash string exists for global-client [Sun Nov 06 2016 21:40:03 GMT+0000 (utc)] DEBUG hasher.handle invoking cb for global-client Unhandled rejection ReferenceError: qp is not defined at Object. (/home/guru/qubeme/aiva/node_modules/cgkb/src/cgkb.js:50:34) at undefined.next (native) at onFulfilled (/home/guru/qubeme/aiva/node_modules/co/index.js:65:19) at runCallback (timers.js:637:20) at tryOnImmediate (timers.js:610:5) at processImmediate [as _immediateCallback] (timers.js:582:5) From previous event: at Object.co (/home/guru/qubeme/aiva/node_modules/co/index.js:50:10) at Object.createPromise [as add] (/home/guru/qubeme/aiva/node_modules/co/index.js:30:15) at TextListener.robot.respond [as callback] (/home/guru/qubeme/aiva/scripts/cgkb-demo.js:29:12) at /home/guru/qubeme/aiva/node_modules/hubot/src/listener.coffee:65:12 at allDone (/home/guru/qubeme/aiva/node_modules/hubot/src/middleware.coffee:44:37) at /home/guru/qubeme/aiva/node_modules/hubot/node_modules/async/lib/async.js:274:13 at Object.async.eachSeries (/home/guru/qubeme/aiva/node_modules/hubot/node_modules/async/lib/async.js:142:20) at Object.async.reduce (/home/guru/qubeme/aiva/node_modules/hubot/node_modules/async/lib/async.js:268:15) at /home/guru/qubeme/aiva/node_modules/hubot/src/middleware.coffee:49:13 at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9) ^C

kengz commented 8 years ago

Hi,

Seems like the python module failed to return any result, so likely that spacy isn't running properly on your machine. Can you independently check spacy on python3?

import spacy
nlp = spacy.load('en')
doc = nlp('Hello, world. Here are two sentences.')
print(doc) # should print something
japel commented 8 years ago

I experienced the same problem. I used your code to test spacy on python3 and it returns:

~$ python3 spacyTest.py
Hello, world. Here are two sentences.
~$ 

what else could it be?

japel commented 8 years ago

How can be qp defined here? https://github.com/kengz/CGKB/blob/master/src/cgkb.js#L50

nguruprasanna commented 8 years ago

Hi,

It returns as follows...

import spacy nlp = spacy.load('en') doc = nlp('Hello, world. Here are two sentences.') print(doc) # should print something Hello, world. Here are two sentences.

Guru

kengz commented 8 years ago

Hi @japel you're right, good catch! I meant to call it on graphs. Just corrected it, published the npm module 1.0.4, and updated aiva to use it. To update:

git remote add upstream https://github.com/kengz/aiva.git
git fetch upstream
git merge upstream/master

and to make sure your node module is up to date, reinstall

npm r cgkb
npm i cgkb

Let me know if the issue is resolved :)

japel commented 8 years ago

this seems to solve the issue...

But I still don't see anything on neo4j when querying: "MATCH (u) RETURN u"

kengz commented 8 years ago

Hey, just pushed another update (v1.0.5) this morning fixing that neo4j issue. Can you update and try again?

japel commented 8 years ago

Still, the query above shows "(no rows)"

here is the log output:

[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] INFO Receiving message_id: XXXX
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG Started global js socketIO client for TELEGRAM at 6466
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG Added a callback to hasher for global-client
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG global-client-js PyIHtjUvUqrZHnUUAAAD joined, -2 remains
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] INFO All 4 IO clients have joined
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG IO on pass, msg: {
  "hash": "global-client-js_4ea7f9bc23a43715e7a10bec65876642",
  "from": "global-client-js",
  "input": "Hello there",
  "to": "nlp.cgkb-py",
  "intent": "parse"
} fn: undefined
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG IO on pass, msg: {
  "from": "cgkb-py",
  "output": null,
  "hash": "global-client-js_4ea7f9bc23a43715e7a10bec65876642",
  "to": "global-client-js"
} fn: undefined
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG hash string exists for global-client
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG hasher.handle invoking cb for global-client
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG hash string exists for global-client
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG hasher.handle invoking cb for global-client
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG hash string exists for global-client
[Tue Nov 08 2016 13:24:25 GMT+0000 (utc)] DEBUG hasher.handle invoking cb for global-client
[Tue Nov 08 2016 13:24:26 GMT+0000 (utc)] INFO Sending message to room: XXXXXXX
kengz commented 8 years ago

Hmm very peculiar, this is a separate issue from the qp now. They python module is returning null in the output. You shd be getting something like this instead:

[Tue Nov 08 2016 13:16:30 GMT+0000 (UTC)] DEBUG IO on pass, msg: {
  "hash": "global-client-js_3b887b9c7c802284405a9bb3845d648f",
  "from": "global-client-js",
  "input": "I am a pizza",
  "to": "nlp.cgkb-py",
  "intent": "parse"
} fn: undefined
[Tue Nov 08 2016 13:16:30 GMT+0000 (UTC)] DEBUG IO on pass, msg: {
  "output": [
    {
      "text": "I am a pizza",
      "len": 4,
      "tokens": [
        "I",
        "am",
        "a",
        "pizza"
      ],
      "noun_phrases": [
        "I",
        "a pizza"
      ],
      "parse_tree": [
        {
          "word": "am",
          "lemma": "be",
          "NE": "",
          "POS_fine": "VBP",
          "POS_coarse": "VERB",
          "arc": "ROOT",
          "modifiers": [
            ...
  ],
  "from": "cgkb-py",
  "to": "global-client-js",
  "hash": "global-client-js_3b887b9c7c802284405a9bb3845d648f"
} fn: undefined

What is your machine (Ubuntu or MacOS), node version, and the python version which spacy was installed into? AIVA's internal process calls python3 client.py

nguruprasanna commented 8 years ago

Same for me I have it on ubuntu

kengz commented 8 years ago

yep likely the same issue

kengz commented 8 years ago

Dependency source code fixed, closing the issue.