Repository: facebookresearch/ParlAI

Issue:
Cannot have multi-turn conversation with agent via interactive_web.py script
Cannot have multi-turn conversation with agent via interactive_web.py script

**Reproduction steps**
Run interacive_web.py with some model file 
```
python3 ../ParlAI/parlai/scripts/interactive_web.py -mf ~/models/model_file 
```
communicate with the agent, send any two consecutive messages as shown below.
```
curl -XPOST "http://localhost:8080/interact" "Content-Type: text" -d "Hello"
```
**Expected behavior**
No exception should be thrown, agent should be available for multi-turn conversation.

The second message produces the following stacktrace
```
Exception happened during processing of request from ('127.0.0.1', 55372)
Traceback (most recent call last):
  File "/Users/johnsmith/miniconda3/envs/rasa-env/lib/python3.6/socketserver.py", line 320, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/Users/johnsmith/miniconda3/envs/rasa-env/lib/python3.6/socketserver.py", line 351, in process_request
    self.finish_request(request, client_address)
  File "/Users/johnsmith/miniconda3/envs/rasa-env/lib/python3.6/socketserver.py", line 364, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Users/johnsmith/miniconda3/envs/rasa-env/lib/python3.6/socketserver.py", line 724, in __init__
    self.handle()
  File "/Users/johnsmith/miniconda3/envs/rasa-env/lib/python3.6/http/server.py", line 418, in handle
    self.handle_one_request()
  File "/Users/johnsmith/miniconda3/envs/rasa-env/lib/python3.6/http/server.py", line 406, in handle_one_request
    method()
  File "/Users/johnsmith/ParlAI/parlai/scripts/interactive_web.py", line 155, in do_POST
    SHARED.get('opt'), body.decode('utf-8')
  File "/Users/johnsmith/ParlAI/parlai/scripts/interactive_web.py", line 139, in interactive_running
    SHARED['agent'].observe(reply)
  File "/Users/johnsmith/ParlAI/parlai/core/torch_agent.py", line 1545, in observe
    reply = self.last_reply(use_reply=self.opt.get('use_reply', 'label'))
  File "/Users/johnsmith/ParlAI/parlai/core/torch_agent.py", line 1515, in last_reply
    or self.observation['episode_done']
KeyError: 'episode_done'
--------------------------

After second message.
```

### Suggestion
The following edit could be made to prevent this issue.
```
self.observation['episode_done'] --> 'episode_done' in self.observation
```
### Extra
Making the change above allows multi-turn conversation, but now there is the question of some functionality terminating the conversation from the client-side i.e.
```
curl -XPOST "http://localhost:8080/interact" "Content-Type: text" -d "[DONE]"
```
such that user application or human has some option to terminate multi-turn conversations. 
If this should be moved to functionality, just let me know!

Thank you 🙏 


Discussion:
Thanks for pointing this out, will fix.

Resolving patch:
diff --git a/parlai/scripts/interactive_web.py b/parlai/scripts/interactive_web.py
--- a/parlai/scripts/interactive_web.py
+++ b/parlai/scripts/interactive_web.py
@@ -134,8 +134,7 @@
 
 class MyHandler(BaseHTTPRequestHandler):
     def interactive_running(self, opt, reply_text):
-        reply = {}
-        reply['text'] = reply_text
+        reply = {'episode_done': False, 'text': reply_text}
         SHARED['agent'].observe(reply)
         model_res = SHARED['agent'].act()
         return model_res


Test patch: