wit-ai / pywit

Python library for Wit.ai
Other
1.46k stars 361 forks source link

action missing exception in run_actions() #64

Closed spaelling closed 6 years ago

spaelling commented 8 years ago

I am sometimes getting the below error. Seems to be when wit.ai is unable to determine the intent. Could this be responded to in a more elegant way?

Or am I doing something completely wrong?

ERROR:jarvis:error when running wit actions
TypeError("Can't convert 'NoneType' object to str implicitly",)
Traceback (most recent call last):
  File "quickstart.py", line 220, in handle_command
    context1 = witclient.run_actions(session_id, command, context0)
  File "C:\Users\Anders\AppData\Local\Programs\Python\Python35-32\lib\site-packages\wit-4.1.0-py3.5.egg\wit\wit.py", line 154, in run_actions
    context, max_steps, verbose)
  File "C:\Users\Anders\AppData\Local\Programs\Python\Python35-32\lib\site-packages\wit-4.1.0-py3.5.egg\wit\wit.py", line 127, in __run_actions
    self.throw_if_action_missing(action)
  File "C:\Users\Anders\AppData\Local\Programs\Python\Python35-32\lib\site-packages\wit-4.1.0-py3.5.egg\wit\wit.py", line 192, in throw_if_action_missing
    raise WitError('unknown action: ' + action_name)
TypeError: Can't convert 'NoneType' object to str implicitly
patapizza commented 7 years ago

Hi @spaelling,

Do you still experience the issue?

sils commented 7 years ago

Same for me!

avbanks commented 7 years ago

in wit.ai did you spell 'get_forecast' exactly like the bottom? actions = { 'send': send, 'getForecast': get_forecast, }

 def throw_if_action_missing(self, action_name):
    if action_name not in self.actions:
        raise WitError('unknown action: ' + action_name)
jiajia-z commented 7 years ago

Same here. What is a "NoneType" action?

pierremonico commented 7 years ago

Same here:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pierre/Dropbox/Projects/chobot/venv/lib/python3.5/site-packages/wit/wit.py", line 210, in interactive
    context = self.run_actions(session_id, message, context, max_steps)
  File "/home/pierre/Dropbox/Projects/chobot/venv/lib/python3.5/site-packages/wit/wit.py", line 176, in run_actions
    context, max_steps, verbose)
  File "/home/pierre/Dropbox/Projects/chobot/venv/lib/python3.5/site-packages/wit/wit.py", line 149, in __run_actions
    self.throw_if_action_missing(action)
  File "/home/pierre/Dropbox/Projects/chobot/venv/lib/python3.5/site-packages/wit/wit.py", line 214, in throw_if_action_missing
    raise WitError('unknown action: ' + action_name)
TypeError: Can't convert 'NoneType' object to str implicitly
pierremonico commented 7 years ago

The problem comes from the fact that the payload return from the Converse API contains action: None. In order to catch the error, this change could be made:

raise WitError('unknown action: ' + action_name)
raise WitError('unknown action: ' + str(action_name))

While that gets rid of the TypeError, I still have trouble understanding why Wit returns a None action here. Is it mandatory to have user input that relates to an action when using the Converse API? If no action is matched, isn't possible to just return text, intent etc. and no action payload at all?

I have to say that while I like the fact that your docs are recipe-based, I find the overall Documentation of Wit not to be very clear. If I manage to get a better grasp of it, I'd be happy to contribute to the docs of at least this repo.

aforaleka commented 6 years ago

Closing actions-related issues. Please check out the new examples with the /message implementation :)