Error while online training - TypeError: 'Response' object is not iterable

I am getting following error while restaurant bot example . I have not done any changes-

127.0.0.1 - - [2018-09-14 16:57:06] “POST /conversations/default/execute HTTP/1.1” 200 849 0.003512

ERROR:rasa_core.server:Caught an exception during prediction.

Traceback (most recent call last):

File “/usr/local/lib/python3.5/dist-packages/rasa_core/server.py”, line 385, in continue_training batch_size=batch_size)

File “/usr/local/lib/python3.5/dist-packages/rasa_core/agent.py”, line 425, in continue_training **kwargs)

File “/usr/local/lib/python3.5/dist-packages/rasa_core/policies/ensemble.py”, line 192, in continue_training self.training_trackers.extend(trackers)

AttributeError: ‘NoneType’ object has no attribute ‘extend’

Traceback (most recent call last):

File “/usr/local/lib/python3.5/dist-packages/gevent/pywsgi.py”, line 936, in handle_one_response self.run_application()

File “/usr/local/lib/python3.5/dist-packages/gevent/pywsgi.py”, line 910, in run_application self.process_result()

File “/usr/local/lib/python3.5/dist-packages/gevent/pywsgi.py”, line 894, in process_result for data in self.result:

File “/usr/local/lib/python3.5/dist-packages/werkzeug/wsgi.py”, line 870, in next return self._next()

File “/usr/local/lib/python3.5/dist-packages/werkzeug/wrappers.py”, line 82, in _iter_encoded for item in iterable:

TypeError: ‘Response’ object is not iterable

Fri Sep 14 16:57:06 2018 {‘REMOTE_ADDR’: ‘127.0.0.1’, ‘HTTP_HOST’: ‘localhost:5005’, ‘REMOTE_PORT’: ‘44884’, (hidden keys: 23)} failed with TypeError

127.0.0.1 - - [2018-09-14 16:57:06] “POST /finetune HTTP/1.1” 500 161 0.005085

ERROR:rasa_core.training.online:An exception occurred while recording messages. Traceback (most recent call last):

File “/usr/local/lib/python3.5/dist-packages/rasa_core/training/online.py”, line 362, in record_messages sender_id)

File “/usr/local/lib/python3.5/dist-packages/rasa_core/training/online.py”, line 296, in predict_till_next_listen response.get(“tracker”, {}).get(“events”, []))

File “/usr/local/lib/python3.5/dist-packages/rasa_core/training/online.py”, line 201, in send_finetune r.raise_for_status()

File “/usr/local/lib/python3.5/dist-packages/requests/models.py”, line 935, in raise_for_status

raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:5005/finetune

Exception in thread Thread-1:

Traceback (most recent call last):

File “/usr/lib/python3.5/threading.py”, line 914, in _bootstrap_inner self.run()

File “/usr/lib/python3.5/threading.py”, line 862, in run self._target(*self._args, **self._kwargs)

File “/usr/local/lib/python3.5/dist-packages/rasa_core/training/online.py”, line 362, in record_messages sender_id)

File “/usr/local/lib/python3.5/dist-packages/rasa_core/training/online.py”, line 296, in predict_till_next_listen response.get(“tracker”, {}).get(“events”, []))

File “/usr/local/lib/python3.5/dist-packages/rasa_core/training/online.py”, line 201, in send_finetune r.raise_for_status()

File “/usr/local/lib/python3.5/dist-packages/requests/models.py”, line 935, in raise_for_status raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:5005/finetune

what’s the command you used to run online training? and also what version are you using? These kinds of issues where you’re actually getting errors from running things would usually be created as an issue in the repo :slight_smile: The correct command that worked for me for online training with the restaurant bot is: python -m rasa_core.train -s data/babi_stories.md -o models/dialogue/ -d restaurant_domain.yml --online

I am getting this issue with this version . When I executed this example on rasa core 0.9.6, I did not encounter this error.

I am using latest version of rasa core - 0.11.3 I am running it in Pycharm using following code -

fallback = FallbackPolicy(fallback_action_name='utter_default', nlu_threshold=0.8)

agent = Agent(domain_file, policies= [KerasPolicy(), fallback], interpreter=interpreter)

data = agent.load_data(training_data_file)

agent.train_online(
    data,
    max_history=2,
    batch_size=50,
    epochs=300,
    max_training_samples=300)

return agent

agent.train_online doesn’t exist anymore in 0.11.3, please use the command i provided

Thank you. It is working now

Hi Akela,

How can i incorporate custom fallback action in this command?

Thank you, Shruti

@akelad: I think the error is related to the --finetune flag. Whenever I run online training with --finetune I still get the “Internal Server Error for url: http://localhost:5005/finetune” error.

I doesn’t happen all the time though. Primarily when correcting something. Here’s a log of what happened the last time:

? The bot wants to run 'custom_action', correct?  No                
? What is the next action of the bot?  0.01 utter_greetings.hello                   
Thanks! The bot will now run utter_greetings.hello.

127.0.0.1 - - [2018-10-01 11:48:42] "POST /conversations/default/execute HTTP/1.1" 200 5379 0.002985
2018-10-01 11:48:42 ERROR    rasa_core.server  - Caught an exception during prediction.
Traceback (most recent call last):
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/server.py", line 425, in continue_training
    batch_size=batch_size)
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/agent.py", line 425, in continue_training
    **kwargs)
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/policies/ensemble.py", line 197, in continue_training
    self.training_trackers.extend(trackers)
AttributeError: 'NoneType' object has no attribute 'extend'
Traceback (most recent call last):
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 975, in handle_one_response
    self.run_application()
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 923, in run_application
    self.process_result()
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 907, in process_result
    for data in self.result:
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/werkzeug/wsgi.py", line 870, in __next__
    return self._next()
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/werkzeug/wrappers.py", line 82, in _iter_encoded
    for item in iterable:
TypeError: 'Response' object is not iterable
2018-10-01T09:48:42Z {'REMOTE_PORT': '58896', 'HTTP_HOST': 'localhost:5005', 'REMOTE_ADDR': '127.0.0.1', (hidden keys: 23)} failed with TypeError

127.0.0.1 - - [2018-10-01 11:48:42] "POST /finetune HTTP/1.1" 500 161 0.034838
2018-10-01 11:48:42 ERROR    rasa_core.training.online  - An exception occurred while recording messages.
Traceback (most recent call last):
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/training/online.py", line 860, in record_messages
    finetune=finetune)
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/training/online.py", line 599, in _predict_till_next_listen
    endpoint, sender_id, finetune=finetune)
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/training/online.py", line 662, in _validate_action
    finetune=finetune)
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/training/online.py", line 635, in _correct_wrong_action
    response.get("tracker", {}).get("events", []))
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/training/online.py", line 173, in send_finetune
    return _response_as_json(r)
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/rasa_core/training/online.py", line 62, in _response_as_json
    response.raise_for_status()
  File "/usr/chatbot/rasa/virtualenv/lib/python2.7/site-packages/requests/models.py", line 939, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:5005/finetune

Looks to me like something like that is happening:

  1. You correct one of the actions that got predicted wrong
  2. Bot tries to continue training
  3. Error happens in rasa_core/policies/ensemble.py", line 197, in continue_training: AttributeError: 'NoneType' object has no attribute 'extend'
  4. This causes pyWSGI to crash
  5. Which in return causes rasa_core/training/online.py to crash

Any thoughts on that?

Please create an issue with some details on the rasa core repo

Created a new issue here: Online / interactive training crashes when correcting false next action predictions with --finetuning · Issue #1114 · RasaHQ/rasa_core · GitHub

1 Like