When parsing user utterance defined by "User says..." in Stories (Beta) which has no entities, the I bump into exception KeyError: 'entities' (See details in the log at the end.)
at line https://github.com/wit-ai/pywit/blob/master/wit/wit.py#L101
If I am not mistaken the solution can be simple:
Instead of this line
context = self.actions['merge'](session_id, dict(context), rst['entities'], user_message)
use this one
context = self.actions['merge'](session_id, dict(context), rst.get('entities', {}), user_message)
oplatek@mb:master:bot$ ./bot.py
> Hi
Starting new HTTPS connection (1): api.wit.ai
2016-06-14 10:31:26,487 - wit.wit - INFO - Executing merge
Msg: Hi
Entities: {}
Context updated ctx:
{}
Starting new HTTPS connection (1): api.wit.ai
2016-06-14 10:31:27,431 - wit.wit - INFO - Executing say with: In arms, sir
User In arms, sir
Starting new HTTPS connection (1): api.wit.ai
2016-06-14 10:31:28,498 - wit.wit - INFO - Executing action arm
Call arming Angee func
2016-06-14 10:31:28,498 - wit.wit - WARNING - missing context - did you forget to return it?
Starting new HTTPS connection (1): api.wit.ai
2016-06-14 10:31:29,933 - wit.wit - INFO - Executing say with: In arms, sir
User In arms, sir
Starting new HTTPS connection (1): api.wit.ai
2016-06-14 10:31:30,933 - wit.wit - INFO - Executing merge
Traceback (most recent call last):
File "./bot.py", line 41, in <module>
client.interactive()
File "/Users/oplatek/Library/Python/2.7/lib/python/site-packages/wit/wit.py", line 152, in interactive
context = self.run_actions(session_id, message, context, max_steps)
File "/Users/oplatek/Library/Python/2.7/lib/python/site-packages/wit/wit.py", line 126, in run_actions
message)
File "/Users/oplatek/Library/Python/2.7/lib/python/site-packages/wit/wit.py", line 119, in __run_actions
user_message)
File "/Users/oplatek/Library/Python/2.7/lib/python/site-packages/wit/wit.py", line 119, in __run_actions
user_message)
File "/Users/oplatek/Library/Python/2.7/lib/python/site-packages/wit/wit.py", line 119, in __run_actions
user_message)
File "/Users/oplatek/Library/Python/2.7/lib/python/site-packages/wit/wit.py", line 119, in __run_actions
user_message)
File "/Users/oplatek/Library/Python/2.7/lib/python/site-packages/wit/wit.py", line 98, in __run_actions
rst['entities'], user_message)
KeyError: 'entities'
When parsing user utterance defined by "User says..." in Stories (Beta) which has no entities, the I bump into exception
KeyError: 'entities'
(See details in the log at the end.) at line https://github.com/wit-ai/pywit/blob/master/wit/wit.py#L101If I am not mistaken the solution can be simple: Instead of this line
context = self.actions['merge'](session_id, dict(context), rst['entities'], user_message)
use this onecontext = self.actions['merge'](session_id, dict(context), rst.get('entities', {}), user_message)